src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy
author blanchet
Fri, 01 Aug 2014 14:43:57 +0200
changeset 57743 0af2d5dfb0ac
parent 57512 cc97b347b301
child 57865 dcfb33c26f50
permissions -rw-r--r--
pushing skolems under 'iff' sometimes breaks things further down the proof (as was to be feared)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41959
b460124855b8 tuned headers;
wenzelm
parents: 41413
diff changeset
     1
(*  Title:      HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     2
    Author:     Robert Himmelmann, TU Muenchen
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
     3
    Author:     Bogdan Grechuk, University of Edinburgh
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     4
*)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     5
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     6
header {* Convex sets, functions and related things. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     7
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     8
theory Convex_Euclidean_Space
44132
0f35a870ecf1 full import paths
huffman
parents: 44125
diff changeset
     9
imports
56189
c4daa97ac57a removed dependencies on theory Ordered_Euclidean_Space
immler
parents: 56188
diff changeset
    10
  Topology_Euclidean_Space
44132
0f35a870ecf1 full import paths
huffman
parents: 44125
diff changeset
    11
  "~~/src/HOL/Library/Convex"
0f35a870ecf1 full import paths
huffman
parents: 44125
diff changeset
    12
  "~~/src/HOL/Library/Set_Algebras"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    13
begin
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    14
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    15
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    16
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    17
(* To be moved elsewhere                                                     *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    18
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    19
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
    20
lemma linear_scaleR: "linear (\<lambda>x. scaleR c x)"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
    21
  by (simp add: linear_iff scaleR_add_right)
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
    22
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
    23
lemma linear_scaleR_left: "linear (\<lambda>r. scaleR r x)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
    24
  by (simp add: linear_iff scaleR_add_left)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
    25
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    26
lemma injective_scaleR: "c \<noteq> 0 \<Longrightarrow> inj (\<lambda>x::'a::real_vector. scaleR c x)"
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
    27
  by (simp add: inj_on_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    28
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    29
lemma linear_add_cmul:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    30
  assumes "linear f"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    31
  shows "f (a *\<^sub>R x + b *\<^sub>R y) = a *\<^sub>R f x +  b *\<^sub>R f y"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    32
  using linear_add[of f] linear_cmul[of f] assms by simp
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    33
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    34
lemma mem_convex_alt:
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    35
  assumes "convex S" "x \<in> S" "y \<in> S" "u \<ge> 0" "v \<ge> 0" "u + v > 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    36
  shows "((u/(u+v)) *\<^sub>R x + (v/(u+v)) *\<^sub>R y) \<in> S"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
    37
  apply (rule convexD)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    38
  using assms
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
    39
  apply (simp_all add: zero_le_divide_iff add_divide_distrib [symmetric])
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    40
  done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    41
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    42
lemma inj_on_image_mem_iff: "inj_on f B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> f a \<in> f`A \<Longrightarrow> a \<in> B \<Longrightarrow> a \<in> A"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    43
  by (blast dest: inj_onD)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    44
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    45
lemma independent_injective_on_span_image:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
    46
  assumes iS: "independent S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    47
    and lf: "linear f"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    48
    and fi: "inj_on f (span S)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    49
  shows "independent (f ` S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    50
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    51
  {
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    52
    fix a
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    53
    assume a: "a \<in> S" "f a \<in> span (f ` S - {f a})"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    54
    have eq: "f ` S - {f a} = f ` (S - {a})"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    55
      using fi a span_inc by (auto simp add: inj_on_def)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    56
    from a have "f a \<in> f ` span (S -{a})"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    57
      unfolding eq span_linear_image [OF lf, of "S - {a}"] by blast
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    58
    moreover have "span (S - {a}) \<subseteq> span S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    59
      using span_mono[of "S - {a}" S] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    60
    ultimately have "a \<in> span (S - {a})"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    61
      using fi a span_inc by (auto simp add: inj_on_def)
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    62
    with a(1) iS have False
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    63
      by (simp add: dependent_def)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    64
  }
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    65
  then show ?thesis
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    66
    unfolding dependent_def by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    67
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    68
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    69
lemma dim_image_eq:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    70
  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    71
  assumes lf: "linear f"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    72
    and fi: "inj_on f (span S)"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    73
  shows "dim (f ` S) = dim (S::'n::euclidean_space set)"
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    74
proof -
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    75
  obtain B where B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "card B = dim S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    76
    using basis_exists[of S] by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    77
  then have "span S = span B"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    78
    using span_mono[of B S] span_mono[of S "span B"] span_span[of B] by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    79
  then have "independent (f ` B)"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    80
    using independent_injective_on_span_image[of B f] B assms by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    81
  moreover have "card (f ` B) = card B"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    82
    using assms card_image[of f B] subset_inj_on[of f "span S" B] B span_inc by auto
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    83
  moreover have "(f ` B) \<subseteq> (f ` S)"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    84
    using B by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    85
  ultimately have "dim (f ` S) \<ge> dim S"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
    86
    using independent_card_le_dim[of "f ` B" "f ` S"] B by auto
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    87
  then show ?thesis
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
    88
    using dim_image_le[of f S] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    89
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    90
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    91
lemma linear_injective_on_subspace_0:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    92
  assumes lf: "linear f"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    93
    and "subspace S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    94
  shows "inj_on f S \<longleftrightarrow> (\<forall>x \<in> S. f x = 0 \<longrightarrow> x = 0)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    95
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    96
  have "inj_on f S \<longleftrightarrow> (\<forall>x \<in> S. \<forall>y \<in> S. f x = f y \<longrightarrow> x = y)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    97
    by (simp add: inj_on_def)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    98
  also have "\<dots> \<longleftrightarrow> (\<forall>x \<in> S. \<forall>y \<in> S. f x - f y = 0 \<longrightarrow> x - y = 0)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    99
    by simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   100
  also have "\<dots> \<longleftrightarrow> (\<forall>x \<in> S. \<forall>y \<in> S. f (x - y) = 0 \<longrightarrow> x - y = 0)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   101
    by (simp add: linear_sub[OF lf])
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   102
  also have "\<dots> \<longleftrightarrow> (\<forall>x \<in> S. f x = 0 \<longrightarrow> x = 0)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   103
    using `subspace S` subspace_def[of S] subspace_sub[of S] by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   104
  finally show ?thesis .
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   105
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   106
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   107
lemma subspace_Inter: "\<forall>s \<in> f. subspace s \<Longrightarrow> subspace (Inter f)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   108
  unfolding subspace_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   109
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   110
lemma span_eq[simp]: "span s = s \<longleftrightarrow> subspace s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   111
  unfolding span_def by (rule hull_eq) (rule subspace_Inter)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   112
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   113
lemma substdbasis_expansion_unique:
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
   114
  assumes d: "d \<subseteq> Basis"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   115
  shows "(\<Sum>i\<in>d. f i *\<^sub>R i) = (x::'a::euclidean_space) \<longleftrightarrow>
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   116
    (\<forall>i\<in>Basis. (i \<in> d \<longrightarrow> f i = x \<bullet> i) \<and> (i \<notin> d \<longrightarrow> x \<bullet> i = 0))"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   117
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   118
  have *: "\<And>x a b P. x * (if P then a else b) = (if P then x * a else x * b)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   119
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   120
  have **: "finite d"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   121
    by (auto intro: finite_subset[OF assms])
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
   122
  have ***: "\<And>i. i \<in> Basis \<Longrightarrow> (\<Sum>i\<in>d. f i *\<^sub>R i) \<bullet> i = (\<Sum>x\<in>d. if x = i then f x else 0)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
   123
    using d
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   124
    by (auto intro!: setsum.cong simp: inner_Basis inner_setsum_left)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   125
  show ?thesis
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   126
    unfolding euclidean_eq_iff[where 'a='a] by (auto simp: setsum.delta[OF **] ***)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
   127
qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
   128
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
   129
lemma independent_substdbasis: "d \<subseteq> Basis \<Longrightarrow> independent d"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
   130
  by (rule independent_mono[OF independent_Basis])
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   131
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   132
lemma dim_cball:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   133
  assumes "e > 0"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   134
  shows "dim (cball (0 :: 'n::euclidean_space) e) = DIM('n)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   135
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   136
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   137
    fix x :: "'n::euclidean_space"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   138
    def y \<equiv> "(e / norm x) *\<^sub>R x"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   139
    then have "y \<in> cball 0 e"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   140
      using cball_def dist_norm[of 0 y] assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   141
    moreover have *: "x = (norm x / e) *\<^sub>R y"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   142
      using y_def assms by simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   143
    moreover from * have "x = (norm x/e) *\<^sub>R y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   144
      by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   145
    ultimately have "x \<in> span (cball 0 e)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   146
      using span_mul[of y "cball 0 e" "norm x/e"] span_inc[of "cball 0 e"] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   147
  }
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   148
  then have "span (cball 0 e) = (UNIV :: 'n::euclidean_space set)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   149
    by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   150
  then show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   151
    using dim_span[of "cball (0 :: 'n::euclidean_space) e"] by (auto simp add: dim_UNIV)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   152
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   153
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   154
lemma indep_card_eq_dim_span:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   155
  fixes B :: "'n::euclidean_space set"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   156
  assumes "independent B"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   157
  shows "finite B \<and> card B = dim (span B)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   158
  using assms basis_card_eq_dim[of B "span B"] span_inc by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   159
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   160
lemma setsum_not_0: "setsum f A \<noteq> 0 \<Longrightarrow> \<exists>a \<in> A. f a \<noteq> 0"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   161
  by (rule ccontr) auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   162
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   163
lemma translate_inj_on:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   164
  fixes A :: "'a::ab_group_add set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   165
  shows "inj_on (\<lambda>x. a + x) A"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   166
  unfolding inj_on_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   167
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   168
lemma translation_assoc:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   169
  fixes a b :: "'a::ab_group_add"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   170
  shows "(\<lambda>x. b + x) ` ((\<lambda>x. a + x) ` S) = (\<lambda>x. (a + b) + x) ` S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   171
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   172
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   173
lemma translation_invert:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   174
  fixes a :: "'a::ab_group_add"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   175
  assumes "(\<lambda>x. a + x) ` A = (\<lambda>x. a + x) ` B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   176
  shows "A = B"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   177
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   178
  have "(\<lambda>x. -a + x) ` ((\<lambda>x. a + x) ` A) = (\<lambda>x. - a + x) ` ((\<lambda>x. a + x) ` B)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   179
    using assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   180
  then show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   181
    using translation_assoc[of "-a" a A] translation_assoc[of "-a" a B] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   182
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   183
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   184
lemma translation_galois:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   185
  fixes a :: "'a::ab_group_add"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   186
  shows "T = ((\<lambda>x. a + x) ` S) \<longleftrightarrow> S = ((\<lambda>x. (- a) + x) ` T)"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   187
  using translation_assoc[of "-a" a S]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   188
  apply auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   189
  using translation_assoc[of a "-a" T]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   190
  apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   191
  done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   192
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   193
lemma translation_inverse_subset:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   194
  assumes "((\<lambda>x. - a + x) ` V) \<le> (S :: 'n::ab_group_add set)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   195
  shows "V \<le> ((\<lambda>x. a + x) ` S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   196
proof -
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   197
  {
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   198
    fix x
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   199
    assume "x \<in> V"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   200
    then have "x-a \<in> S" using assms by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   201
    then have "x \<in> {a + v |v. v \<in> S}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   202
      apply auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   203
      apply (rule exI[of _ "x-a"])
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   204
      apply simp
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   205
      done
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   206
    then have "x \<in> ((\<lambda>x. a+x) ` S)" by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   207
  }
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   208
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   209
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   210
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   211
lemma basis_to_basis_subspace_isomorphism:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   212
  assumes s: "subspace (S:: ('n::euclidean_space) set)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   213
    and t: "subspace (T :: ('m::euclidean_space) set)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   214
    and d: "dim S = dim T"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   215
    and B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "card B = dim S"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   216
    and C: "C \<subseteq> T" "independent C" "T \<subseteq> span C" "card C = dim T"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   217
  shows "\<exists>f. linear f \<and> f ` B = C \<and> f ` S = T \<and> inj_on f S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   218
proof -
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   219
  from B independent_bound have fB: "finite B"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   220
    by blast
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   221
  from C independent_bound have fC: "finite C"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   222
    by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   223
  from B(4) C(4) card_le_inj[of B C] d obtain f where
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   224
    f: "f ` B \<subseteq> C" "inj_on f B" using `finite B` `finite C` by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   225
  from linear_independent_extend[OF B(2)] obtain g where
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   226
    g: "linear g" "\<forall>x \<in> B. g x = f x" by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   227
  from inj_on_iff_eq_card[OF fB, of f] f(2)
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   228
  have "card (f ` B) = card B" by simp
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   229
  with B(4) C(4) have ceq: "card (f ` B) = card C" using d
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   230
    by simp
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   231
  have "g ` B = f ` B" using g(2)
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   232
    by (auto simp add: image_iff)
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   233
  also have "\<dots> = C" using card_subset_eq[OF fC f(1) ceq] .
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   234
  finally have gBC: "g ` B = C" .
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   235
  have gi: "inj_on g B" using f(2) g(2)
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   236
    by (auto simp add: inj_on_def)
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   237
  note g0 = linear_indep_image_lemma[OF g(1) fB, unfolded gBC, OF C(2) gi]
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   238
  {
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   239
    fix x y
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   240
    assume x: "x \<in> S" and y: "y \<in> S" and gxy: "g x = g y"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   241
    from B(3) x y have x': "x \<in> span B" and y': "y \<in> span B"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   242
      by blast+
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   243
    from gxy have th0: "g (x - y) = 0"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   244
      by (simp add: linear_sub[OF g(1)])
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   245
    have th1: "x - y \<in> span B" using x' y'
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   246
      by (metis span_sub)
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   247
    have "x = y" using g0[OF th1 th0] by simp
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   248
  }
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   249
  then have giS: "inj_on g S" unfolding inj_on_def by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   250
  from span_subspace[OF B(1,3) s]
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   251
  have "g ` S = span (g ` B)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   252
    by (simp add: span_linear_image[OF g(1)])
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   253
  also have "\<dots> = span C"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   254
    unfolding gBC ..
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   255
  also have "\<dots> = T"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   256
    using span_subspace[OF C(1,3) t] .
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   257
  finally have gS: "g ` S = T" .
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   258
  from g(1) gS giS gBC show ?thesis
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   259
    by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   260
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   261
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   262
lemma closure_bounded_linear_image:
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   263
  assumes f: "bounded_linear f"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   264
  shows "f ` closure S \<subseteq> closure (f ` S)"
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   265
  using linear_continuous_on [OF f] closed_closure closure_subset
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   266
  by (rule image_closure_subset)
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   267
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   268
lemma closure_linear_image:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   269
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::real_normed_vector"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   270
  assumes "linear f"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   271
  shows "f ` (closure S) \<le> closure (f ` S)"
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   272
  using assms unfolding linear_conv_bounded_linear
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   273
  by (rule closure_bounded_linear_image)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   274
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   275
lemma closure_injective_linear_image:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   276
  fixes f :: "'n::euclidean_space \<Rightarrow> 'n::euclidean_space"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   277
  assumes "linear f" "inj f"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   278
  shows "f ` (closure S) = closure (f ` S)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   279
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   280
  obtain f' where f': "linear f' \<and> f \<circ> f' = id \<and> f' \<circ> f = id"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   281
    using assms linear_injective_isomorphism[of f] isomorphism_expand by auto
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   282
  then have "f' ` closure (f ` S) \<le> closure (S)"
56154
f0a927235162 more complete set of lemmas wrt. image and composition
haftmann
parents: 55929
diff changeset
   283
    using closure_linear_image[of f' "f ` S"] image_comp[of f' f] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   284
  then have "f ` f' ` closure (f ` S) \<le> f ` closure S" by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   285
  then have "closure (f ` S) \<le> f ` closure S"
56154
f0a927235162 more complete set of lemmas wrt. image and composition
haftmann
parents: 55929
diff changeset
   286
    using image_comp[of f f' "closure (f ` S)"] f' by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   287
  then show ?thesis using closure_linear_image[of f S] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   288
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   289
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   290
lemma closure_scaleR:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   291
  fixes S :: "'a::real_normed_vector set"
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   292
  shows "(op *\<^sub>R c) ` (closure S) = closure ((op *\<^sub>R c) ` S)"
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   293
proof
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   294
  show "(op *\<^sub>R c) ` (closure S) \<subseteq> closure ((op *\<^sub>R c) ` S)"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   295
    using bounded_linear_scaleR_right
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   296
    by (rule closure_bounded_linear_image)
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
   297
  show "closure ((op *\<^sub>R c) ` S) \<subseteq> (op *\<^sub>R c) ` (closure S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   298
    by (intro closure_minimal image_mono closure_subset closed_scaling closed_closure)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   299
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   300
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   301
lemma fst_linear: "linear fst"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
   302
  unfolding linear_iff by (simp add: algebra_simps)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   303
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   304
lemma snd_linear: "linear snd"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
   305
  unfolding linear_iff by (simp add: algebra_simps)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   306
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   307
lemma fst_snd_linear: "linear (\<lambda>(x,y). x + y)"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
   308
  unfolding linear_iff by (simp add: algebra_simps)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   309
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   310
lemma scaleR_2:
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   311
  fixes x :: "'a::real_vector"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   312
  shows "scaleR 2 x = x + x"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   313
  unfolding one_add_one [symmetric] scaleR_left_distrib by simp
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   314
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   315
lemma vector_choose_size:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   316
  "0 \<le> c \<Longrightarrow> \<exists>x::'a::euclidean_space. norm x = c"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   317
  apply (rule exI [where x="c *\<^sub>R (SOME i. i \<in> Basis)"])
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
   318
  apply (auto simp: SOME_Basis)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   319
  done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   320
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   321
lemma setsum_delta_notmem:
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   322
  assumes "x \<notin> s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   323
  shows "setsum (\<lambda>y. if (y = x) then P x else Q y) s = setsum Q s"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   324
    and "setsum (\<lambda>y. if (x = y) then P x else Q y) s = setsum Q s"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   325
    and "setsum (\<lambda>y. if (y = x) then P y else Q y) s = setsum Q s"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   326
    and "setsum (\<lambda>y. if (x = y) then P y else Q y) s = setsum Q s"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   327
  apply (rule_tac [!] setsum.cong)
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   328
  using assms
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   329
  apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   330
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   331
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   332
lemma setsum_delta'':
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   333
  fixes s::"'a::real_vector set"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   334
  assumes "finite s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   335
  shows "(\<Sum>x\<in>s. (if y = x then f x else 0) *\<^sub>R x) = (if y\<in>s then (f y) *\<^sub>R y else 0)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   336
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   337
  have *: "\<And>x y. (if y = x then f x else (0::real)) *\<^sub>R x = (if x=y then (f x) *\<^sub>R x else 0)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   338
    by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   339
  show ?thesis
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   340
    unfolding * using setsum.delta[OF assms, of y "\<lambda>x. f x *\<^sub>R x"] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   341
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   342
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   343
lemma if_smult: "(if P then x else (y::real)) *\<^sub>R v = (if P then x *\<^sub>R v else y *\<^sub>R v)"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   344
  by (fact if_distrib)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   345
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   346
lemma dist_triangle_eq:
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
   347
  fixes x y z :: "'a::real_inner"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   348
  shows "dist x z = dist x y + dist y z \<longleftrightarrow>
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   349
    norm (x - y) *\<^sub>R (y - z) = norm (y - z) *\<^sub>R (x - y)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   350
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   351
  have *: "x - y + (y - z) = x - z" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   352
  show ?thesis unfolding dist_norm norm_triangle_eq[of "x - y" "y - z", unfolded *]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   353
    by (auto simp add:norm_minus_commute)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   354
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   355
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53374
diff changeset
   356
lemma norm_minus_eqI: "x = - y \<Longrightarrow> norm x = norm y" by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   357
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   358
lemma Min_grI:
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   359
  assumes "finite A" "A \<noteq> {}" "\<forall>a\<in>A. x < a"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   360
  shows "x < Min A"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   361
  unfolding Min_gr_iff[OF assms(1,2)] using assms(3) by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   362
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   363
lemma norm_lt: "norm x < norm y \<longleftrightarrow> inner x x < inner y y"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   364
  unfolding norm_eq_sqrt_inner by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   365
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   366
lemma norm_le: "norm x \<le> norm y \<longleftrightarrow> inner x x \<le> inner y y"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   367
  unfolding norm_eq_sqrt_inner by simp
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   368
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   369
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
   370
subsection {* Affine set and affine hull *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   371
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   372
definition affine :: "'a::real_vector set \<Rightarrow> bool"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   373
  where "affine s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u v. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> s)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   374
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   375
lemma affine_alt: "affine s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u::real. (1 - u) *\<^sub>R x + u *\<^sub>R y \<in> s)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   376
  unfolding affine_def by (metis eq_diff_eq')
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   377
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   378
lemma affine_empty[intro]: "affine {}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   379
  unfolding affine_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   380
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   381
lemma affine_sing[intro]: "affine {x}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   382
  unfolding affine_alt by (auto simp add: scaleR_left_distrib [symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   383
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   384
lemma affine_UNIV[intro]: "affine UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   385
  unfolding affine_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   386
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   387
lemma affine_Inter: "(\<forall>s\<in>f. affine s) \<Longrightarrow> affine (\<Inter> f)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   388
  unfolding affine_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   389
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   390
lemma affine_Int: "affine s \<Longrightarrow> affine t \<Longrightarrow> affine (s \<inter> t)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   391
  unfolding affine_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   392
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   393
lemma affine_affine_hull: "affine(affine hull s)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   394
  unfolding hull_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   395
  using affine_Inter[of "{t. affine t \<and> s \<subseteq> t}"] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   396
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   397
lemma affine_hull_eq[simp]: "(affine hull s = s) \<longleftrightarrow> affine s"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   398
  by (metis affine_affine_hull hull_same)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   399
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   400
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
   401
subsubsection {* Some explicit formulations (from Lars Schewe) *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   402
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   403
lemma affine:
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   404
  fixes V::"'a::real_vector set"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   405
  shows "affine V \<longleftrightarrow>
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   406
    (\<forall>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> V \<and> setsum u s = 1 \<longrightarrow> (setsum (\<lambda>x. (u x) *\<^sub>R x)) s \<in> V)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   407
  unfolding affine_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   408
  apply rule
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   409
  apply(rule, rule, rule)
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   410
  apply(erule conjE)+
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   411
  defer
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   412
  apply (rule, rule, rule, rule, rule)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   413
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   414
  fix x y u v
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   415
  assume as: "x \<in> V" "y \<in> V" "u + v = (1::real)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   416
    "\<forall>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> V \<and> setsum u s = 1 \<longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   417
  then show "u *\<^sub>R x + v *\<^sub>R y \<in> V"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   418
    apply (cases "x = y")
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   419
    using as(4)[THEN spec[where x="{x,y}"], THEN spec[where x="\<lambda>w. if w = x then u else v"]]
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   420
      and as(1-3)
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   421
    apply (auto simp add: scaleR_left_distrib[symmetric])
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   422
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   423
next
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   424
  fix s u
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   425
  assume as: "\<forall>x\<in>V. \<forall>y\<in>V. \<forall>u v. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> V"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   426
    "finite s" "s \<noteq> {}" "s \<subseteq> V" "setsum u s = (1::real)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   427
  def n \<equiv> "card s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   428
  have "card s = 0 \<or> card s = 1 \<or> card s = 2 \<or> card s > 2" by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   429
  then show "(\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   430
  proof (auto simp only: disjE)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   431
    assume "card s = 2"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   432
    then have "card s = Suc (Suc 0)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   433
      by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   434
    then obtain a b where "s = {a, b}"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   435
      unfolding card_Suc_eq by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   436
    then show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   437
      using as(1)[THEN bspec[where x=a], THEN bspec[where x=b]] using as(4,5)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   438
      by (auto simp add: setsum_clauses(2))
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   439
  next
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   440
    assume "card s > 2"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   441
    then show ?thesis using as and n_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   442
    proof (induct n arbitrary: u s)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   443
      case 0
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   444
      then show ?case by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   445
    next
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   446
      case (Suc n)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   447
      fix s :: "'a set" and u :: "'a \<Rightarrow> real"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   448
      assume IA:
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   449
        "\<And>u s.  \<lbrakk>2 < card s; \<forall>x\<in>V. \<forall>y\<in>V. \<forall>u v. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> V; finite s;
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   450
          s \<noteq> {}; s \<subseteq> V; setsum u s = 1; n = card s \<rbrakk> \<Longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   451
        and as:
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   452
          "Suc n = card s" "2 < card s" "\<forall>x\<in>V. \<forall>y\<in>V. \<forall>u v. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> V"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   453
           "finite s" "s \<noteq> {}" "s \<subseteq> V" "setsum u s = 1"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   454
      have "\<exists>x\<in>s. u x \<noteq> 1"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   455
      proof (rule ccontr)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   456
        assume "\<not> ?thesis"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   457
        then have "setsum u s = real_of_nat (card s)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   458
          unfolding card_eq_setsum by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   459
        then show False
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   460
          using as(7) and `card s > 2`
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   461
          by (metis One_nat_def less_Suc0 Zero_not_Suc of_nat_1 of_nat_eq_iff numeral_2_eq_2)
45498
2dc373f1867a avoid numeral-representation-specific rules in metis proof
huffman
parents: 45051
diff changeset
   462
      qed
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   463
      then obtain x where x:"x \<in> s" "u x \<noteq> 1" by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   464
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   465
      have c: "card (s - {x}) = card s - 1"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   466
        apply (rule card_Diff_singleton)
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   467
        using `x\<in>s` as(4)
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   468
        apply auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   469
        done
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   470
      have *: "s = insert x (s - {x})" "finite (s - {x})"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   471
        using `x\<in>s` and as(4) by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   472
      have **: "setsum u (s - {x}) = 1 - u x"
49530
wenzelm
parents: 49529
diff changeset
   473
        using setsum_clauses(2)[OF *(2), of u x, unfolded *(1)[symmetric] as(7)] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   474
      have ***: "inverse (1 - u x) * setsum u (s - {x}) = 1"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   475
        unfolding ** using `u x \<noteq> 1` by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   476
      have "(\<Sum>xa\<in>s - {x}. (inverse (1 - u x) * u xa) *\<^sub>R xa) \<in> V"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   477
      proof (cases "card (s - {x}) > 2")
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   478
        case True
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   479
        then have "s - {x} \<noteq> {}" "card (s - {x}) = n"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   480
          unfolding c and as(1)[symmetric]
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   481
        proof (rule_tac ccontr)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   482
          assume "\<not> s - {x} \<noteq> {}"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   483
          then have "card (s - {x}) = 0" unfolding card_0_eq[OF *(2)] by simp
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   484
          then show False using True by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   485
        qed auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   486
        then show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   487
          apply (rule_tac IA[of "s - {x}" "\<lambda>y. (inverse (1 - u x) * u y)"])
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   488
          unfolding setsum_right_distrib[symmetric]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   489
          using as and *** and True
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   490
          apply auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   491
          done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   492
      next
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   493
        case False
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   494
        then have "card (s - {x}) = Suc (Suc 0)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   495
          using as(2) and c by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   496
        then obtain a b where "(s - {x}) = {a, b}" "a\<noteq>b"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   497
          unfolding card_Suc_eq by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   498
        then show ?thesis
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   499
          using as(3)[THEN bspec[where x=a], THEN bspec[where x=b]]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   500
          using *** *(2) and `s \<subseteq> V`
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   501
          unfolding setsum_right_distrib
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   502
          by (auto simp add: setsum_clauses(2))
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   503
      qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   504
      then have "u x + (1 - u x) = 1 \<Longrightarrow>
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   505
          u x *\<^sub>R x + (1 - u x) *\<^sub>R ((\<Sum>xa\<in>s - {x}. u xa *\<^sub>R xa) /\<^sub>R (1 - u x)) \<in> V"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   506
        apply -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   507
        apply (rule as(3)[rule_format])
51524
7cb5ac44ca9e rename RealVector.thy to Real_Vector_Spaces.thy
hoelzl
parents: 51480
diff changeset
   508
        unfolding  Real_Vector_Spaces.scaleR_right.setsum
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   509
        using x(1) as(6)
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   510
        apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   511
        done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   512
      then show "(\<Sum>x\<in>s. u x *\<^sub>R x) \<in> V"
49530
wenzelm
parents: 49529
diff changeset
   513
        unfolding scaleR_scaleR[symmetric] and scaleR_right.setsum [symmetric]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   514
        apply (subst *)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   515
        unfolding setsum_clauses(2)[OF *(2)]
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   516
        using `u x \<noteq> 1`
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   517
        apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   518
        done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   519
    qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   520
  next
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   521
    assume "card s = 1"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   522
    then obtain a where "s={a}"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   523
      by (auto simp add: card_Suc_eq)
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   524
    then show ?thesis
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   525
      using as(4,5) by simp
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   526
  qed (insert `s\<noteq>{}` `finite s`, auto)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   527
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   528
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   529
lemma affine_hull_explicit:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   530
  "affine hull p =
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   531
    {y. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> setsum (\<lambda>v. (u v) *\<^sub>R v) s = y}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   532
  apply (rule hull_unique)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   533
  apply (subst subset_eq)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   534
  prefer 3
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   535
  apply rule
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   536
  unfolding mem_Collect_eq
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   537
  apply (erule exE)+
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   538
  apply (erule conjE)+
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   539
  prefer 2
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   540
  apply rule
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   541
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   542
  fix x
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   543
  assume "x\<in>p"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   544
  then show "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   545
    apply (rule_tac x="{x}" in exI)
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   546
    apply (rule_tac x="\<lambda>x. 1" in exI)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   547
    apply auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   548
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   549
next
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   550
  fix t x s u
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   551
  assume as: "p \<subseteq> t" "affine t" "finite s" "s \<noteq> {}"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   552
    "s \<subseteq> p" "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   553
  then show "x \<in> t"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   554
    using as(2)[unfolded affine, THEN spec[where x=s], THEN spec[where x=u]]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   555
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   556
next
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   557
  show "affine {y. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y}"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   558
    unfolding affine_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   559
    apply (rule, rule, rule, rule, rule)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   560
    unfolding mem_Collect_eq
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   561
  proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   562
    fix u v :: real
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   563
    assume uv: "u + v = 1"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   564
    fix x
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   565
    assume "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   566
    then obtain sx ux where
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   567
      x: "finite sx" "sx \<noteq> {}" "sx \<subseteq> p" "setsum ux sx = 1" "(\<Sum>v\<in>sx. ux v *\<^sub>R v) = x"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   568
      by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   569
    fix y
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   570
    assume "\<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   571
    then obtain sy uy where
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   572
      y: "finite sy" "sy \<noteq> {}" "sy \<subseteq> p" "setsum uy sy = 1" "(\<Sum>v\<in>sy. uy v *\<^sub>R v) = y" by auto
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   573
    have xy: "finite (sx \<union> sy)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   574
      using x(1) y(1) by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   575
    have **: "(sx \<union> sy) \<inter> sx = sx" "(sx \<union> sy) \<inter> sy = sy"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   576
      by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   577
    show "\<exists>s ua. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p \<and>
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   578
        setsum ua s = 1 \<and> (\<Sum>v\<in>s. ua v *\<^sub>R v) = u *\<^sub>R x + v *\<^sub>R y"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   579
      apply (rule_tac x="sx \<union> sy" in exI)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   580
      apply (rule_tac x="\<lambda>a. (if a\<in>sx then u * ux a else 0) + (if a\<in>sy then v * uy a else 0)" in exI)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   581
      unfolding scaleR_left_distrib setsum.distrib if_smult scaleR_zero_left
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   582
        ** setsum.inter_restrict[OF xy, symmetric]
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   583
      unfolding scaleR_scaleR[symmetric] Real_Vector_Spaces.scaleR_right.setsum [symmetric]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   584
        and setsum_right_distrib[symmetric]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   585
      unfolding x y
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   586
      using x(1-3) y(1-3) uv
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   587
      apply simp
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   588
      done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   589
  qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   590
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   591
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   592
lemma affine_hull_finite:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   593
  assumes "finite s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   594
  shows "affine hull s = {y. \<exists>u. setsum u s = 1 \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = y}"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   595
  unfolding affine_hull_explicit and set_eq_iff and mem_Collect_eq
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   596
  apply (rule, rule)
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   597
  apply (erule exE)+
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   598
  apply (erule conjE)+
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   599
  defer
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   600
  apply (erule exE)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   601
  apply (erule conjE)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   602
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   603
  fix x u
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   604
  assume "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   605
  then show "\<exists>sa u. finite sa \<and>
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   606
      \<not> (\<forall>x. (x \<in> sa) = (x \<in> {})) \<and> sa \<subseteq> s \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = x"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   607
    apply (rule_tac x=s in exI, rule_tac x=u in exI)
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   608
    using assms
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   609
    apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   610
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   611
next
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   612
  fix x t u
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   613
  assume "t \<subseteq> s"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   614
  then have *: "s \<inter> t = t"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   615
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   616
  assume "finite t" "\<not> (\<forall>x. (x \<in> t) = (x \<in> {}))" "setsum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = x"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   617
  then show "\<exists>u. setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   618
    apply (rule_tac x="\<lambda>x. if x\<in>t then u x else 0" in exI)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   619
    unfolding if_smult scaleR_zero_left and setsum.inter_restrict[OF assms, symmetric] and *
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   620
    apply auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   621
    done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   622
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   623
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   624
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
   625
subsubsection {* Stepping theorems and hence small special cases *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   626
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   627
lemma affine_hull_empty[simp]: "affine hull {} = {}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   628
  by (rule hull_unique) auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   629
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   630
lemma affine_hull_finite_step:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   631
  fixes y :: "'a::real_vector"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   632
  shows
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   633
    "(\<exists>u. setsum u {} = w \<and> setsum (\<lambda>x. u x *\<^sub>R x) {} = y) \<longleftrightarrow> w = 0 \<and> y = 0" (is ?th1)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   634
    and
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   635
    "finite s \<Longrightarrow>
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   636
      (\<exists>u. setsum u (insert a s) = w \<and> setsum (\<lambda>x. u x *\<^sub>R x) (insert a s) = y) \<longleftrightarrow>
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   637
      (\<exists>v u. setsum u s = w - v \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y - v *\<^sub>R a)" (is "_ \<Longrightarrow> ?lhs = ?rhs")
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   638
proof -
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   639
  show ?th1 by simp
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   640
  assume fin: "finite s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   641
  show "?lhs = ?rhs"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   642
  proof
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   643
    assume ?lhs
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   644
    then obtain u where u: "setsum u (insert a s) = w \<and> (\<Sum>x\<in>insert a s. u x *\<^sub>R x) = y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   645
      by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   646
    show ?rhs
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   647
    proof (cases "a \<in> s")
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   648
      case True
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   649
      then have *: "insert a s = s" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   650
      show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   651
        using u[unfolded *]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   652
        apply(rule_tac x=0 in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   653
        apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   654
        done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   655
    next
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   656
      case False
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   657
      then show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   658
        apply (rule_tac x="u a" in exI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   659
        using u and fin
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   660
        apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   661
        done
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   662
    qed
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   663
  next
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   664
    assume ?rhs
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   665
    then obtain v u where vu: "setsum u s = w - v"  "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   666
      by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   667
    have *: "\<And>x M. (if x = a then v else M) *\<^sub>R x = (if x = a then v *\<^sub>R x else M *\<^sub>R x)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   668
      by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   669
    show ?lhs
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   670
    proof (cases "a \<in> s")
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   671
      case True
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   672
      then show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   673
        apply (rule_tac x="\<lambda>x. (if x=a then v else 0) + u x" in exI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   674
        unfolding setsum_clauses(2)[OF fin]
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   675
        apply simp
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   676
        unfolding scaleR_left_distrib and setsum.distrib
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   677
        unfolding vu and * and scaleR_zero_left
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   678
        apply (auto simp add: setsum.delta[OF fin])
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   679
        done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   680
    next
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   681
      case False
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   682
      then have **:
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   683
        "\<And>x. x \<in> s \<Longrightarrow> u x = (if x = a then v else u x)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   684
        "\<And>x. x \<in> s \<Longrightarrow> u x *\<^sub>R x = (if x = a then v *\<^sub>R x else u x *\<^sub>R x)" by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   685
      from False show ?thesis
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   686
        apply (rule_tac x="\<lambda>x. if x=a then v else u x" in exI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   687
        unfolding setsum_clauses(2)[OF fin] and * using vu
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   688
        using setsum.cong [of s _ "\<lambda>x. u x *\<^sub>R x" "\<lambda>x. if x = a then v *\<^sub>R x else u x *\<^sub>R x", OF _ **(2)]
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   689
        using setsum.cong [of s _ u "\<lambda>x. if x = a then v else u x", OF _ **(1)]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   690
        apply auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   691
        done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   692
    qed
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   693
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   694
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   695
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   696
lemma affine_hull_2:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   697
  fixes a b :: "'a::real_vector"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   698
  shows "affine hull {a,b} = {u *\<^sub>R a + v *\<^sub>R b| u v. (u + v = 1)}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   699
  (is "?lhs = ?rhs")
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   700
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   701
  have *:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   702
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::real)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   703
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::'a)" by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   704
  have "?lhs = {y. \<exists>u. setsum u {a, b} = 1 \<and> (\<Sum>v\<in>{a, b}. u v *\<^sub>R v) = y}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   705
    using affine_hull_finite[of "{a,b}"] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   706
  also have "\<dots> = {y. \<exists>v u. u b = 1 - v \<and> u b *\<^sub>R b = y - v *\<^sub>R a}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   707
    by (simp add: affine_hull_finite_step(2)[of "{b}" a])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   708
  also have "\<dots> = ?rhs" unfolding * by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   709
  finally show ?thesis by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   710
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   711
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   712
lemma affine_hull_3:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   713
  fixes a b c :: "'a::real_vector"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   714
  shows "affine hull {a,b,c} = { u *\<^sub>R a + v *\<^sub>R b + w *\<^sub>R c| u v w. u + v + w = 1}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   715
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   716
  have *:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   717
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::real)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   718
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::'a)" by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   719
  show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   720
    apply (simp add: affine_hull_finite affine_hull_finite_step)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   721
    unfolding *
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   722
    apply auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   723
    apply (rule_tac x=v in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   724
    apply (rule_tac x=va in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   725
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   726
    apply (rule_tac x=u in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   727
    apply force
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   728
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   729
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   730
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   731
lemma mem_affine:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   732
  assumes "affine S" "x \<in> S" "y \<in> S" "u + v = 1"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   733
  shows "u *\<^sub>R x + v *\<^sub>R y \<in> S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   734
  using assms affine_def[of S] by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   735
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   736
lemma mem_affine_3:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   737
  assumes "affine S" "x \<in> S" "y \<in> S" "z \<in> S" "u + v + w = 1"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   738
  shows "u *\<^sub>R x + v *\<^sub>R y + w *\<^sub>R z \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   739
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   740
  have "u *\<^sub>R x + v *\<^sub>R y + w *\<^sub>R z \<in> affine hull {x, y, z}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   741
    using affine_hull_3[of x y z] assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   742
  moreover
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   743
  have "affine hull {x, y, z} \<subseteq> affine hull S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   744
    using hull_mono[of "{x, y, z}" "S"] assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   745
  moreover
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   746
  have "affine hull S = S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   747
    using assms affine_hull_eq[of S] by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   748
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   749
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   750
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   751
lemma mem_affine_3_minus:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   752
  assumes "affine S" "x \<in> S" "y \<in> S" "z \<in> S"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   753
  shows "x + v *\<^sub>R (y-z) \<in> S"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   754
  using mem_affine_3[of S x y z 1 v "-v"] assms
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   755
  by (simp add: algebra_simps)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   756
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   757
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
   758
subsubsection {* Some relations between affine hull and subspaces *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   759
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   760
lemma affine_hull_insert_subset_span:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   761
  "affine hull (insert a s) \<subseteq> {a + v| v . v \<in> span {x - a | x . x \<in> s}}"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   762
  unfolding subset_eq Ball_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   763
  unfolding affine_hull_explicit span_explicit mem_Collect_eq
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
   764
  apply (rule, rule)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
   765
  apply (erule exE)+
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
   766
  apply (erule conjE)+
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   767
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   768
  fix x t u
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   769
  assume as: "finite t" "t \<noteq> {}" "t \<subseteq> insert a s" "setsum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = x"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   770
  have "(\<lambda>x. x - a) ` (t - {a}) \<subseteq> {x - a |x. x \<in> s}"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   771
    using as(3) by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   772
  then show "\<exists>v. x = a + v \<and> (\<exists>S u. finite S \<and> S \<subseteq> {x - a |x. x \<in> s} \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = v)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   773
    apply (rule_tac x="x - a" in exI)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   774
    apply (rule conjI, simp)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   775
    apply (rule_tac x="(\<lambda>x. x - a) ` (t - {a})" in exI)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   776
    apply (rule_tac x="\<lambda>x. u (x + a)" in exI)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   777
    apply (rule conjI) using as(1) apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   778
    apply (erule conjI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   779
    using as(1)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   780
    apply (simp add: setsum.reindex[unfolded inj_on_def] scaleR_right_diff_distrib
49530
wenzelm
parents: 49529
diff changeset
   781
      setsum_subtractf scaleR_left.setsum[symmetric] setsum_diff1 scaleR_left_diff_distrib)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   782
    unfolding as
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   783
    apply simp
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   784
    done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   785
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   786
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   787
lemma affine_hull_insert_span:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   788
  assumes "a \<notin> s"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   789
  shows "affine hull (insert a s) = {a + v | v . v \<in> span {x - a | x.  x \<in> s}}"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   790
  apply (rule, rule affine_hull_insert_subset_span)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   791
  unfolding subset_eq Ball_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   792
  unfolding affine_hull_explicit and mem_Collect_eq
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   793
proof (rule, rule, erule exE, erule conjE)
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   794
  fix y v
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   795
  assume "y = a + v" "v \<in> span {x - a |x. x \<in> s}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   796
  then obtain t u where obt: "finite t" "t \<subseteq> {x - a |x. x \<in> s}" "a + (\<Sum>v\<in>t. u v *\<^sub>R v) = y"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   797
    unfolding span_explicit by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   798
  def f \<equiv> "(\<lambda>x. x + a) ` t"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   799
  have f: "finite f" "f \<subseteq> s" "(\<Sum>v\<in>f. u (v - a) *\<^sub>R (v - a)) = y - a"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   800
    unfolding f_def using obt by (auto simp add: setsum.reindex[unfolded inj_on_def])
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   801
  have *: "f \<inter> {a} = {}" "f \<inter> - {a} = f"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   802
    using f(2) assms by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   803
  show "\<exists>sa u. finite sa \<and> sa \<noteq> {} \<and> sa \<subseteq> insert a s \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   804
    apply (rule_tac x = "insert a f" in exI)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   805
    apply (rule_tac x = "\<lambda>x. if x=a then 1 - setsum (\<lambda>x. u (x - a)) f else u (x - a)" in exI)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   806
    using assms and f
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   807
    unfolding setsum_clauses(2)[OF f(1)] and if_smult
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
   808
    unfolding setsum.If_cases[OF f(1), of "\<lambda>x. x = a"]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   809
    apply (auto simp add: setsum_subtractf scaleR_left.setsum algebra_simps *)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   810
    done
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   811
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   812
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   813
lemma affine_hull_span:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   814
  assumes "a \<in> s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   815
  shows "affine hull s = {a + v | v. v \<in> span {x - a | x. x \<in> s - {a}}}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   816
  using affine_hull_insert_span[of a "s - {a}", unfolded insert_Diff[OF assms]] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   817
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   818
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
   819
subsubsection {* Parallel affine sets *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   820
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
   821
definition affine_parallel :: "'a::real_vector set \<Rightarrow> 'a::real_vector set \<Rightarrow> bool"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   822
  where "affine_parallel S T \<longleftrightarrow> (\<exists>a. T = (\<lambda>x. a + x) ` S)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   823
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   824
lemma affine_parallel_expl_aux:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   825
  fixes S T :: "'a::real_vector set"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   826
  assumes "\<forall>x. x \<in> S \<longleftrightarrow> a + x \<in> T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   827
  shows "T = (\<lambda>x. a + x) ` S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   828
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   829
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   830
    fix x
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   831
    assume "x \<in> T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   832
    then have "( - a) + x \<in> S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   833
      using assms by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   834
    then have "x \<in> ((\<lambda>x. a + x) ` S)"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   835
      using imageI[of "-a+x" S "(\<lambda>x. a+x)"] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   836
  }
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   837
  moreover have "T \<ge> (\<lambda>x. a + x) ` S"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   838
    using assms by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   839
  ultimately show ?thesis by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   840
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   841
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   842
lemma affine_parallel_expl: "affine_parallel S T \<longleftrightarrow> (\<exists>a. \<forall>x. x \<in> S \<longleftrightarrow> a + x \<in> T)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   843
  unfolding affine_parallel_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   844
  using affine_parallel_expl_aux[of S _ T] by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   845
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   846
lemma affine_parallel_reflex: "affine_parallel S S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   847
  unfolding affine_parallel_def
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   848
  apply (rule exI[of _ "0"])
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   849
  apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   850
  done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   851
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   852
lemma affine_parallel_commut:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   853
  assumes "affine_parallel A B"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   854
  shows "affine_parallel B A"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   855
proof -
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
   856
  from assms obtain a where B: "B = (\<lambda>x. a + x) ` A"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   857
    unfolding affine_parallel_def by auto
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
   858
  have [simp]: "(\<lambda>x. x - a) = plus (- a)" by (simp add: fun_eq_iff)
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
   859
  from B show ?thesis
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   860
    using translation_galois [of B a A]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   861
    unfolding affine_parallel_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   862
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   863
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   864
lemma affine_parallel_assoc:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   865
  assumes "affine_parallel A B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   866
    and "affine_parallel B C"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   867
  shows "affine_parallel A C"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   868
proof -
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   869
  from assms obtain ab where "B = (\<lambda>x. ab + x) ` A"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   870
    unfolding affine_parallel_def by auto
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   871
  moreover
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   872
  from assms obtain bc where "C = (\<lambda>x. bc + x) ` B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   873
    unfolding affine_parallel_def by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   874
  ultimately show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   875
    using translation_assoc[of bc ab A] unfolding affine_parallel_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   876
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   877
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   878
lemma affine_translation_aux:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   879
  fixes a :: "'a::real_vector"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   880
  assumes "affine ((\<lambda>x. a + x) ` S)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   881
  shows "affine S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   882
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   883
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   884
    fix x y u v
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   885
    assume xy: "x \<in> S" "y \<in> S" "(u :: real) + v = 1"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   886
    then have "(a + x) \<in> ((\<lambda>x. a + x) ` S)" "(a + y) \<in> ((\<lambda>x. a + x) ` S)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   887
      by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   888
    then have h1: "u *\<^sub>R  (a + x) + v *\<^sub>R (a + y) \<in> (\<lambda>x. a + x) ` S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   889
      using xy assms unfolding affine_def by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   890
    have "u *\<^sub>R (a + x) + v *\<^sub>R (a + y) = (u + v) *\<^sub>R a + (u *\<^sub>R x + v *\<^sub>R y)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   891
      by (simp add: algebra_simps)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   892
    also have "\<dots> = a + (u *\<^sub>R x + v *\<^sub>R y)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   893
      using `u + v = 1` by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   894
    ultimately have "a + (u *\<^sub>R x + v *\<^sub>R y) \<in> (\<lambda>x. a + x) ` S"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   895
      using h1 by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   896
    then have "u *\<^sub>R x + v *\<^sub>R y : S" by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   897
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   898
  then show ?thesis unfolding affine_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   899
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   900
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   901
lemma affine_translation:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   902
  fixes a :: "'a::real_vector"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   903
  shows "affine S \<longleftrightarrow> affine ((\<lambda>x. a + x) ` S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   904
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   905
  have "affine S \<Longrightarrow> affine ((\<lambda>x. a + x) ` S)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   906
    using affine_translation_aux[of "-a" "((\<lambda>x. a + x) ` S)"]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   907
    using translation_assoc[of "-a" a S] by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   908
  then show ?thesis using affine_translation_aux by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   909
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   910
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   911
lemma parallel_is_affine:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   912
  fixes S T :: "'a::real_vector set"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   913
  assumes "affine S" "affine_parallel S T"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   914
  shows "affine T"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   915
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   916
  from assms obtain a where "T = (\<lambda>x. a + x) ` S"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   917
    unfolding affine_parallel_def by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   918
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   919
    using affine_translation assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   920
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   921
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
   922
lemma subspace_imp_affine: "subspace s \<Longrightarrow> affine s"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   923
  unfolding subspace_def affine_def by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   924
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   925
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
   926
subsubsection {* Subspace parallel to an affine set *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   927
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   928
lemma subspace_affine: "subspace S \<longleftrightarrow> affine S \<and> 0 \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   929
proof -
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   930
  have h0: "subspace S \<Longrightarrow> affine S \<and> 0 \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   931
    using subspace_imp_affine[of S] subspace_0 by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   932
  {
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   933
    assume assm: "affine S \<and> 0 \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   934
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   935
      fix c :: real
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   936
      fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   937
      assume x: "x \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   938
      have "c *\<^sub>R x = (1-c) *\<^sub>R 0 + c *\<^sub>R x" by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   939
      moreover
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   940
      have "(1 - c) *\<^sub>R 0 + c *\<^sub>R x \<in> S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   941
        using affine_alt[of S] assm x by auto
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   942
      ultimately have "c *\<^sub>R x \<in> S" by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   943
    }
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   944
    then have h1: "\<forall>c. \<forall>x \<in> S. c *\<^sub>R x \<in> S" by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   945
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   946
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   947
      fix x y
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   948
      assume xy: "x \<in> S" "y \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   949
      def u == "(1 :: real)/2"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   950
      have "(1/2) *\<^sub>R (x+y) = (1/2) *\<^sub>R (x+y)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   951
        by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   952
      moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   953
      have "(1/2) *\<^sub>R (x+y)=(1/2) *\<^sub>R x + (1-(1/2)) *\<^sub>R y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   954
        by (simp add: algebra_simps)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   955
      moreover
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   956
      have "(1 - u) *\<^sub>R x + u *\<^sub>R y \<in> S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   957
        using affine_alt[of S] assm xy by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   958
      ultimately
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   959
      have "(1/2) *\<^sub>R (x+y) \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   960
        using u_def by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   961
      moreover
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   962
      have "x + y = 2 *\<^sub>R ((1/2) *\<^sub>R (x+y))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   963
        by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   964
      ultimately
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   965
      have "x + y \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   966
        using h1[rule_format, of "(1/2) *\<^sub>R (x+y)" "2"] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   967
    }
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   968
    then have "\<forall>x \<in> S. \<forall>y \<in> S. x + y \<in> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   969
      by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   970
    then have "subspace S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   971
      using h1 assm unfolding subspace_def by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   972
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   973
  then show ?thesis using h0 by metis
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   974
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   975
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   976
lemma affine_diffs_subspace:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   977
  assumes "affine S" "a \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   978
  shows "subspace ((\<lambda>x. (-a)+x) ` S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   979
proof -
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
   980
  have [simp]: "(\<lambda>x. x - a) = plus (- a)" by (simp add: fun_eq_iff)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   981
  have "affine ((\<lambda>x. (-a)+x) ` S)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   982
    using  affine_translation assms by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   983
  moreover have "0 : ((\<lambda>x. (-a)+x) ` S)"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   984
    using assms exI[of "(\<lambda>x. x\<in>S \<and> -a+x = 0)" a] by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   985
  ultimately show ?thesis using subspace_affine by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   986
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   987
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   988
lemma parallel_subspace_explicit:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   989
  assumes "affine S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   990
    and "a \<in> S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   991
  assumes "L \<equiv> {y. \<exists>x \<in> S. (-a) + x = y}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   992
  shows "subspace L \<and> affine_parallel S L"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   993
proof -
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
   994
  from assms have "L = plus (- a) ` S" by auto
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
   995
  then have par: "affine_parallel S L"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
   996
    unfolding affine_parallel_def ..
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
   997
  then have "affine L" using assms parallel_is_affine by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
   998
  moreover have "0 \<in> L"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
   999
    using assms by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1000
  ultimately show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1001
    using subspace_affine par by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1002
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1003
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1004
lemma parallel_subspace_aux:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1005
  assumes "subspace A"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1006
    and "subspace B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1007
    and "affine_parallel A B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1008
  shows "A \<supseteq> B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1009
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1010
  from assms obtain a where a: "\<forall>x. x \<in> A \<longleftrightarrow> a + x \<in> B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1011
    using affine_parallel_expl[of A B] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1012
  then have "-a \<in> A"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1013
    using assms subspace_0[of B] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1014
  then have "a \<in> A"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1015
    using assms subspace_neg[of A "-a"] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1016
  then show ?thesis
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1017
    using assms a unfolding subspace_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1018
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1019
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1020
lemma parallel_subspace:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1021
  assumes "subspace A"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1022
    and "subspace B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1023
    and "affine_parallel A B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1024
  shows "A = B"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1025
proof
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1026
  show "A \<supseteq> B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1027
    using assms parallel_subspace_aux by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1028
  show "A \<subseteq> B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1029
    using assms parallel_subspace_aux[of B A] affine_parallel_commut by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1030
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1031
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1032
lemma affine_parallel_subspace:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1033
  assumes "affine S" "S \<noteq> {}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1034
  shows "\<exists>!L. subspace L \<and> affine_parallel S L"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1035
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1036
  have ex: "\<exists>L. subspace L \<and> affine_parallel S L"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1037
    using assms parallel_subspace_explicit by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1038
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1039
    fix L1 L2
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1040
    assume ass: "subspace L1 \<and> affine_parallel S L1" "subspace L2 \<and> affine_parallel S L2"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1041
    then have "affine_parallel L1 L2"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1042
      using affine_parallel_commut[of S L1] affine_parallel_assoc[of L1 S L2] by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1043
    then have "L1 = L2"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1044
      using ass parallel_subspace by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1045
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1046
  then show ?thesis using ex by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1047
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1048
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1049
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1050
subsection {* Cones *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1051
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1052
definition cone :: "'a::real_vector set \<Rightarrow> bool"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1053
  where "cone s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>c\<ge>0. c *\<^sub>R x \<in> s)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1054
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1055
lemma cone_empty[intro, simp]: "cone {}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1056
  unfolding cone_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1057
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1058
lemma cone_univ[intro, simp]: "cone UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1059
  unfolding cone_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1060
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1061
lemma cone_Inter[intro]: "\<forall>s\<in>f. cone s \<Longrightarrow> cone (\<Inter>f)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1062
  unfolding cone_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1063
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1064
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1065
subsubsection {* Conic hull *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1066
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1067
lemma cone_cone_hull: "cone (cone hull s)"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  1068
  unfolding hull_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1069
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1070
lemma cone_hull_eq: "cone hull s = s \<longleftrightarrow> cone s"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1071
  apply (rule hull_eq)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1072
  using cone_Inter
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1073
  unfolding subset_eq
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1074
  apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1075
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1076
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1077
lemma mem_cone:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1078
  assumes "cone S" "x \<in> S" "c \<ge> 0"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1079
  shows "c *\<^sub>R x : S"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1080
  using assms cone_def[of S] by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1081
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1082
lemma cone_contains_0:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1083
  assumes "cone S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1084
  shows "S \<noteq> {} \<longleftrightarrow> 0 \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1085
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1086
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1087
    assume "S \<noteq> {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1088
    then obtain a where "a \<in> S" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1089
    then have "0 \<in> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1090
      using assms mem_cone[of S a 0] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1091
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1092
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1093
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1094
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  1095
lemma cone_0: "cone {0}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1096
  unfolding cone_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1097
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1098
lemma cone_Union[intro]: "(\<forall>s\<in>f. cone s) \<longrightarrow> cone (Union f)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1099
  unfolding cone_def by blast
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1100
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1101
lemma cone_iff:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1102
  assumes "S \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1103
  shows "cone S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (op *\<^sub>R c) ` S = S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1104
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1105
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1106
    assume "cone S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1107
    {
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1108
      fix c :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1109
      assume "c > 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1110
      {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1111
        fix x
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1112
        assume "x \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1113
        then have "x \<in> (op *\<^sub>R c) ` S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1114
          unfolding image_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1115
          using `cone S` `c>0` mem_cone[of S x "1/c"]
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1116
            exI[of "(\<lambda>t. t \<in> S \<and> x = c *\<^sub>R t)" "(1 / c) *\<^sub>R x"]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1117
          by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1118
      }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1119
      moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1120
      {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1121
        fix x
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1122
        assume "x \<in> (op *\<^sub>R c) ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1123
        then have "x \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1124
          using `cone S` `c > 0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1125
          unfolding cone_def image_def `c > 0` by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1126
      }
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1127
      ultimately have "(op *\<^sub>R c) ` S = S" by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1128
    }
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1129
    then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (op *\<^sub>R c) ` S = S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1130
      using `cone S` cone_contains_0[of S] assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1131
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1132
  moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1133
  {
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1134
    assume a: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (op *\<^sub>R c) ` S = S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1135
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1136
      fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1137
      assume "x \<in> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1138
      fix c1 :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1139
      assume "c1 \<ge> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1140
      then have "c1 = 0 \<or> c1 > 0" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1141
      then have "c1 *\<^sub>R x \<in> S" using a `x \<in> S` by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1142
    }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1143
    then have "cone S" unfolding cone_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1144
  }
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1145
  ultimately show ?thesis by blast
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1146
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1147
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1148
lemma cone_hull_empty: "cone hull {} = {}"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1149
  by (metis cone_empty cone_hull_eq)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1150
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1151
lemma cone_hull_empty_iff: "S = {} \<longleftrightarrow> cone hull S = {}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1152
  by (metis bot_least cone_hull_empty hull_subset xtrans(5))
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1153
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1154
lemma cone_hull_contains_0: "S \<noteq> {} \<longleftrightarrow> 0 \<in> cone hull S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1155
  using cone_cone_hull[of S] cone_contains_0[of "cone hull S"] cone_hull_empty_iff[of S]
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1156
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1157
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1158
lemma mem_cone_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1159
  assumes "x \<in> S" "c \<ge> 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1160
  shows "c *\<^sub>R x \<in> cone hull S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1161
  by (metis assms cone_cone_hull hull_inc mem_cone)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1162
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1163
lemma cone_hull_expl: "cone hull S = {c *\<^sub>R x | c x. c \<ge> 0 \<and> x \<in> S}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1164
  (is "?lhs = ?rhs")
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1165
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1166
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1167
    fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1168
    assume "x \<in> ?rhs"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1169
    then obtain cx :: real and xx where x: "x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1170
      by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1171
    fix c :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1172
    assume c: "c \<ge> 0"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1173
    then have "c *\<^sub>R x = (c * cx) *\<^sub>R xx"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1174
      using x by (simp add: algebra_simps)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1175
    moreover
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  1176
    have "c * cx \<ge> 0" using c x by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1177
    ultimately
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1178
    have "c *\<^sub>R x \<in> ?rhs" using x by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1179
  }
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1180
  then have "cone ?rhs"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1181
    unfolding cone_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1182
  then have "?rhs \<in> Collect cone"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1183
    unfolding mem_Collect_eq by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1184
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1185
    fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1186
    assume "x \<in> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1187
    then have "1 *\<^sub>R x \<in> ?rhs"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1188
      apply auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1189
      apply (rule_tac x = 1 in exI)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1190
      apply auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1191
      done
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1192
    then have "x \<in> ?rhs" by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1193
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1194
  then have "S \<subseteq> ?rhs" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1195
  then have "?lhs \<subseteq> ?rhs"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1196
    using `?rhs \<in> Collect cone` hull_minimal[of S "?rhs" "cone"] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1197
  moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1198
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1199
    fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1200
    assume "x \<in> ?rhs"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1201
    then obtain cx :: real and xx where x: "x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1202
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1203
    then have "xx \<in> cone hull S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1204
      using hull_subset[of S] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1205
    then have "x \<in> ?lhs"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1206
      using x cone_cone_hull[of S] cone_def[of "cone hull S"] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1207
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1208
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1209
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1210
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1211
lemma cone_closure:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1212
  fixes S :: "'a::real_normed_vector set"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1213
  assumes "cone S"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1214
  shows "cone (closure S)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1215
proof (cases "S = {}")
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1216
  case True
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1217
  then show ?thesis by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1218
next
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1219
  case False
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1220
  then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` S = S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1221
    using cone_iff[of S] assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1222
  then have "0 \<in> closure S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` closure S = closure S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1223
    using closure_subset by (auto simp add: closure_scaleR)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1224
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1225
    using cone_iff[of "closure S"] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1226
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1227
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1228
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1229
subsection {* Affine dependence and consequential theorems (from Lars Schewe) *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1230
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1231
definition affine_dependent :: "'a::real_vector set \<Rightarrow> bool"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1232
  where "affine_dependent s \<longleftrightarrow> (\<exists>x\<in>s. x \<in> affine hull (s - {x}))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1233
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1234
lemma affine_dependent_explicit:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1235
  "affine_dependent p \<longleftrightarrow>
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1236
    (\<exists>s u. finite s \<and> s \<subseteq> p \<and> setsum u s = 0 \<and>
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1237
      (\<exists>v\<in>s. u v \<noteq> 0) \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = 0)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1238
  unfolding affine_dependent_def affine_hull_explicit mem_Collect_eq
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1239
  apply rule
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1240
  apply (erule bexE, erule exE, erule exE)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1241
  apply (erule conjE)+
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1242
  defer
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1243
  apply (erule exE, erule exE)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1244
  apply (erule conjE)+
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1245
  apply (erule bexE)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1246
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1247
  fix x s u
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1248
  assume as: "x \<in> p" "finite s" "s \<noteq> {}" "s \<subseteq> p - {x}" "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1249
  have "x \<notin> s" using as(1,4) by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1250
  show "\<exists>s u. finite s \<and> s \<subseteq> p \<and> setsum u s = 0 \<and> (\<exists>v\<in>s. u v \<noteq> 0) \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1251
    apply (rule_tac x="insert x s" in exI, rule_tac x="\<lambda>v. if v = x then - 1 else u v" in exI)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1252
    unfolding if_smult and setsum_clauses(2)[OF as(2)] and setsum_delta_notmem[OF `x\<notin>s`] and as
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1253
    using as
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1254
    apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1255
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1256
next
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1257
  fix s u v
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1258
  assume as: "finite s" "s \<subseteq> p" "setsum u s = 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0" "v \<in> s" "u v \<noteq> 0"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1259
  have "s \<noteq> {v}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1260
    using as(3,6) by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1261
  then show "\<exists>x\<in>p. \<exists>s u. finite s \<and> s \<noteq> {} \<and> s \<subseteq> p - {x} \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1262
    apply (rule_tac x=v in bexI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1263
    apply (rule_tac x="s - {v}" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1264
    apply (rule_tac x="\<lambda>x. - (1 / u v) * u x" in exI)
49530
wenzelm
parents: 49529
diff changeset
  1265
    unfolding scaleR_scaleR[symmetric] and scaleR_right.setsum [symmetric]
wenzelm
parents: 49529
diff changeset
  1266
    unfolding setsum_right_distrib[symmetric] and setsum_diff1[OF as(1)]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1267
    using as
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1268
    apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1269
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1270
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1271
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1272
lemma affine_dependent_explicit_finite:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1273
  fixes s :: "'a::real_vector set"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1274
  assumes "finite s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1275
  shows "affine_dependent s \<longleftrightarrow>
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1276
    (\<exists>u. setsum u s = 0 \<and> (\<exists>v\<in>s. u v \<noteq> 0) \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = 0)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1277
  (is "?lhs = ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1278
proof
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1279
  have *: "\<And>vt u v. (if vt then u v else 0) *\<^sub>R v = (if vt then (u v) *\<^sub>R v else 0::'a)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1280
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1281
  assume ?lhs
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1282
  then obtain t u v where
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1283
    "finite t" "t \<subseteq> s" "setsum u t = 0" "v\<in>t" "u v \<noteq> 0"  "(\<Sum>v\<in>t. u v *\<^sub>R v) = 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1284
    unfolding affine_dependent_explicit by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1285
  then show ?rhs
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1286
    apply (rule_tac x="\<lambda>x. if x\<in>t then u x else 0" in exI)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1287
    apply auto unfolding * and setsum.inter_restrict[OF assms, symmetric]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1288
    unfolding Int_absorb1[OF `t\<subseteq>s`]
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1289
    apply auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1290
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1291
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1292
  assume ?rhs
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1293
  then obtain u v where "setsum u s = 0"  "v\<in>s" "u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1294
    by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1295
  then show ?lhs unfolding affine_dependent_explicit
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1296
    using assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1297
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1298
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1299
44465
fa56622bb7bc move connected_real_lemma to the one place it is used
huffman
parents: 44457
diff changeset
  1300
subsection {* Connectedness of convex sets *}
fa56622bb7bc move connected_real_lemma to the one place it is used
huffman
parents: 44457
diff changeset
  1301
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1302
lemma connectedD:
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1303
  "connected S \<Longrightarrow> open A \<Longrightarrow> open B \<Longrightarrow> S \<subseteq> A \<union> B \<Longrightarrow> A \<inter> B \<inter> S = {} \<Longrightarrow> A \<inter> S = {} \<or> B \<inter> S = {}"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1304
  by (metis connected_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1305
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1306
lemma convex_connected:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1307
  fixes s :: "'a::real_normed_vector set"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1308
  assumes "convex s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1309
  shows "connected s"
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1310
proof (rule connectedI)
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1311
  fix A B
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1312
  assume "open A" "open B" "A \<inter> B \<inter> s = {}" "s \<subseteq> A \<union> B"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1313
  moreover
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1314
  assume "A \<inter> s \<noteq> {}" "B \<inter> s \<noteq> {}"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1315
  then obtain a b where a: "a \<in> A" "a \<in> s" and b: "b \<in> B" "b \<in> s" by auto
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1316
  def f \<equiv> "\<lambda>u. u *\<^sub>R a + (1 - u) *\<^sub>R b"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1317
  then have "continuous_on {0 .. 1} f"
56371
fb9ae0727548 extend continuous_intros; remove continuous_on_intros and isCont_intros
hoelzl
parents: 56369
diff changeset
  1318
    by (auto intro!: continuous_intros)
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1319
  then have "connected (f ` {0 .. 1})"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1320
    by (auto intro!: connected_continuous_image)
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1321
  note connectedD[OF this, of A B]
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1322
  moreover have "a \<in> A \<inter> f ` {0 .. 1}"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1323
    using a by (auto intro!: image_eqI[of _ _ 1] simp: f_def)
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1324
  moreover have "b \<in> B \<inter> f ` {0 .. 1}"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1325
    using b by (auto intro!: image_eqI[of _ _ 0] simp: f_def)
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1326
  moreover have "f ` {0 .. 1} \<subseteq> s"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1327
    using `convex s` a b unfolding convex_def f_def by auto
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  1328
  ultimately show False by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1329
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1330
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1331
text {* One rather trivial consequence. *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1332
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  1333
lemma connected_UNIV[intro]: "connected (UNIV :: 'a::real_normed_vector set)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1334
  by(simp add: convex_connected convex_UNIV)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1335
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1336
text {* Balls, being convex, are connected. *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1337
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  1338
lemma convex_prod:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1339
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> convex {x. P i x}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  1340
  shows "convex {x. \<forall>i\<in>Basis. P i (x\<bullet>i)}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  1341
  using assms unfolding convex_def
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  1342
  by (auto simp: inner_add_left)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  1343
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  1344
lemma convex_positive_orthant: "convex {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i)}"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  1345
  by (rule convex_prod) (simp add: atLeast_def[symmetric] convex_real_interval)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1346
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1347
lemma convex_local_global_minimum:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1348
  fixes s :: "'a::real_normed_vector set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1349
  assumes "e > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1350
    and "convex_on s f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1351
    and "ball x e \<subseteq> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1352
    and "\<forall>y\<in>ball x e. f x \<le> f y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1353
  shows "\<forall>y\<in>s. f x \<le> f y"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1354
proof (rule ccontr)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1355
  have "x \<in> s" using assms(1,3) by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1356
  assume "\<not> ?thesis"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1357
  then obtain y where "y\<in>s" and y: "f x > f y" by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1358
  then have xy: "0 < dist x y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1359
    by (auto simp add: dist_nz[symmetric])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1360
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1361
  then obtain u where "0 < u" "u \<le> 1" and u: "u < e / dist x y"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  1362
    using real_lbound_gt_zero[of 1 "e / dist x y"] xy `e>0` by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1363
  then have "f ((1-u) *\<^sub>R x + u *\<^sub>R y) \<le> (1-u) * f x + u * f y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1364
    using `x\<in>s` `y\<in>s`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1365
    using assms(2)[unfolded convex_on_def,
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1366
      THEN bspec[where x=x], THEN bspec[where x=y], THEN spec[where x="1-u"]]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1367
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1368
  moreover
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1369
  have *: "x - ((1 - u) *\<^sub>R x + u *\<^sub>R y) = u *\<^sub>R (x - y)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1370
    by (simp add: algebra_simps)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1371
  have "(1 - u) *\<^sub>R x + u *\<^sub>R y \<in> ball x e"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1372
    unfolding mem_ball dist_norm
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1373
    unfolding * and norm_scaleR and abs_of_pos[OF `0<u`]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1374
    unfolding dist_norm[symmetric]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1375
    using u
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1376
    unfolding pos_less_divide_eq[OF xy]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1377
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1378
  then have "f x \<le> f ((1 - u) *\<^sub>R x + u *\<^sub>R y)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1379
    using assms(4) by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1380
  ultimately show False
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1381
    using mult_strict_left_mono[OF y `u>0`]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1382
    unfolding left_diff_distrib
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1383
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1384
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1385
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1386
lemma convex_ball:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1387
  fixes x :: "'a::real_normed_vector"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1388
  shows "convex (ball x e)"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1389
proof (auto simp add: convex_def)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1390
  fix y z
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1391
  assume yz: "dist x y < e" "dist x z < e"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1392
  fix u v :: real
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1393
  assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1394
  have "dist x (u *\<^sub>R y + v *\<^sub>R z) \<le> u * dist x y + v * dist x z"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1395
    using uv yz
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1396
    using convex_on_dist [of "ball x e" x, unfolded convex_on_def,
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1397
      THEN bspec[where x=y], THEN bspec[where x=z]]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1398
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1399
  then show "dist x (u *\<^sub>R y + v *\<^sub>R z) < e"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1400
    using convex_bound_lt[OF yz uv] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1401
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1402
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1403
lemma convex_cball:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1404
  fixes x :: "'a::real_normed_vector"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1405
  shows "convex (cball x e)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1406
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1407
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1408
    fix y z
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1409
    assume yz: "dist x y \<le> e" "dist x z \<le> e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1410
    fix u v :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1411
    assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1412
    have "dist x (u *\<^sub>R y + v *\<^sub>R z) \<le> u * dist x y + v * dist x z"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1413
      using uv yz
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1414
      using convex_on_dist [of "cball x e" x, unfolded convex_on_def,
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1415
        THEN bspec[where x=y], THEN bspec[where x=z]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1416
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1417
    then have "dist x (u *\<^sub>R y + v *\<^sub>R z) \<le> e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1418
      using convex_bound_le[OF yz uv] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1419
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1420
  then show ?thesis by (auto simp add: convex_def Ball_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1421
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1422
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1423
lemma connected_ball:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1424
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1425
  shows "connected (ball x e)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1426
  using convex_connected convex_ball by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1427
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1428
lemma connected_cball:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1429
  fixes x :: "'a::real_normed_vector"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1430
  shows "connected (cball x e)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1431
  using convex_connected convex_cball by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1432
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1433
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1434
subsection {* Convex hull *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1435
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1436
lemma convex_convex_hull: "convex (convex hull s)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1437
  unfolding hull_def
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1438
  using convex_Inter[of "{t. convex t \<and> s \<subseteq> t}"]
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  1439
  by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1440
34064
eee04bbbae7e avoid dependency on implicit dest rule predicate1D in proofs
haftmann
parents: 33758
diff changeset
  1441
lemma convex_hull_eq: "convex hull s = s \<longleftrightarrow> convex s"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1442
  by (metis convex_convex_hull hull_same)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1443
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1444
lemma bounded_convex_hull:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1445
  fixes s :: "'a::real_normed_vector set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1446
  assumes "bounded s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1447
  shows "bounded (convex hull s)"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1448
proof -
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1449
  from assms obtain B where B: "\<forall>x\<in>s. norm x \<le> B"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1450
    unfolding bounded_iff by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1451
  show ?thesis
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1452
    apply (rule bounded_subset[OF bounded_cball, of _ 0 B])
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  1453
    unfolding subset_hull[of convex, OF convex_cball]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1454
    unfolding subset_eq mem_cball dist_norm using B
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1455
    apply auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1456
    done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1457
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1458
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1459
lemma finite_imp_bounded_convex_hull:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1460
  fixes s :: "'a::real_normed_vector set"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1461
  shows "finite s \<Longrightarrow> bounded (convex hull s)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1462
  using bounded_convex_hull finite_imp_bounded
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1463
  by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1464
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1465
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1466
subsubsection {* Convex hull is "preserved" by a linear function *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1467
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1468
lemma convex_hull_linear_image:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1469
  assumes f: "linear f"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1470
  shows "f ` (convex hull s) = convex hull (f ` s)"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1471
proof
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1472
  show "convex hull (f ` s) \<subseteq> f ` (convex hull s)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1473
    by (intro hull_minimal image_mono hull_subset convex_linear_image assms convex_convex_hull)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1474
  show "f ` (convex hull s) \<subseteq> convex hull (f ` s)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1475
  proof (unfold image_subset_iff_subset_vimage, rule hull_minimal)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1476
    show "s \<subseteq> f -` (convex hull (f ` s))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1477
      by (fast intro: hull_inc)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1478
    show "convex (f -` (convex hull (f ` s)))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1479
      by (intro convex_linear_vimage [OF f] convex_convex_hull)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1480
  qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1481
qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1482
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1483
lemma in_convex_hull_linear_image:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1484
  assumes "linear f"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1485
    and "x \<in> convex hull s"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1486
  shows "f x \<in> convex hull (f ` s)"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1487
  using convex_hull_linear_image[OF assms(1)] assms(2) by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1488
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1489
lemma convex_hull_Times:
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1490
  "convex hull (s \<times> t) = (convex hull s) \<times> (convex hull t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1491
proof
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1492
  show "convex hull (s \<times> t) \<subseteq> (convex hull s) \<times> (convex hull t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1493
    by (intro hull_minimal Sigma_mono hull_subset convex_Times convex_convex_hull)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1494
  have "\<forall>x\<in>convex hull s. \<forall>y\<in>convex hull t. (x, y) \<in> convex hull (s \<times> t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1495
  proof (intro hull_induct)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1496
    fix x y assume "x \<in> s" and "y \<in> t"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1497
    then show "(x, y) \<in> convex hull (s \<times> t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1498
      by (simp add: hull_inc)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1499
  next
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1500
    fix x let ?S = "((\<lambda>y. (0, y)) -` (\<lambda>p. (- x, 0) + p) ` (convex hull s \<times> t))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1501
    have "convex ?S"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1502
      by (intro convex_linear_vimage convex_translation convex_convex_hull,
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1503
        simp add: linear_iff)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1504
    also have "?S = {y. (x, y) \<in> convex hull (s \<times> t)}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1505
      by (auto simp add: uminus_add_conv_diff image_def Bex_def)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1506
    finally show "convex {y. (x, y) \<in> convex hull (s \<times> t)}" .
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1507
  next
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1508
    show "convex {x. \<forall>y\<in>convex hull t. (x, y) \<in> convex hull (s \<times> t)}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1509
    proof (unfold Collect_ball_eq, rule convex_INT [rule_format])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1510
      fix y let ?S = "((\<lambda>x. (x, 0)) -` (\<lambda>p. (0, - y) + p) ` (convex hull s \<times> t))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1511
      have "convex ?S"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1512
      by (intro convex_linear_vimage convex_translation convex_convex_hull,
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1513
        simp add: linear_iff)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1514
      also have "?S = {x. (x, y) \<in> convex hull (s \<times> t)}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1515
        by (auto simp add: uminus_add_conv_diff image_def Bex_def)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1516
      finally show "convex {x. (x, y) \<in> convex hull (s \<times> t)}" .
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1517
    qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1518
  qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1519
  then show "(convex hull s) \<times> (convex hull t) \<subseteq> convex hull (s \<times> t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1520
    unfolding subset_eq split_paired_Ball_Sigma .
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1521
qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  1522
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1523
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1524
subsubsection {* Stepping theorems for convex hulls of finite sets *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1525
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1526
lemma convex_hull_empty[simp]: "convex hull {} = {}"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1527
  by (rule hull_unique) auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1528
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1529
lemma convex_hull_singleton[simp]: "convex hull {a} = {a}"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1530
  by (rule hull_unique) auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1531
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1532
lemma convex_hull_insert:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1533
  fixes s :: "'a::real_vector set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1534
  assumes "s \<noteq> {}"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1535
  shows "convex hull (insert a s) =
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1536
    {x. \<exists>u\<ge>0. \<exists>v\<ge>0. \<exists>b. (u + v = 1) \<and> b \<in> (convex hull s) \<and> (x = u *\<^sub>R a + v *\<^sub>R b)}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1537
  (is "_ = ?hull")
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1538
  apply (rule, rule hull_minimal, rule)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1539
  unfolding insert_iff
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1540
  prefer 3
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1541
  apply rule
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1542
proof -
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1543
  fix x
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1544
  assume x: "x = a \<or> x \<in> s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1545
  then show "x \<in> ?hull"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1546
    apply rule
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1547
    unfolding mem_Collect_eq
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1548
    apply (rule_tac x=1 in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1549
    defer
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1550
    apply (rule_tac x=0 in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1551
    using assms hull_subset[of s convex]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1552
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1553
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1554
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1555
  fix x
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1556
  assume "x \<in> ?hull"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1557
  then obtain u v b where obt: "u\<ge>0" "v\<ge>0" "u + v = 1" "b \<in> convex hull s" "x = u *\<^sub>R a + v *\<^sub>R b"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1558
    by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1559
  have "a \<in> convex hull insert a s" "b \<in> convex hull insert a s"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1560
    using hull_mono[of s "insert a s" convex] hull_mono[of "{a}" "insert a s" convex] and obt(4)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1561
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1562
  then show "x \<in> convex hull insert a s"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  1563
    unfolding obt(5) using obt(1-3)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  1564
    by (rule convexD [OF convex_convex_hull])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1565
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1566
  show "convex ?hull"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  1567
  proof (rule convexI)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1568
    fix x y u v
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1569
    assume as: "(0::real) \<le> u" "0 \<le> v" "u + v = 1" "x\<in>?hull" "y\<in>?hull"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1570
    from as(4) obtain u1 v1 b1 where
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1571
      obt1: "u1\<ge>0" "v1\<ge>0" "u1 + v1 = 1" "b1 \<in> convex hull s" "x = u1 *\<^sub>R a + v1 *\<^sub>R b1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1572
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1573
    from as(5) obtain u2 v2 b2 where
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1574
      obt2: "u2\<ge>0" "v2\<ge>0" "u2 + v2 = 1" "b2 \<in> convex hull s" "y = u2 *\<^sub>R a + v2 *\<^sub>R b2"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1575
      by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1576
    have *: "\<And>(x::'a) s1 s2. x - s1 *\<^sub>R x - s2 *\<^sub>R x = ((1::real) - (s1 + s2)) *\<^sub>R x"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1577
      by (auto simp add: algebra_simps)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1578
    have **: "\<exists>b \<in> convex hull s. u *\<^sub>R x + v *\<^sub>R y =
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1579
      (u * u1) *\<^sub>R a + (v * u2) *\<^sub>R a + (b - (u * u1) *\<^sub>R b - (v * u2) *\<^sub>R b)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1580
    proof (cases "u * v1 + v * v2 = 0")
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1581
      case True
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1582
      have *: "\<And>(x::'a) s1 s2. x - s1 *\<^sub>R x - s2 *\<^sub>R x = ((1::real) - (s1 + s2)) *\<^sub>R x"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1583
        by (auto simp add: algebra_simps)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1584
      from True have ***: "u * v1 = 0" "v * v2 = 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1585
        using mult_nonneg_nonneg[OF `u\<ge>0` `v1\<ge>0`] mult_nonneg_nonneg[OF `v\<ge>0` `v2\<ge>0`]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1586
        by arith+
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1587
      then have "u * u1 + v * u2 = 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1588
        using as(3) obt1(3) obt2(3) by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1589
      then show ?thesis
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1590
        unfolding obt1(5) obt2(5) *
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1591
        using assms hull_subset[of s convex]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1592
        by (auto simp add: *** scaleR_right_distrib)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1593
    next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1594
      case False
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1595
      have "1 - (u * u1 + v * u2) = (u + v) - (u * u1 + v * u2)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1596
        using as(3) obt1(3) obt2(3) by (auto simp add: field_simps)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1597
      also have "\<dots> = u * (v1 + u1 - u1) + v * (v2 + u2 - u2)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1598
        using as(3) obt1(3) obt2(3) by (auto simp add: field_simps)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1599
      also have "\<dots> = u * v1 + v * v2"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1600
        by simp
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1601
      finally have **:"1 - (u * u1 + v * u2) = u * v1 + v * v2" by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1602
      have "0 \<le> u * v1 + v * v2" "0 \<le> u * v1" "0 \<le> u * v1 + v * v2" "0 \<le> v * v2"
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  1603
        using as(1,2) obt1(1,2) obt2(1,2) by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1604
      then show ?thesis
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1605
        unfolding obt1(5) obt2(5)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1606
        unfolding * and **
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1607
        using False
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1608
        apply (rule_tac
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1609
          x = "((u * v1) / (u * v1 + v * v2)) *\<^sub>R b1 + ((v * v2) / (u * v1 + v * v2)) *\<^sub>R b2" in bexI)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1610
        defer
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  1611
        apply (rule convexD [OF convex_convex_hull])
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1612
        using obt1(4) obt2(4)
49530
wenzelm
parents: 49529
diff changeset
  1613
        unfolding add_divide_distrib[symmetric] and zero_le_divide_iff
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1614
        apply (auto simp add: scaleR_left_distrib scaleR_right_distrib)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1615
        done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1616
    qed
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1617
    have u1: "u1 \<le> 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1618
      unfolding obt1(3)[symmetric] and not_le using obt1(2) by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1619
    have u2: "u2 \<le> 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1620
      unfolding obt2(3)[symmetric] and not_le using obt2(2) by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1621
    have "u1 * u + u2 * v \<le> max u1 u2 * u + max u1 u2 * v"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1622
      apply (rule add_mono)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1623
      apply (rule_tac [!] mult_right_mono)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1624
      using as(1,2) obt1(1,2) obt2(1,2)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1625
      apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1626
      done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1627
    also have "\<dots> \<le> 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1628
      unfolding distrib_left[symmetric] and as(3) using u1 u2 by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1629
    finally show "u *\<^sub>R x + v *\<^sub>R y \<in> ?hull"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1630
      unfolding mem_Collect_eq
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1631
      apply (rule_tac x="u * u1 + v * u2" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1632
      apply (rule conjI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1633
      defer
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1634
      apply (rule_tac x="1 - u * u1 - v * u2" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1635
      unfolding Bex_def
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1636
      using as(1,2) obt1(1,2) obt2(1,2) **
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  1637
      apply (auto simp add: algebra_simps)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1638
      done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1639
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1640
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1641
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1642
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1643
subsubsection {* Explicit expression for convex hull *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1644
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1645
lemma convex_hull_indexed:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1646
  fixes s :: "'a::real_vector set"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1647
  shows "convex hull s =
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1648
    {y. \<exists>k u x.
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1649
      (\<forall>i\<in>{1::nat .. k}. 0 \<le> u i \<and> x i \<in> s) \<and>
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1650
      (setsum u {1..k} = 1) \<and> (setsum (\<lambda>i. u i *\<^sub>R x i) {1..k} = y)}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1651
  (is "?xyz = ?hull")
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1652
  apply (rule hull_unique)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1653
  apply rule
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1654
  defer
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  1655
  apply (rule convexI)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1656
proof -
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1657
  fix x
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1658
  assume "x\<in>s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1659
  then show "x \<in> ?hull"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1660
    unfolding mem_Collect_eq
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1661
    apply (rule_tac x=1 in exI, rule_tac x="\<lambda>x. 1" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1662
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1663
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1664
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1665
  fix t
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1666
  assume as: "s \<subseteq> t" "convex t"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1667
  show "?hull \<subseteq> t"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1668
    apply rule
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1669
    unfolding mem_Collect_eq
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1670
    apply (elim exE conjE)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1671
  proof -
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1672
    fix x k u y
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1673
    assume assm:
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1674
      "\<forall>i\<in>{1::nat..k}. 0 \<le> u i \<and> y i \<in> s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1675
      "setsum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R y i) = x"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1676
    show "x\<in>t"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1677
      unfolding assm(3) [symmetric]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1678
      apply (rule as(2)[unfolded convex, rule_format])
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1679
      using assm(1,2) as(1) apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1680
      done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1681
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1682
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1683
  fix x y u v
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1684
  assume uv: "0 \<le> u" "0 \<le> v" "u + v = (1::real)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1685
  assume xy: "x \<in> ?hull" "y \<in> ?hull"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1686
  from xy obtain k1 u1 x1 where
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1687
    x: "\<forall>i\<in>{1::nat..k1}. 0\<le>u1 i \<and> x1 i \<in> s" "setsum u1 {Suc 0..k1} = 1" "(\<Sum>i = Suc 0..k1. u1 i *\<^sub>R x1 i) = x"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1688
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1689
  from xy obtain k2 u2 x2 where
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1690
    y: "\<forall>i\<in>{1::nat..k2}. 0\<le>u2 i \<and> x2 i \<in> s" "setsum u2 {Suc 0..k2} = 1" "(\<Sum>i = Suc 0..k2. u2 i *\<^sub>R x2 i) = y"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1691
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1692
  have *: "\<And>P (x1::'a) x2 s1 s2 i.
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1693
    (if P i then s1 else s2) *\<^sub>R (if P i then x1 else x2) = (if P i then s1 *\<^sub>R x1 else s2 *\<^sub>R x2)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1694
    "{1..k1 + k2} \<inter> {1..k1} = {1..k1}" "{1..k1 + k2} \<inter> - {1..k1} = (\<lambda>i. i + k1) ` {1..k2}"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1695
    prefer 3
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1696
    apply (rule, rule)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1697
    unfolding image_iff
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1698
    apply (rule_tac x = "x - k1" in bexI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1699
    apply (auto simp add: not_le)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1700
    done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1701
  have inj: "inj_on (\<lambda>i. i + k1) {1..k2}"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1702
    unfolding inj_on_def by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1703
  show "u *\<^sub>R x + v *\<^sub>R y \<in> ?hull"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1704
    apply rule
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1705
    apply (rule_tac x="k1 + k2" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1706
    apply (rule_tac x="\<lambda>i. if i \<in> {1..k1} then u * u1 i else v * u2 (i - k1)" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1707
    apply (rule_tac x="\<lambda>i. if i \<in> {1..k1} then x1 i else x2 (i - k1)" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1708
    apply (rule, rule)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1709
    defer
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1710
    apply rule
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1711
    unfolding * and setsum.If_cases[OF finite_atLeastAtMost[of 1 "k1 + k2"]] and
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1712
      setsum.reindex[OF inj] and o_def Collect_mem_eq
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1713
    unfolding scaleR_scaleR[symmetric] scaleR_right.setsum [symmetric] setsum_right_distrib[symmetric]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1714
  proof -
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1715
    fix i
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1716
    assume i: "i \<in> {1..k1+k2}"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1717
    show "0 \<le> (if i \<in> {1..k1} then u * u1 i else v * u2 (i - k1)) \<and>
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1718
      (if i \<in> {1..k1} then x1 i else x2 (i - k1)) \<in> s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1719
    proof (cases "i\<in>{1..k1}")
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1720
      case True
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1721
      then show ?thesis
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  1722
        using uv(1) x(1)[THEN bspec[where x=i]] by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1723
    next
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1724
      case False
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1725
      def j \<equiv> "i - k1"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1726
      from i False have "j \<in> {1..k2}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1727
        unfolding j_def by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1728
      then show ?thesis
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  1729
        using False uv(2) y(1)[THEN bspec[where x=j]]
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  1730
        by (auto simp: j_def[symmetric])
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1731
    qed
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1732
  qed (auto simp add: not_le x(2,3) y(2,3) uv(3))
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1733
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1734
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1735
lemma convex_hull_finite:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1736
  fixes s :: "'a::real_vector set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1737
  assumes "finite s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1738
  shows "convex hull s = {y. \<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and>
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1739
    setsum u s = 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1740
  (is "?HULL = ?set")
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1741
proof (rule hull_unique, auto simp add: convex_def[of ?set])
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1742
  fix x
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1743
  assume "x \<in> s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1744
  then show "\<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = x"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1745
    apply (rule_tac x="\<lambda>y. if x=y then 1 else 0" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1746
    apply auto
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1747
    unfolding setsum.delta'[OF assms] and setsum_delta''[OF assms]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1748
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1749
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1750
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1751
  fix u v :: real
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1752
  assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1753
  fix ux assume ux: "\<forall>x\<in>s. 0 \<le> ux x" "setsum ux s = (1::real)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1754
  fix uy assume uy: "\<forall>x\<in>s. 0 \<le> uy x" "setsum uy s = (1::real)"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1755
  {
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1756
    fix x
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1757
    assume "x\<in>s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1758
    then have "0 \<le> u * ux x + v * uy x"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1759
      using ux(1)[THEN bspec[where x=x]] uy(1)[THEN bspec[where x=x]] and uv(1,2)
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  1760
      by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1761
  }
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1762
  moreover
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1763
  have "(\<Sum>x\<in>s. u * ux x + v * uy x) = 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1764
    unfolding setsum.distrib and setsum_right_distrib[symmetric] and ux(2) uy(2)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1765
    using uv(3) by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1766
  moreover
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1767
  have "(\<Sum>x\<in>s. (u * ux x + v * uy x) *\<^sub>R x) = u *\<^sub>R (\<Sum>x\<in>s. ux x *\<^sub>R x) + v *\<^sub>R (\<Sum>x\<in>s. uy x *\<^sub>R x)"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1768
    unfolding scaleR_left_distrib and setsum.distrib and scaleR_scaleR[symmetric]
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1769
      and scaleR_right.setsum [symmetric]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1770
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1771
  ultimately
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1772
  show "\<exists>uc. (\<forall>x\<in>s. 0 \<le> uc x) \<and> setsum uc s = 1 \<and>
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1773
      (\<Sum>x\<in>s. uc x *\<^sub>R x) = u *\<^sub>R (\<Sum>x\<in>s. ux x *\<^sub>R x) + v *\<^sub>R (\<Sum>x\<in>s. uy x *\<^sub>R x)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1774
    apply (rule_tac x="\<lambda>x. u * ux x + v * uy x" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1775
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1776
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1777
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1778
  fix t
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1779
  assume t: "s \<subseteq> t" "convex t"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1780
  fix u
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1781
  assume u: "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = (1::real)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1782
  then show "(\<Sum>x\<in>s. u x *\<^sub>R x) \<in> t"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1783
    using t(2)[unfolded convex_explicit, THEN spec[where x=s], THEN spec[where x=u]]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1784
    using assms and t(1) by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1785
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1786
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1787
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1788
subsubsection {* Another formulation from Lars Schewe *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1789
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1790
lemma setsum_constant_scaleR:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1791
  fixes y :: "'a::real_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1792
  shows "(\<Sum>x\<in>A. y) = of_nat (card A) *\<^sub>R y"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1793
  apply (cases "finite A")
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1794
  apply (induct set: finite)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1795
  apply (simp_all add: algebra_simps)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1796
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1797
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1798
lemma convex_hull_explicit:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1799
  fixes p :: "'a::real_vector set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1800
  shows "convex hull p =
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1801
    {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = y}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1802
  (is "?lhs = ?rhs")
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1803
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1804
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1805
    fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1806
    assume "x\<in>?lhs"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1807
    then obtain k u y where
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1808
        obt: "\<forall>i\<in>{1::nat..k}. 0 \<le> u i \<and> y i \<in> p" "setsum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R y i) = x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1809
      unfolding convex_hull_indexed by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1810
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1811
    have fin: "finite {1..k}" by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1812
    have fin': "\<And>v. finite {i \<in> {1..k}. y i = v}" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1813
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1814
      fix j
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1815
      assume "j\<in>{1..k}"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1816
      then have "y j \<in> p" "0 \<le> setsum u {i. Suc 0 \<le> i \<and> i \<le> k \<and> y i = y j}"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1817
        using obt(1)[THEN bspec[where x=j]] and obt(2)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1818
        apply simp
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1819
        apply (rule setsum_nonneg)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1820
        using obt(1)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1821
        apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1822
        done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1823
    }
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1824
    moreover
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1825
    have "(\<Sum>v\<in>y ` {1..k}. setsum u {i \<in> {1..k}. y i = v}) = 1"
49530
wenzelm
parents: 49529
diff changeset
  1826
      unfolding setsum_image_gen[OF fin, symmetric] using obt(2) by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1827
    moreover have "(\<Sum>v\<in>y ` {1..k}. setsum u {i \<in> {1..k}. y i = v} *\<^sub>R v) = x"
49530
wenzelm
parents: 49529
diff changeset
  1828
      using setsum_image_gen[OF fin, of "\<lambda>i. u i *\<^sub>R y i" y, symmetric]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1829
      unfolding scaleR_left.setsum using obt(3) by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1830
    ultimately
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1831
    have "\<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = x"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1832
      apply (rule_tac x="y ` {1..k}" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1833
      apply (rule_tac x="\<lambda>v. setsum u {i\<in>{1..k}. y i = v}" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1834
      apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1835
      done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1836
    then have "x\<in>?rhs" by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1837
  }
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1838
  moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1839
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1840
    fix y
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1841
    assume "y\<in>?rhs"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1842
    then obtain s u where
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1843
      obt: "finite s" "s \<subseteq> p" "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = y"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1844
      by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1845
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1846
    obtain f where f: "inj_on f {1..card s}" "f ` {1..card s} = s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1847
      using ex_bij_betw_nat_finite_1[OF obt(1)] unfolding bij_betw_def by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1848
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1849
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1850
      fix i :: nat
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1851
      assume "i\<in>{1..card s}"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1852
      then have "f i \<in> s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1853
        apply (subst f(2)[symmetric])
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1854
        apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1855
        done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1856
      then have "0 \<le> u (f i)" "f i \<in> p" using obt(2,3) by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1857
    }
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1858
    moreover have *: "finite {1..card s}" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1859
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1860
      fix y
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1861
      assume "y\<in>s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1862
      then obtain i where "i\<in>{1..card s}" "f i = y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1863
        using f using image_iff[of y f "{1..card s}"]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1864
        by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1865
      then have "{x. Suc 0 \<le> x \<and> x \<le> card s \<and> f x = y} = {i}"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1866
        apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1867
        using f(1)[unfolded inj_on_def]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1868
        apply(erule_tac x=x in ballE)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1869
        apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1870
        done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1871
      then have "card {x. Suc 0 \<le> x \<and> x \<le> card s \<and> f x = y} = 1" by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1872
      then have "(\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x)) = u y"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1873
          "(\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x) *\<^sub>R f x) = u y *\<^sub>R y"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1874
        by (auto simp add: setsum_constant_scaleR)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1875
    }
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1876
    then have "(\<Sum>x = 1..card s. u (f x)) = 1" "(\<Sum>i = 1..card s. u (f i) *\<^sub>R f i) = y"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1877
      unfolding setsum_image_gen[OF *(1), of "\<lambda>x. u (f x) *\<^sub>R f x" f]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1878
        and setsum_image_gen[OF *(1), of "\<lambda>x. u (f x)" f]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1879
      unfolding f
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1880
      using setsum.cong [of s s "\<lambda>y. (\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x) *\<^sub>R f x)" "\<lambda>v. u v *\<^sub>R v"]
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1881
      using setsum.cong [of s s "\<lambda>y. (\<Sum>x\<in>{x \<in> {1..card s}. f x = y}. u (f x))" u]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1882
      unfolding obt(4,5)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1883
      by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1884
    ultimately
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1885
    have "\<exists>k u x. (\<forall>i\<in>{1..k}. 0 \<le> u i \<and> x i \<in> p) \<and> setsum u {1..k} = 1 \<and>
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1886
        (\<Sum>i::nat = 1..k. u i *\<^sub>R x i) = y"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1887
      apply (rule_tac x="card s" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1888
      apply (rule_tac x="u \<circ> f" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1889
      apply (rule_tac x=f in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1890
      apply fastforce
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1891
      done
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1892
    then have "y \<in> ?lhs"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1893
      unfolding convex_hull_indexed by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1894
  }
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1895
  ultimately show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1896
    unfolding set_eq_iff by blast
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1897
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1898
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1899
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1900
subsubsection {* A stepping theorem for that expansion *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1901
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1902
lemma convex_hull_finite_step:
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1903
  fixes s :: "'a::real_vector set"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1904
  assumes "finite s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1905
  shows
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1906
    "(\<exists>u. (\<forall>x\<in>insert a s. 0 \<le> u x) \<and> setsum u (insert a s) = w \<and> setsum (\<lambda>x. u x *\<^sub>R x) (insert a s) = y)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1907
      \<longleftrightarrow> (\<exists>v\<ge>0. \<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = w - v \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y - v *\<^sub>R a)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1908
  (is "?lhs = ?rhs")
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1909
proof (rule, case_tac[!] "a\<in>s")
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1910
  assume "a \<in> s"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1911
  then have *: "insert a s = s" by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1912
  assume ?lhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1913
  then show ?rhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1914
    unfolding *
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1915
    apply (rule_tac x=0 in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1916
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1917
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1918
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1919
  assume ?lhs
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1920
  then obtain u where
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1921
      u: "\<forall>x\<in>insert a s. 0 \<le> u x" "setsum u (insert a s) = w" "(\<Sum>x\<in>insert a s. u x *\<^sub>R x) = y"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1922
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1923
  assume "a \<notin> s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1924
  then show ?rhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1925
    apply (rule_tac x="u a" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1926
    using u(1)[THEN bspec[where x=a]]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1927
    apply simp
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1928
    apply (rule_tac x=u in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1929
    using u[unfolded setsum_clauses(2)[OF assms]] and `a\<notin>s`
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1930
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1931
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1932
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1933
  assume "a \<in> s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1934
  then have *: "insert a s = s" by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1935
  have fin: "finite (insert a s)" using assms by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1936
  assume ?rhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1937
  then obtain v u where uv: "v\<ge>0" "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = w - v" "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1938
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1939
  show ?lhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1940
    apply (rule_tac x = "\<lambda>x. (if a = x then v else 0) + u x" in exI)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1941
    unfolding scaleR_left_distrib and setsum.distrib and setsum_delta''[OF fin] and setsum.delta'[OF fin]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1942
    unfolding setsum_clauses(2)[OF assms]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1943
    using uv and uv(2)[THEN bspec[where x=a]] and `a\<in>s`
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1944
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1945
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1946
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1947
  assume ?rhs
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1948
  then obtain v u where
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1949
    uv: "v\<ge>0" "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = w - v" "(\<Sum>x\<in>s. u x *\<^sub>R x) = y - v *\<^sub>R a"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1950
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1951
  moreover
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1952
  assume "a \<notin> s"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1953
  moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1954
  have "(\<Sum>x\<in>s. if a = x then v else u x) = setsum u s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1955
    and "(\<Sum>x\<in>s. (if a = x then v else u x) *\<^sub>R x) = (\<Sum>x\<in>s. u x *\<^sub>R x)"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1956
    apply (rule_tac setsum.cong) apply rule
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1957
    defer
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1958
    apply (rule_tac setsum.cong) apply rule
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1959
    using `a \<notin> s`
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1960
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1961
    done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1962
  ultimately show ?lhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1963
    apply (rule_tac x="\<lambda>x. if a = x then v else u x" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1964
    unfolding setsum_clauses(2)[OF assms]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1965
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1966
    done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1967
qed
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  1968
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1969
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  1970
subsubsection {* Hence some special cases *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1971
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1972
lemma convex_hull_2:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1973
  "convex hull {a,b} = {u *\<^sub>R a + v *\<^sub>R b | u v. 0 \<le> u \<and> 0 \<le> v \<and> u + v = 1}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1974
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1975
  have *: "\<And>u. (\<forall>x\<in>{a, b}. 0 \<le> u x) \<longleftrightarrow> 0 \<le> u a \<and> 0 \<le> u b"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1976
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1977
  have **: "finite {b}" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1978
  show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1979
    apply (simp add: convex_hull_finite)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1980
    unfolding convex_hull_finite_step[OF **, of a 1, unfolded * conj_assoc]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1981
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1982
    apply (rule_tac x=v in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1983
    apply (rule_tac x="1 - v" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1984
    apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1985
    apply (rule_tac x=u in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1986
    apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1987
    apply (rule_tac x="\<lambda>x. v" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1988
    apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1989
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1990
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1991
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1992
lemma convex_hull_2_alt: "convex hull {a,b} = {a + u *\<^sub>R (b - a) | u.  0 \<le> u \<and> u \<le> 1}"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  1993
  unfolding convex_hull_2
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1994
proof (rule Collect_cong)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1995
  have *: "\<And>x y ::real. x + y = 1 \<longleftrightarrow> x = 1 - y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1996
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1997
  fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1998
  show "(\<exists>v u. x = v *\<^sub>R a + u *\<^sub>R b \<and> 0 \<le> v \<and> 0 \<le> u \<and> v + u = 1) \<longleftrightarrow>
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1999
    (\<exists>u. x = a + u *\<^sub>R (b - a) \<and> 0 \<le> u \<and> u \<le> 1)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2000
    unfolding *
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2001
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2002
    apply (rule_tac[!] x=u in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2003
    apply (auto simp add: algebra_simps)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2004
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2005
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2006
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2007
lemma convex_hull_3:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2008
  "convex hull {a,b,c} = { u *\<^sub>R a + v *\<^sub>R b + w *\<^sub>R c | u v w. 0 \<le> u \<and> 0 \<le> v \<and> 0 \<le> w \<and> u + v + w = 1}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2009
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2010
  have fin: "finite {a,b,c}" "finite {b,c}" "finite {c}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2011
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2012
  have *: "\<And>x y z ::real. x + y + z = 1 \<longleftrightarrow> x = 1 - y - z"
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  2013
    by (auto simp add: field_simps)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2014
  show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2015
    unfolding convex_hull_finite[OF fin(1)] and convex_hull_finite_step[OF fin(2)] and *
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2016
    unfolding convex_hull_finite_step[OF fin(3)]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2017
    apply (rule Collect_cong)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2018
    apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2019
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2020
    apply (rule_tac x=va in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2021
    apply (rule_tac x="u c" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2022
    apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2023
    apply (rule_tac x="1 - v - w" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2024
    apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2025
    apply (rule_tac x=v in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2026
    apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2027
    apply (rule_tac x="\<lambda>x. w" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2028
    apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2029
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2030
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2031
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2032
lemma convex_hull_3_alt:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2033
  "convex hull {a,b,c} = {a + u *\<^sub>R (b - a) + v *\<^sub>R (c - a) | u v.  0 \<le> u \<and> 0 \<le> v \<and> u + v \<le> 1}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2034
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2035
  have *: "\<And>x y z ::real. x + y + z = 1 \<longleftrightarrow> x = 1 - y - z"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2036
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2037
  show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2038
    unfolding convex_hull_3
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2039
    apply (auto simp add: *)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2040
    apply (rule_tac x=v in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2041
    apply (rule_tac x=w in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2042
    apply (simp add: algebra_simps)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2043
    apply (rule_tac x=u in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2044
    apply (rule_tac x=v in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2045
    apply (simp add: algebra_simps)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2046
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2047
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2048
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2049
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  2050
subsection {* Relations among closure notions and corresponding hulls *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2051
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2052
lemma affine_imp_convex: "affine s \<Longrightarrow> convex s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2053
  unfolding affine_def convex_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2054
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  2055
lemma subspace_imp_convex: "subspace s \<Longrightarrow> convex s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2056
  using subspace_imp_affine affine_imp_convex by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2057
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  2058
lemma affine_hull_subset_span: "(affine hull s) \<subseteq> (span s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2059
  by (metis hull_minimal span_inc subspace_imp_affine subspace_span)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2060
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  2061
lemma convex_hull_subset_span: "(convex hull s) \<subseteq> (span s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2062
  by (metis hull_minimal span_inc subspace_imp_convex subspace_span)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2063
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2064
lemma convex_hull_subset_affine_hull: "(convex hull s) \<subseteq> (affine hull s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2065
  by (metis affine_affine_hull affine_imp_convex hull_minimal hull_subset)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2066
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2067
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2068
lemma affine_dependent_imp_dependent: "affine_dependent s \<Longrightarrow> dependent s"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2069
  unfolding affine_dependent_def dependent_def
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2070
  using affine_hull_subset_span by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2071
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2072
lemma dependent_imp_affine_dependent:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2073
  assumes "dependent {x - a| x . x \<in> s}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2074
    and "a \<notin> s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2075
  shows "affine_dependent (insert a s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2076
proof -
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2077
  from assms(1)[unfolded dependent_explicit] obtain S u v
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2078
    where obt: "finite S" "S \<subseteq> {x - a |x. x \<in> s}" "v\<in>S" "u v  \<noteq> 0" "(\<Sum>v\<in>S. u v *\<^sub>R v) = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2079
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2080
  def t \<equiv> "(\<lambda>x. x + a) ` S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2081
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2082
  have inj: "inj_on (\<lambda>x. x + a) S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2083
    unfolding inj_on_def by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2084
  have "0 \<notin> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2085
    using obt(2) assms(2) unfolding subset_eq by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2086
  have fin: "finite t" and "t \<subseteq> s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2087
    unfolding t_def using obt(1,2) by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2088
  then have "finite (insert a t)" and "insert a t \<subseteq> insert a s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2089
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2090
  moreover have *: "\<And>P Q. (\<Sum>x\<in>t. (if x = a then P x else Q x)) = (\<Sum>x\<in>t. Q x)"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  2091
    apply (rule setsum.cong)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2092
    using `a\<notin>s` `t\<subseteq>s`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2093
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2094
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2095
  have "(\<Sum>x\<in>insert a t. if x = a then - (\<Sum>x\<in>t. u (x - a)) else u (x - a)) = 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2096
    unfolding setsum_clauses(2)[OF fin]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2097
    using `a\<notin>s` `t\<subseteq>s`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2098
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2099
    unfolding *
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2100
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2101
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2102
  moreover have "\<exists>v\<in>insert a t. (if v = a then - (\<Sum>x\<in>t. u (x - a)) else u (v - a)) \<noteq> 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2103
    apply (rule_tac x="v + a" in bexI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2104
    using obt(3,4) and `0\<notin>S`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2105
    unfolding t_def
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2106
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2107
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2108
  moreover have *: "\<And>P Q. (\<Sum>x\<in>t. (if x = a then P x else Q x) *\<^sub>R x) = (\<Sum>x\<in>t. Q x *\<^sub>R x)"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  2109
    apply (rule setsum.cong)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2110
    using `a\<notin>s` `t\<subseteq>s`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2111
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2112
    done
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2113
  have "(\<Sum>x\<in>t. u (x - a)) *\<^sub>R a = (\<Sum>v\<in>t. u (v - a) *\<^sub>R v)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2114
    unfolding scaleR_left.setsum
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  2115
    unfolding t_def and setsum.reindex[OF inj] and o_def
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2116
    using obt(5)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  2117
    by (auto simp add: setsum.distrib scaleR_right_distrib)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2118
  then have "(\<Sum>v\<in>insert a t. (if v = a then - (\<Sum>x\<in>t. u (x - a)) else u (v - a)) *\<^sub>R v) = 0"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2119
    unfolding setsum_clauses(2)[OF fin]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2120
    using `a\<notin>s` `t\<subseteq>s`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2121
    by (auto simp add: *)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2122
  ultimately show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2123
    unfolding affine_dependent_explicit
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2124
    apply (rule_tac x="insert a t" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2125
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2126
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2127
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2128
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2129
lemma convex_cone:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2130
  "convex s \<and> cone s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. (x + y) \<in> s) \<and> (\<forall>x\<in>s. \<forall>c\<ge>0. (c *\<^sub>R x) \<in> s)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2131
  (is "?lhs = ?rhs")
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2132
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2133
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2134
    fix x y
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2135
    assume "x\<in>s" "y\<in>s" and ?lhs
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2136
    then have "2 *\<^sub>R x \<in>s" "2 *\<^sub>R y \<in> s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2137
      unfolding cone_def by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2138
    then have "x + y \<in> s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2139
      using `?lhs`[unfolded convex_def, THEN conjunct1]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2140
      apply (erule_tac x="2*\<^sub>R x" in ballE)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2141
      apply (erule_tac x="2*\<^sub>R y" in ballE)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2142
      apply (erule_tac x="1/2" in allE)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2143
      apply simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2144
      apply (erule_tac x="1/2" in allE)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2145
      apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2146
      done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2147
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2148
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2149
    unfolding convex_def cone_def by blast
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2150
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2151
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2152
lemma affine_dependent_biggerset:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2153
  fixes s :: "'a::euclidean_space set"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  2154
  assumes "finite s" "card s \<ge> DIM('a) + 2"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2155
  shows "affine_dependent s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2156
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2157
  have "s \<noteq> {}" using assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2158
  then obtain a where "a\<in>s" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2159
  have *: "{x - a |x. x \<in> s - {a}} = (\<lambda>x. x - a) ` (s - {a})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2160
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2161
  have "card {x - a |x. x \<in> s - {a}} = card (s - {a})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2162
    unfolding *
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2163
    apply (rule card_image)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2164
    unfolding inj_on_def
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2165
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2166
    done
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  2167
  also have "\<dots> > DIM('a)" using assms(2)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2168
    unfolding card_Diff_singleton[OF assms(1) `a\<in>s`] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2169
  finally show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2170
    apply (subst insert_Diff[OF `a\<in>s`, symmetric])
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2171
    apply (rule dependent_imp_affine_dependent)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2172
    apply (rule dependent_biggerset)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2173
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2174
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2175
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2176
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2177
lemma affine_dependent_biggerset_general:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2178
  assumes "finite (s :: 'a::euclidean_space set)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2179
    and "card s \<ge> dim s + 2"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2180
  shows "affine_dependent s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2181
proof -
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2182
  from assms(2) have "s \<noteq> {}" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2183
  then obtain a where "a\<in>s" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2184
  have *: "{x - a |x. x \<in> s - {a}} = (\<lambda>x. x - a) ` (s - {a})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2185
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2186
  have **: "card {x - a |x. x \<in> s - {a}} = card (s - {a})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2187
    unfolding *
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2188
    apply (rule card_image)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2189
    unfolding inj_on_def
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2190
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2191
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2192
  have "dim {x - a |x. x \<in> s - {a}} \<le> dim s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2193
    apply (rule subset_le_dim)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2194
    unfolding subset_eq
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2195
    using `a\<in>s`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2196
    apply (auto simp add:span_superset span_sub)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2197
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2198
  also have "\<dots> < dim s + 1" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2199
  also have "\<dots> \<le> card (s - {a})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2200
    using assms
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2201
    using card_Diff_singleton[OF assms(1) `a\<in>s`]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2202
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2203
  finally show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2204
    apply (subst insert_Diff[OF `a\<in>s`, symmetric])
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2205
    apply (rule dependent_imp_affine_dependent)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2206
    apply (rule dependent_biggerset_general)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2207
    unfolding **
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2208
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2209
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2210
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2211
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2212
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2213
subsection {* Caratheodory's theorem. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2214
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2215
lemma convex_hull_caratheodory:
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2216
  fixes p :: "('a::euclidean_space) set"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2217
  shows "convex hull p =
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2218
    {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and>
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2219
      (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> setsum (\<lambda>v. u v *\<^sub>R v) s = y}"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
  2220
  unfolding convex_hull_explicit set_eq_iff mem_Collect_eq
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2221
proof (rule, rule)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2222
  fix y
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2223
  let ?P = "\<lambda>n. \<exists>s u. finite s \<and> card s = n \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and>
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2224
    setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2225
  assume "\<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2226
  then obtain N where "?P N" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2227
  then have "\<exists>n\<le>N. (\<forall>k<n. \<not> ?P k) \<and> ?P n"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2228
    apply (rule_tac ex_least_nat_le)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2229
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2230
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2231
  then obtain n where "?P n" and smallest: "\<forall>k<n. \<not> ?P k"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2232
    by blast
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2233
  then obtain s u where obt: "finite s" "card s = n" "s\<subseteq>p" "\<forall>x\<in>s. 0 \<le> u x"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2234
    "setsum u s = 1"  "(\<Sum>v\<in>s. u v *\<^sub>R v) = y" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2235
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2236
  have "card s \<le> DIM('a) + 1"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2237
  proof (rule ccontr, simp only: not_le)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  2238
    assume "DIM('a) + 1 < card s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2239
    then have "affine_dependent s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2240
      using affine_dependent_biggerset[OF obt(1)] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2241
    then obtain w v where wv: "setsum w s = 0" "v\<in>s" "w v \<noteq> 0" "(\<Sum>v\<in>s. w v *\<^sub>R v) = 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2242
      using affine_dependent_explicit_finite[OF obt(1)] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2243
    def i \<equiv> "(\<lambda>v. (u v) / (- w v)) ` {v\<in>s. w v < 0}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2244
    def t \<equiv> "Min i"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2245
    have "\<exists>x\<in>s. w x < 0"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2246
    proof (rule ccontr, simp add: not_less)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2247
      assume as:"\<forall>x\<in>s. 0 \<le> w x"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2248
      then have "setsum w (s - {v}) \<ge> 0"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2249
        apply (rule_tac setsum_nonneg)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2250
        apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2251
        done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2252
      then have "setsum w s > 0"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  2253
        unfolding setsum.remove[OF obt(1) `v\<in>s`]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2254
        using as[THEN bspec[where x=v]] and `v\<in>s`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2255
        using `w v \<noteq> 0`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2256
        by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2257
      then show False using wv(1) by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2258
    qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2259
    then have "i \<noteq> {}" unfolding i_def by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2260
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2261
    then have "t \<ge> 0"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2262
      using Min_ge_iff[of i 0 ] and obt(1)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2263
      unfolding t_def i_def
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2264
      using obt(4)[unfolded le_less]
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  2265
      by (auto simp: divide_le_0_iff)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2266
    have t: "\<forall>v\<in>s. u v + t * w v \<ge> 0"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2267
    proof
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2268
      fix v
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2269
      assume "v \<in> s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2270
      then have v: "0 \<le> u v"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2271
        using obt(4)[THEN bspec[where x=v]] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2272
      show "0 \<le> u v + t * w v"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2273
      proof (cases "w v < 0")
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2274
        case False
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  2275
        thus ?thesis using v `t\<ge>0` by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2276
      next
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2277
        case True
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2278
        then have "t \<le> u v / (- w v)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2279
          using `v\<in>s`
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2280
          unfolding t_def i_def
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2281
          apply (rule_tac Min_le)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2282
          using obt(1)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2283
          apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2284
          done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2285
        then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2286
          unfolding real_0_le_add_iff
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2287
          using pos_le_divide_eq[OF True[unfolded neg_0_less_iff_less[symmetric]]]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2288
          by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2289
      qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2290
    qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2291
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2292
    obtain a where "a \<in> s" and "t = (\<lambda>v. (u v) / (- w v)) a" and "w a < 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2293
      using Min_in[OF _ `i\<noteq>{}`] and obt(1) unfolding i_def t_def by auto
56479
91958d4b30f7 revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
hoelzl
parents: 56409
diff changeset
  2294
    then have a: "a \<in> s" "u a + t * w a = 0" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2295
    have *: "\<And>f. setsum f (s - {a}) = setsum f s - ((f a)::'b::ab_group_add)"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  2296
      unfolding setsum.remove[OF obt(1) `a\<in>s`] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2297
    have "(\<Sum>v\<in>s. u v + t * w v) = 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  2298
      unfolding setsum.distrib wv(1) setsum_right_distrib[symmetric] obt(5) by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2299
    moreover have "(\<Sum>v\<in>s. u v *\<^sub>R v + (t * w v) *\<^sub>R v) - (u a *\<^sub>R a + (t * w a) *\<^sub>R a) = y"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  2300
      unfolding setsum.distrib obt(6) scaleR_scaleR[symmetric] scaleR_right.setsum [symmetric] wv(4)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  2301
      using a(2) [THEN eq_neg_iff_add_eq_0 [THEN iffD2]] by simp
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2302
    ultimately have "?P (n - 1)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2303
      apply (rule_tac x="(s - {a})" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2304
      apply (rule_tac x="\<lambda>v. u v + t * w v" in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2305
      using obt(1-3) and t and a
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2306
      apply (auto simp add: * scaleR_left_distrib)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2307
      done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2308
    then show False
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2309
      using smallest[THEN spec[where x="n - 1"]] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2310
  qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2311
  then show "\<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and>
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2312
      (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2313
    using obt by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2314
qed auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2315
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2316
lemma caratheodory:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2317
  "convex hull p =
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2318
    {x::'a::euclidean_space. \<exists>s. finite s \<and> s \<subseteq> p \<and>
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  2319
      card s \<le> DIM('a) + 1 \<and> x \<in> convex hull s}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2320
  unfolding set_eq_iff
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2321
  apply rule
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2322
  apply rule
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2323
  unfolding mem_Collect_eq
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2324
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2325
  fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2326
  assume "x \<in> convex hull p"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  2327
  then obtain s u where "finite s" "s \<subseteq> p" "card s \<le> DIM('a) + 1"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2328
    "\<forall>x\<in>s. 0 \<le> u x" "setsum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2329
    unfolding convex_hull_caratheodory by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2330
  then show "\<exists>s. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and> x \<in> convex hull s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2331
    apply (rule_tac x=s in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2332
    using hull_subset[of s convex]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2333
    using convex_convex_hull[unfolded convex_explicit, of s,
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2334
      THEN spec[where x=s], THEN spec[where x=u]]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2335
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2336
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2337
next
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2338
  fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2339
  assume "\<exists>s. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and> x \<in> convex hull s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2340
  then obtain s where "finite s" "s \<subseteq> p" "card s \<le> DIM('a) + 1" "x \<in> convex hull s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2341
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2342
  then show "x \<in> convex hull p"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2343
    using hull_mono[OF `s\<subseteq>p`] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2344
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2345
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2346
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2347
subsection {* Some Properties of Affine Dependent Sets *}
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2348
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2349
lemma affine_independent_empty: "\<not> affine_dependent {}"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2350
  by (simp add: affine_dependent_def)
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2351
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2352
lemma affine_independent_sing: "\<not> affine_dependent {a}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2353
  by (simp add: affine_dependent_def)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2354
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2355
lemma affine_hull_translation: "affine hull ((\<lambda>x. a + x) `  S) = (\<lambda>x. a + x) ` (affine hull S)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2356
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2357
  have "affine ((\<lambda>x. a + x) ` (affine hull S))"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2358
    using affine_translation affine_affine_hull by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2359
  moreover have "(\<lambda>x. a + x) `  S \<subseteq> (\<lambda>x. a + x) ` (affine hull S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2360
    using hull_subset[of S] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2361
  ultimately have h1: "affine hull ((\<lambda>x. a + x) `  S) \<subseteq> (\<lambda>x. a + x) ` (affine hull S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2362
    by (metis hull_minimal)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2363
  have "affine((\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S)))"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  2364
    using affine_translation affine_affine_hull by (auto simp del: uminus_add_conv_diff)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2365
  moreover have "(\<lambda>x. -a + x) ` (\<lambda>x. a + x) `  S \<subseteq> (\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2366
    using hull_subset[of "(\<lambda>x. a + x) `  S"] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2367
  moreover have "S = (\<lambda>x. -a + x) ` (\<lambda>x. a + x) `  S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2368
    using translation_assoc[of "-a" a] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2369
  ultimately have "(\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S)) >= (affine hull S)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2370
    by (metis hull_minimal)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2371
  then have "affine hull ((\<lambda>x. a + x) ` S) >= (\<lambda>x. a + x) ` (affine hull S)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2372
    by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2373
  then show ?thesis using h1 by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2374
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2375
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2376
lemma affine_dependent_translation:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2377
  assumes "affine_dependent S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2378
  shows "affine_dependent ((\<lambda>x. a + x) ` S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2379
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2380
  obtain x where x: "x \<in> S \<and> x \<in> affine hull (S - {x})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2381
    using assms affine_dependent_def by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2382
  have "op + a ` (S - {x}) = op + a ` S - {a + x}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2383
    by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2384
  then have "a + x \<in> affine hull ((\<lambda>x. a + x) ` S - {a + x})"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2385
    using affine_hull_translation[of a "S - {x}"] x by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2386
  moreover have "a + x \<in> (\<lambda>x. a + x) ` S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2387
    using x by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2388
  ultimately show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2389
    unfolding affine_dependent_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2390
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2391
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2392
lemma affine_dependent_translation_eq:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2393
  "affine_dependent S \<longleftrightarrow> affine_dependent ((\<lambda>x. a + x) ` S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2394
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2395
  {
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2396
    assume "affine_dependent ((\<lambda>x. a + x) ` S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2397
    then have "affine_dependent S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2398
      using affine_dependent_translation[of "((\<lambda>x. a + x) ` S)" "-a"] translation_assoc[of "-a" a]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2399
      by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2400
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2401
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2402
    using affine_dependent_translation by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2403
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2404
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2405
lemma affine_hull_0_dependent:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2406
  assumes "0 \<in> affine hull S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2407
  shows "dependent S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2408
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2409
  obtain s u where s_u: "finite s \<and> s \<noteq> {} \<and> s \<subseteq> S \<and> setsum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2410
    using assms affine_hull_explicit[of S] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2411
  then have "\<exists>v\<in>s. u v \<noteq> 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2412
    using setsum_not_0[of "u" "s"] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2413
  then have "finite s \<and> s \<subseteq> S \<and> (\<exists>v\<in>s. u v \<noteq> 0 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2414
    using s_u by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2415
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2416
    unfolding dependent_explicit[of S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2417
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2418
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2419
lemma affine_dependent_imp_dependent2:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2420
  assumes "affine_dependent (insert 0 S)"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2421
  shows "dependent S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2422
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2423
  obtain x where x: "x \<in> insert 0 S \<and> x \<in> affine hull (insert 0 S - {x})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2424
    using affine_dependent_def[of "(insert 0 S)"] assms by blast
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2425
  then have "x \<in> span (insert 0 S - {x})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2426
    using affine_hull_subset_span by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2427
  moreover have "span (insert 0 S - {x}) = span (S - {x})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2428
    using insert_Diff_if[of "0" S "{x}"] span_insert_0[of "S-{x}"] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2429
  ultimately have "x \<in> span (S - {x})" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2430
  then have "x \<noteq> 0 \<Longrightarrow> dependent S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2431
    using x dependent_def by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2432
  moreover
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2433
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2434
    assume "x = 0"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2435
    then have "0 \<in> affine hull S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2436
      using x hull_mono[of "S - {0}" S] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2437
    then have "dependent S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2438
      using affine_hull_0_dependent by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2439
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2440
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2441
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2442
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2443
lemma affine_dependent_iff_dependent:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2444
  assumes "a \<notin> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2445
  shows "affine_dependent (insert a S) \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` S)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2446
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2447
  have "(op + (- a) ` S) = {x - a| x . x : S}" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2448
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2449
    using affine_dependent_translation_eq[of "(insert a S)" "-a"]
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2450
      affine_dependent_imp_dependent2 assms
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2451
      dependent_imp_affine_dependent[of a S]
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  2452
    by (auto simp del: uminus_add_conv_diff)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2453
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2454
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2455
lemma affine_dependent_iff_dependent2:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2456
  assumes "a \<in> S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2457
  shows "affine_dependent S \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` (S-{a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2458
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2459
  have "insert a (S - {a}) = S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2460
    using assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2461
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2462
    using assms affine_dependent_iff_dependent[of a "S-{a}"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2463
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2464
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2465
lemma affine_hull_insert_span_gen:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2466
  "affine hull (insert a s) = (\<lambda>x. a + x) ` span ((\<lambda>x. - a + x) ` s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2467
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2468
  have h1: "{x - a |x. x \<in> s} = ((\<lambda>x. -a+x) ` s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2469
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2470
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2471
    assume "a \<notin> s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2472
    then have ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2473
      using affine_hull_insert_span[of a s] h1 by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2474
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2475
  moreover
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2476
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2477
    assume a1: "a \<in> s"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2478
    have "\<exists>x. x \<in> s \<and> -a+x=0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2479
      apply (rule exI[of _ a])
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2480
      using a1
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2481
      apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2482
      done
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2483
    then have "insert 0 ((\<lambda>x. -a+x) ` (s - {a})) = (\<lambda>x. -a+x) ` s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2484
      by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2485
    then have "span ((\<lambda>x. -a+x) ` (s - {a}))=span ((\<lambda>x. -a+x) ` s)"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  2486
      using span_insert_0[of "op + (- a) ` (s - {a})"] by (auto simp del: uminus_add_conv_diff)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2487
    moreover have "{x - a |x. x \<in> (s - {a})} = ((\<lambda>x. -a+x) ` (s - {a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2488
      by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2489
    moreover have "insert a (s - {a}) = insert a s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2490
      using assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2491
    ultimately have ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2492
      using assms affine_hull_insert_span[of "a" "s-{a}"] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2493
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2494
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2495
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2496
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2497
lemma affine_hull_span2:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2498
  assumes "a \<in> s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2499
  shows "affine hull s = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` (s-{a}))"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2500
  using affine_hull_insert_span_gen[of a "s - {a}", unfolded insert_Diff[OF assms]]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2501
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2502
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2503
lemma affine_hull_span_gen:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2504
  assumes "a \<in> affine hull s"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2505
  shows "affine hull s = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2506
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2507
  have "affine hull (insert a s) = affine hull s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2508
    using hull_redundant[of a affine s] assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2509
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2510
    using affine_hull_insert_span_gen[of a "s"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2511
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2512
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2513
lemma affine_hull_span_0:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2514
  assumes "0 \<in> affine hull S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2515
  shows "affine hull S = span S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2516
  using affine_hull_span_gen[of "0" S] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2517
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2518
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2519
lemma extend_to_affine_basis:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2520
  fixes S V :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2521
  assumes "\<not> affine_dependent S" "S \<subseteq> V" "S \<noteq> {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2522
  shows "\<exists>T. \<not> affine_dependent T \<and> S \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2523
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2524
  obtain a where a: "a \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2525
    using assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2526
  then have h0: "independent  ((\<lambda>x. -a + x) ` (S-{a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2527
    using affine_dependent_iff_dependent2 assms by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2528
  then obtain B where B:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2529
    "(\<lambda>x. -a+x) ` (S - {a}) \<subseteq> B \<and> B \<subseteq> (\<lambda>x. -a+x) ` V \<and> independent B \<and> (\<lambda>x. -a+x) ` V \<subseteq> span B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2530
     using maximal_independent_subset_extend[of "(\<lambda>x. -a+x) ` (S-{a})" "(\<lambda>x. -a + x) ` V"] assms
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2531
     by blast
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2532
  def T \<equiv> "(\<lambda>x. a+x) ` insert 0 B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2533
  then have "T = insert a ((\<lambda>x. a+x) ` B)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2534
    by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2535
  then have "affine hull T = (\<lambda>x. a+x) ` span B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2536
    using affine_hull_insert_span_gen[of a "((\<lambda>x. a+x) ` B)"] translation_assoc[of "-a" a B]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2537
    by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2538
  then have "V \<subseteq> affine hull T"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2539
    using B assms translation_inverse_subset[of a V "span B"]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2540
    by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2541
  moreover have "T \<subseteq> V"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2542
    using T_def B a assms by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2543
  ultimately have "affine hull T = affine hull V"
44457
d366fa5551ef declare euclidean_simps [simp] at the point they are proved;
huffman
parents: 44365
diff changeset
  2544
    by (metis Int_absorb1 Int_absorb2 hull_hull hull_mono)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2545
  moreover have "S \<subseteq> T"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2546
    using T_def B translation_inverse_subset[of a "S-{a}" B]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2547
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2548
  moreover have "\<not> affine_dependent T"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2549
    using T_def affine_dependent_translation_eq[of "insert 0 B"]
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2550
      affine_dependent_imp_dependent2 B
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2551
    by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2552
  ultimately show ?thesis using `T \<subseteq> V` by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2553
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2554
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2555
lemma affine_basis_exists:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2556
  fixes V :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2557
  shows "\<exists>B. B \<subseteq> V \<and> \<not> affine_dependent B \<and> affine hull V = affine hull B"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2558
proof (cases "V = {}")
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2559
  case True
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2560
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2561
    using affine_independent_empty by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2562
next
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2563
  case False
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2564
  then obtain x where "x \<in> V" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2565
  then show ?thesis
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2566
    using affine_dependent_def[of "{x}"] extend_to_affine_basis[of "{x}" V]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2567
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2568
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2569
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2570
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2571
subsection {* Affine Dimension of a Set *}
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2572
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2573
definition "aff_dim V =
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2574
  (SOME d :: int.
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2575
    \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = d + 1)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2576
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2577
lemma aff_dim_basis_exists:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2578
  fixes V :: "('n::euclidean_space) set"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2579
  shows "\<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2580
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2581
  obtain B where "\<not> affine_dependent B \<and> affine hull B = affine hull V"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2582
    using affine_basis_exists[of V] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2583
  then show ?thesis
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2584
    unfolding aff_dim_def
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2585
      some_eq_ex[of "\<lambda>d. \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = d + 1"]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2586
    apply auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2587
    apply (rule exI[of _ "int (card B) - (1 :: int)"])
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2588
    apply (rule exI[of _ "B"])
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2589
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2590
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2591
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2592
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2593
lemma affine_hull_nonempty: "S \<noteq> {} \<longleftrightarrow> affine hull S \<noteq> {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2594
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2595
  have "S = {} \<Longrightarrow> affine hull S = {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2596
    using affine_hull_empty by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2597
  moreover have "affine hull S = {} \<Longrightarrow> S = {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2598
    unfolding hull_def by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2599
  ultimately show ?thesis by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2600
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2601
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2602
lemma aff_dim_parallel_subspace_aux:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2603
  fixes B :: "'n::euclidean_space set"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2604
  assumes "\<not> affine_dependent B" "a \<in> B"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2605
  shows "finite B \<and> ((card B) - 1 = dim (span ((\<lambda>x. -a+x) ` (B-{a}))))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2606
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2607
  have "independent ((\<lambda>x. -a + x) ` (B-{a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2608
    using affine_dependent_iff_dependent2 assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2609
  then have fin: "dim (span ((\<lambda>x. -a+x) ` (B-{a}))) = card ((\<lambda>x. -a + x) ` (B-{a}))"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2610
    "finite ((\<lambda>x. -a + x) ` (B - {a}))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2611
    using indep_card_eq_dim_span[of "(\<lambda>x. -a+x) ` (B-{a})"] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2612
  show ?thesis
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2613
  proof (cases "(\<lambda>x. -a + x) ` (B - {a}) = {}")
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2614
    case True
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2615
    have "B = insert a ((\<lambda>x. a + x) ` (\<lambda>x. -a + x) ` (B - {a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2616
      using translation_assoc[of "a" "-a" "(B - {a})"] assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2617
    then have "B = {a}" using True by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2618
    then show ?thesis using assms fin by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2619
  next
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2620
    case False
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2621
    then have "card ((\<lambda>x. -a + x) ` (B - {a})) > 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2622
      using fin by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2623
    moreover have h1: "card ((\<lambda>x. -a + x) ` (B-{a})) = card (B-{a})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2624
       apply (rule card_image)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2625
       using translate_inj_on
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  2626
       apply (auto simp del: uminus_add_conv_diff)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2627
       done
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2628
    ultimately have "card (B-{a}) > 0" by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2629
    then have *: "finite (B - {a})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2630
      using card_gt_0_iff[of "(B - {a})"] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2631
    then have "card (B - {a}) = card B - 1"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2632
      using card_Diff_singleton assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2633
    with * show ?thesis using fin h1 by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2634
  qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2635
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2636
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2637
lemma aff_dim_parallel_subspace:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2638
  fixes V L :: "'n::euclidean_space set"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2639
  assumes "V \<noteq> {}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2640
    and "subspace L"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2641
    and "affine_parallel (affine hull V) L"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2642
  shows "aff_dim V = int (dim L)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2643
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2644
  obtain B where
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2645
    B: "affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = aff_dim V + 1"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2646
    using aff_dim_basis_exists by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2647
  then have "B \<noteq> {}"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2648
    using assms B affine_hull_nonempty[of V] affine_hull_nonempty[of B]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2649
    by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2650
  then obtain a where a: "a \<in> B" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2651
  def Lb \<equiv> "span ((\<lambda>x. -a+x) ` (B-{a}))"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2652
  moreover have "affine_parallel (affine hull B) Lb"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2653
    using Lb_def B assms affine_hull_span2[of a B] a
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2654
      affine_parallel_commut[of "Lb" "(affine hull B)"]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2655
    unfolding affine_parallel_def
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2656
    by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2657
  moreover have "subspace Lb"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2658
    using Lb_def subspace_span by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2659
  moreover have "affine hull B \<noteq> {}"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2660
    using assms B affine_hull_nonempty[of V] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2661
  ultimately have "L = Lb"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2662
    using assms affine_parallel_subspace[of "affine hull B"] affine_affine_hull[of B] B
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2663
    by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2664
  then have "dim L = dim Lb"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2665
    by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2666
  moreover have "card B - 1 = dim Lb" and "finite B"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2667
    using Lb_def aff_dim_parallel_subspace_aux a B by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2668
  ultimately show ?thesis
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2669
    using B `B \<noteq> {}` card_gt_0_iff[of B] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2670
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2671
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2672
lemma aff_independent_finite:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2673
  fixes B :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2674
  assumes "\<not> affine_dependent B"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2675
  shows "finite B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2676
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2677
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2678
    assume "B \<noteq> {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2679
    then obtain a where "a \<in> B" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2680
    then have ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2681
      using aff_dim_parallel_subspace_aux assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2682
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2683
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2684
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2685
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2686
lemma independent_finite:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2687
  fixes B :: "'n::euclidean_space set"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2688
  assumes "independent B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2689
  shows "finite B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2690
  using affine_dependent_imp_dependent[of B] aff_independent_finite[of B] assms
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2691
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2692
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2693
lemma subspace_dim_equal:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2694
  assumes "subspace (S :: ('n::euclidean_space) set)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2695
    and "subspace T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2696
    and "S \<subseteq> T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2697
    and "dim S \<ge> dim T"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2698
  shows "S = T"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2699
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2700
  obtain B where B: "B \<le> S" "independent B \<and> S \<subseteq> span B" "card B = dim S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2701
    using basis_exists[of S] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2702
  then have "span B \<subseteq> S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2703
    using span_mono[of B S] span_eq[of S] assms by metis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2704
  then have "span B = S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2705
    using B by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2706
  have "dim S = dim T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2707
    using assms dim_subset[of S T] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2708
  then have "T \<subseteq> span B"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2709
    using card_eq_dim[of B T] B independent_finite assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2710
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2711
    using assms `span B = S` by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2712
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2713
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2714
lemma span_substd_basis:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2715
  assumes d: "d \<subseteq> Basis"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2716
  shows "span d = {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2717
  (is "_ = ?B")
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2718
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2719
  have "d \<subseteq> ?B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2720
    using d by (auto simp: inner_Basis)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2721
  moreover have s: "subspace ?B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2722
    using subspace_substandard[of "\<lambda>i. i \<notin> d"] .
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2723
  ultimately have "span d \<subseteq> ?B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2724
    using span_mono[of d "?B"] span_eq[of "?B"] by blast
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53348
diff changeset
  2725
  moreover have *: "card d \<le> dim (span d)"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2726
    using independent_card_le_dim[of d "span d"] independent_substdbasis[OF assms] span_inc[of d]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2727
    by auto
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53348
diff changeset
  2728
  moreover from * have "dim ?B \<le> dim (span d)"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2729
    using dim_substandard[OF assms] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2730
  ultimately show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2731
    using s subspace_dim_equal[of "span d" "?B"] subspace_span[of d] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2732
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2733
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2734
lemma basis_to_substdbasis_subspace_isomorphism:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2735
  fixes B :: "'a::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2736
  assumes "independent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2737
  shows "\<exists>f d::'a set. card d = card B \<and> linear f \<and> f ` B = d \<and>
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2738
    f ` span B = {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0} \<and> inj_on f (span B) \<and> d \<subseteq> Basis"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2739
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2740
  have B: "card B = dim B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2741
    using dim_unique[of B B "card B"] assms span_inc[of B] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2742
  have "dim B \<le> card (Basis :: 'a set)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2743
    using dim_subset_UNIV[of B] by simp
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2744
  from ex_card[OF this] obtain d :: "'a set" where d: "d \<subseteq> Basis" and t: "card d = dim B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2745
    by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2746
  let ?t = "{x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2747
  have "\<exists>f. linear f \<and> f ` B = d \<and> f ` span B = ?t \<and> inj_on f (span B)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2748
    apply (rule basis_to_basis_subspace_isomorphism[of "span B" ?t B "d"])
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2749
    apply (rule subspace_span)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2750
    apply (rule subspace_substandard)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2751
    defer
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2752
    apply (rule span_inc)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2753
    apply (rule assms)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2754
    defer
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2755
    unfolding dim_span[of B]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2756
    apply(rule B)
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2757
    unfolding span_substd_basis[OF d, symmetric]
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2758
    apply (rule span_inc)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2759
    apply (rule independent_substdbasis[OF d])
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2760
    apply rule
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2761
    apply assumption
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2762
    unfolding t[symmetric] span_substd_basis[OF d] dim_substandard[OF d]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2763
    apply auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2764
    done
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2765
  with t `card B = dim B` d show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2766
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2767
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2768
lemma aff_dim_empty:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2769
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2770
  shows "S = {} \<longleftrightarrow> aff_dim S = -1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2771
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2772
  obtain B where *: "affine hull B = affine hull S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2773
    and "\<not> affine_dependent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2774
    and "int (card B) = aff_dim S + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2775
    using aff_dim_basis_exists by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2776
  moreover
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2777
  from * have "S = {} \<longleftrightarrow> B = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2778
    using affine_hull_nonempty[of B] affine_hull_nonempty[of S] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2779
  ultimately show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2780
    using aff_independent_finite[of B] card_gt_0_iff[of B] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2781
qed
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2782
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2783
lemma aff_dim_affine_hull: "aff_dim (affine hull S) = aff_dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2784
  unfolding aff_dim_def using hull_hull[of _ S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2785
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2786
lemma aff_dim_affine_hull2:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2787
  assumes "affine hull S = affine hull T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2788
  shows "aff_dim S = aff_dim T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2789
  unfolding aff_dim_def using assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2790
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2791
lemma aff_dim_unique:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2792
  fixes B V :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2793
  assumes "affine hull B = affine hull V \<and> \<not> affine_dependent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2794
  shows "of_nat (card B) = aff_dim V + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2795
proof (cases "B = {}")
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2796
  case True
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2797
  then have "V = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2798
    using affine_hull_nonempty[of V] affine_hull_nonempty[of B] assms
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2799
    by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2800
  then have "aff_dim V = (-1::int)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2801
    using aff_dim_empty by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2802
  then show ?thesis
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2803
    using `B = {}` by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2804
next
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2805
  case False
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2806
  then obtain a where a: "a \<in> B" by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2807
  def Lb \<equiv> "span ((\<lambda>x. -a+x) ` (B-{a}))"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2808
  have "affine_parallel (affine hull B) Lb"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2809
    using Lb_def affine_hull_span2[of a B] a
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2810
      affine_parallel_commut[of "Lb" "(affine hull B)"]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2811
    unfolding affine_parallel_def by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2812
  moreover have "subspace Lb"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2813
    using Lb_def subspace_span by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2814
  ultimately have "aff_dim B = int(dim Lb)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2815
    using aff_dim_parallel_subspace[of B Lb] `B \<noteq> {}` by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2816
  moreover have "(card B) - 1 = dim Lb" "finite B"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2817
    using Lb_def aff_dim_parallel_subspace_aux a assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2818
  ultimately have "of_nat (card B) = aff_dim B + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2819
    using `B \<noteq> {}` card_gt_0_iff[of B] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2820
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2821
    using aff_dim_affine_hull2 assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2822
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2823
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2824
lemma aff_dim_affine_independent:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2825
  fixes B :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2826
  assumes "\<not> affine_dependent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2827
  shows "of_nat (card B) = aff_dim B + 1"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2828
  using aff_dim_unique[of B B] assms by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2829
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2830
lemma aff_dim_sing:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2831
  fixes a :: "'n::euclidean_space"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2832
  shows "aff_dim {a} = 0"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2833
  using aff_dim_affine_independent[of "{a}"] affine_independent_sing by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2834
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2835
lemma aff_dim_inner_basis_exists:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2836
  fixes V :: "('n::euclidean_space) set"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2837
  shows "\<exists>B. B \<subseteq> V \<and> affine hull B = affine hull V \<and>
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2838
    \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2839
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2840
  obtain B where B: "\<not> affine_dependent B" "B \<subseteq> V" "affine hull B = affine hull V"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2841
    using affine_basis_exists[of V] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2842
  then have "of_nat(card B) = aff_dim V+1" using aff_dim_unique by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2843
  with B show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2844
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2845
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2846
lemma aff_dim_le_card:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2847
  fixes V :: "'n::euclidean_space set"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2848
  assumes "finite V"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2849
  shows "aff_dim V \<le> of_nat (card V) - 1"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2850
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2851
  obtain B where B: "B \<subseteq> V" "of_nat (card B) = aff_dim V + 1"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2852
    using aff_dim_inner_basis_exists[of V] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2853
  then have "card B \<le> card V"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2854
    using assms card_mono by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2855
  with B show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2856
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2857
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2858
lemma aff_dim_parallel_eq:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2859
  fixes S T :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2860
  assumes "affine_parallel (affine hull S) (affine hull T)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2861
  shows "aff_dim S = aff_dim T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2862
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2863
  {
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2864
    assume "T \<noteq> {}" "S \<noteq> {}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2865
    then obtain L where L: "subspace L \<and> affine_parallel (affine hull T) L"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2866
      using affine_parallel_subspace[of "affine hull T"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2867
        affine_affine_hull[of T] affine_hull_nonempty
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2868
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2869
    then have "aff_dim T = int (dim L)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2870
      using aff_dim_parallel_subspace `T \<noteq> {}` by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2871
    moreover have *: "subspace L \<and> affine_parallel (affine hull S) L"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2872
       using L affine_parallel_assoc[of "affine hull S" "affine hull T" L] assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2873
    moreover from * have "aff_dim S = int (dim L)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2874
      using aff_dim_parallel_subspace `S \<noteq> {}` by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2875
    ultimately have ?thesis by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2876
  }
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2877
  moreover
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2878
  {
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2879
    assume "S = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2880
    then have "S = {}" and "T = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2881
      using assms affine_hull_nonempty
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2882
      unfolding affine_parallel_def
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2883
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2884
    then have ?thesis using aff_dim_empty by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2885
  }
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2886
  moreover
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2887
  {
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2888
    assume "T = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2889
    then have "S = {}" and "T = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2890
      using assms affine_hull_nonempty
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2891
      unfolding affine_parallel_def
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2892
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2893
    then have ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2894
      using aff_dim_empty by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2895
  }
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2896
  ultimately show ?thesis by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2897
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2898
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2899
lemma aff_dim_translation_eq:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2900
  fixes a :: "'n::euclidean_space"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2901
  shows "aff_dim ((\<lambda>x. a + x) ` S) = aff_dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2902
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2903
  have "affine_parallel (affine hull S) (affine hull ((\<lambda>x. a + x) ` S))"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2904
    unfolding affine_parallel_def
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2905
    apply (rule exI[of _ "a"])
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2906
    using affine_hull_translation[of a S]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2907
    apply auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2908
    done
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2909
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2910
    using aff_dim_parallel_eq[of S "(\<lambda>x. a + x) ` S"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2911
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2912
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2913
lemma aff_dim_affine:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2914
  fixes S L :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2915
  assumes "S \<noteq> {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2916
    and "affine S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2917
    and "subspace L"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2918
    and "affine_parallel S L"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2919
  shows "aff_dim S = int (dim L)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2920
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2921
  have *: "affine hull S = S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2922
    using assms affine_hull_eq[of S] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2923
  then have "affine_parallel (affine hull S) L"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2924
    using assms by (simp add: *)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2925
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2926
    using assms aff_dim_parallel_subspace[of S L] by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2927
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2928
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2929
lemma dim_affine_hull:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2930
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2931
  shows "dim (affine hull S) = dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2932
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2933
  have "dim (affine hull S) \<ge> dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2934
    using dim_subset by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2935
  moreover have "dim (span S) \<ge> dim (affine hull S)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2936
    using dim_subset affine_hull_subset_span by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2937
  moreover have "dim (span S) = dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2938
    using dim_span by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2939
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2940
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2941
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2942
lemma aff_dim_subspace:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2943
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2944
  assumes "S \<noteq> {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2945
    and "subspace S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2946
  shows "aff_dim S = int (dim S)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2947
  using aff_dim_affine[of S S] assms subspace_imp_affine[of S] affine_parallel_reflex[of S]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2948
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2949
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2950
lemma aff_dim_zero:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2951
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2952
  assumes "0 \<in> affine hull S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2953
  shows "aff_dim S = int (dim S)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2954
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2955
  have "subspace (affine hull S)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2956
    using subspace_affine[of "affine hull S"] affine_affine_hull assms
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2957
    by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2958
  then have "aff_dim (affine hull S) = int (dim (affine hull S))"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2959
    using assms aff_dim_subspace[of "affine hull S"] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2960
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2961
    using aff_dim_affine_hull[of S] dim_affine_hull[of S]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2962
    by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2963
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2964
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2965
lemma aff_dim_univ: "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2966
  using aff_dim_subspace[of "(UNIV :: 'n::euclidean_space set)"]
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2967
    dim_UNIV[where 'a="'n::euclidean_space"]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2968
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2969
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2970
lemma aff_dim_geq:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2971
  fixes V :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2972
  shows "aff_dim V \<ge> -1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2973
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2974
  obtain B where "affine hull B = affine hull V"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2975
    and "\<not> affine_dependent B"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2976
    and "int (card B) = aff_dim V + 1"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2977
    using aff_dim_basis_exists by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2978
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2979
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2980
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2981
lemma independent_card_le_aff_dim:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2982
  fixes B :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2983
  assumes "B \<subseteq> V"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2984
  assumes "\<not> affine_dependent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2985
  shows "int (card B) \<le> aff_dim V + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2986
proof (cases "B = {}")
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2987
  case True
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2988
  then have "-1 \<le> aff_dim V"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2989
    using aff_dim_geq by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2990
  with True show ?thesis by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2991
next
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2992
  case False
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2993
  then obtain T where T: "\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2994
    using assms extend_to_affine_basis[of B V] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2995
  then have "of_nat (card T) = aff_dim V + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2996
    using aff_dim_unique by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2997
  then show ?thesis
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2998
    using T card_mono[of T B] aff_independent_finite[of T] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2999
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3000
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3001
lemma aff_dim_subset:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3002
  fixes S T :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3003
  assumes "S \<subseteq> T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3004
  shows "aff_dim S \<le> aff_dim T"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3005
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3006
  obtain B where B: "\<not> affine_dependent B" "B \<subseteq> S" "affine hull B = affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3007
    "of_nat (card B) = aff_dim S + 1"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3008
    using aff_dim_inner_basis_exists[of S] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3009
  then have "int (card B) \<le> aff_dim T + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3010
    using assms independent_card_le_aff_dim[of B T] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3011
  with B show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3012
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3013
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3014
lemma aff_dim_subset_univ:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3015
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3016
  shows "aff_dim S \<le> int (DIM('n))"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3017
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3018
  have "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3019
    using aff_dim_univ by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3020
  then show "aff_dim (S:: 'n::euclidean_space set) \<le> int(DIM('n))"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3021
    using assms aff_dim_subset[of S "(UNIV :: ('n::euclidean_space) set)"] subset_UNIV by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3022
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3023
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3024
lemma affine_dim_equal:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3025
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3026
  assumes "affine S" "affine T" "S \<noteq> {}" "S \<subseteq> T" "aff_dim S = aff_dim T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3027
  shows "S = T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3028
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3029
  obtain a where "a \<in> S" using assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3030
  then have "a \<in> T" using assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3031
  def LS \<equiv> "{y. \<exists>x \<in> S. (-a) + x = y}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3032
  then have ls: "subspace LS" "affine_parallel S LS"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3033
    using assms parallel_subspace_explicit[of S a LS] `a \<in> S` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3034
  then have h1: "int(dim LS) = aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3035
    using assms aff_dim_affine[of S LS] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3036
  have "T \<noteq> {}" using assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3037
  def LT \<equiv> "{y. \<exists>x \<in> T. (-a) + x = y}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3038
  then have lt: "subspace LT \<and> affine_parallel T LT"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3039
    using assms parallel_subspace_explicit[of T a LT] `a \<in> T` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3040
  then have "int(dim LT) = aff_dim T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3041
    using assms aff_dim_affine[of T LT] `T \<noteq> {}` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3042
  then have "dim LS = dim LT"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3043
    using h1 assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3044
  moreover have "LS \<le> LT"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3045
    using LS_def LT_def assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3046
  ultimately have "LS = LT"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3047
    using subspace_dim_equal[of LS LT] ls lt by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3048
  moreover have "S = {x. \<exists>y \<in> LS. a+y=x}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3049
    using LS_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3050
  moreover have "T = {x. \<exists>y \<in> LT. a+y=x}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3051
    using LT_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3052
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3053
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3054
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3055
lemma affine_hull_univ:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3056
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3057
  assumes "aff_dim S = int(DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3058
  shows "affine hull S = (UNIV :: ('n::euclidean_space) set)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3059
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3060
  have "S \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3061
    using assms aff_dim_empty[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3062
  have h0: "S \<subseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3063
    using hull_subset[of S _] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3064
  have h1: "aff_dim (UNIV :: ('n::euclidean_space) set) = aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3065
    using aff_dim_univ assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3066
  then have h2: "aff_dim (affine hull S) \<le> aff_dim (UNIV :: ('n::euclidean_space) set)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3067
    using aff_dim_subset_univ[of "affine hull S"] assms h0 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3068
  have h3: "aff_dim S \<le> aff_dim (affine hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3069
    using h0 aff_dim_subset[of S "affine hull S"] assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3070
  then have h4: "aff_dim (affine hull S) = aff_dim (UNIV :: ('n::euclidean_space) set)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3071
    using h0 h1 h2 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3072
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3073
    using affine_dim_equal[of "affine hull S" "(UNIV :: ('n::euclidean_space) set)"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3074
      affine_affine_hull[of S] affine_UNIV assms h4 h0 `S \<noteq> {}`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3075
    by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3076
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3077
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3078
lemma aff_dim_convex_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3079
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3080
  shows "aff_dim (convex hull S) = aff_dim S"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3081
  using aff_dim_affine_hull[of S] convex_hull_subset_affine_hull[of S]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3082
    hull_subset[of S "convex"] aff_dim_subset[of S "convex hull S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3083
    aff_dim_subset[of "convex hull S" "affine hull S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3084
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3085
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3086
lemma aff_dim_cball:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3087
  fixes a :: "'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3088
  assumes "e > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3089
  shows "aff_dim (cball a e) = int (DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3090
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3091
  have "(\<lambda>x. a + x) ` (cball 0 e) \<subseteq> cball a e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3092
    unfolding cball_def dist_norm by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3093
  then have "aff_dim (cball (0 :: 'n::euclidean_space) e) \<le> aff_dim (cball a e)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3094
    using aff_dim_translation_eq[of a "cball 0 e"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3095
          aff_dim_subset[of "op + a ` cball 0 e" "cball a e"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3096
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3097
  moreover have "aff_dim (cball (0 :: 'n::euclidean_space) e) = int (DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3098
    using hull_inc[of "(0 :: 'n::euclidean_space)" "cball 0 e"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3099
      centre_in_cball[of "(0 :: 'n::euclidean_space)"] assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3100
    by (simp add: dim_cball[of e] aff_dim_zero[of "cball 0 e"])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3101
  ultimately show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3102
    using aff_dim_subset_univ[of "cball a e"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3103
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3104
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3105
lemma aff_dim_open:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3106
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3107
  assumes "open S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3108
    and "S \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3109
  shows "aff_dim S = int (DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3110
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3111
  obtain x where "x \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3112
    using assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3113
  then obtain e where e: "e > 0" "cball x e \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3114
    using open_contains_cball[of S] assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3115
  then have "aff_dim (cball x e) \<le> aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3116
    using aff_dim_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3117
  with e show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3118
    using aff_dim_cball[of e x] aff_dim_subset_univ[of S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3119
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3120
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3121
lemma low_dim_interior:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3122
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3123
  assumes "\<not> aff_dim S = int (DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3124
  shows "interior S = {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3125
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3126
  have "aff_dim(interior S) \<le> aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3127
    using interior_subset aff_dim_subset[of "interior S" S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3128
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3129
    using aff_dim_open[of "interior S"] aff_dim_subset_univ[of S] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3130
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3131
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  3132
subsection {* Relative interior of a set *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3133
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3134
definition "rel_interior S =
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3135
  {x. \<exists>T. openin (subtopology euclidean (affine hull S)) T \<and> x \<in> T \<and> T \<subseteq> S}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3136
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3137
lemma rel_interior:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3138
  "rel_interior S = {x \<in> S. \<exists>T. open T \<and> x \<in> T \<and> T \<inter> affine hull S \<subseteq> S}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3139
  unfolding rel_interior_def[of S] openin_open[of "affine hull S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3140
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3141
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3142
  fix x T
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3143
  assume *: "x \<in> S" "open T" "x \<in> T" "T \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3144
  then have **: "x \<in> T \<inter> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3145
    using hull_inc by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3146
  show "\<exists>Tb. (\<exists>Ta. open Ta \<and> Tb = affine hull S \<inter> Ta) \<and> x \<in> Tb \<and> Tb \<subseteq> S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3147
    apply (rule_tac x = "T \<inter> (affine hull S)" in exI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3148
    using * **
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3149
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3150
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3151
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3152
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3153
lemma mem_rel_interior: "x \<in> rel_interior S \<longleftrightarrow> (\<exists>T. open T \<and> x \<in> T \<inter> S \<and> T \<inter> affine hull S \<subseteq> S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3154
  by (auto simp add: rel_interior)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3155
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3156
lemma mem_rel_interior_ball:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3157
  "x \<in> rel_interior S \<longleftrightarrow> x \<in> S \<and> (\<exists>e. e > 0 \<and> ball x e \<inter> affine hull S \<subseteq> S)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3158
  apply (simp add: rel_interior, safe)
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3159
  apply (force simp add: open_contains_ball)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3160
  apply (rule_tac x = "ball x e" in exI)
44457
d366fa5551ef declare euclidean_simps [simp] at the point they are proved;
huffman
parents: 44365
diff changeset
  3161
  apply simp
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3162
  done
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3163
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3164
lemma rel_interior_ball:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3165
  "rel_interior S = {x \<in> S. \<exists>e. e > 0 \<and> ball x e \<inter> affine hull S \<subseteq> S}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3166
  using mem_rel_interior_ball [of _ S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3167
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3168
lemma mem_rel_interior_cball:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3169
  "x \<in> rel_interior S \<longleftrightarrow> x \<in> S \<and> (\<exists>e. e > 0 \<and> cball x e \<inter> affine hull S \<subseteq> S)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3170
  apply (simp add: rel_interior, safe)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3171
  apply (force simp add: open_contains_cball)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3172
  apply (rule_tac x = "ball x e" in exI)
44457
d366fa5551ef declare euclidean_simps [simp] at the point they are proved;
huffman
parents: 44365
diff changeset
  3173
  apply (simp add: subset_trans [OF ball_subset_cball])
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3174
  apply auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3175
  done
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3176
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3177
lemma rel_interior_cball:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3178
  "rel_interior S = {x \<in> S. \<exists>e. e > 0 \<and> cball x e \<inter> affine hull S \<subseteq> S}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3179
  using mem_rel_interior_cball [of _ S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3180
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3181
lemma rel_interior_empty: "rel_interior {} = {}"
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3182
   by (auto simp add: rel_interior_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3183
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3184
lemma affine_hull_sing: "affine hull {a :: 'n::euclidean_space} = {a}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3185
  by (metis affine_hull_eq affine_sing)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3186
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3187
lemma rel_interior_sing: "rel_interior {a :: 'n::euclidean_space} = {a}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3188
  unfolding rel_interior_ball affine_hull_sing
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3189
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3190
  apply (rule_tac x = "1 :: real" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3191
  apply simp
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3192
  done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3193
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3194
lemma subset_rel_interior:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3195
  fixes S T :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3196
  assumes "S \<subseteq> T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3197
    and "affine hull S = affine hull T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3198
  shows "rel_interior S \<subseteq> rel_interior T"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3199
  using assms by (auto simp add: rel_interior_def)
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3200
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3201
lemma rel_interior_subset: "rel_interior S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3202
  by (auto simp add: rel_interior_def)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3203
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3204
lemma rel_interior_subset_closure: "rel_interior S \<subseteq> closure S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3205
  using rel_interior_subset by (auto simp add: closure_def)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3206
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3207
lemma interior_subset_rel_interior: "interior S \<subseteq> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3208
  by (auto simp add: rel_interior interior_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3209
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3210
lemma interior_rel_interior:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3211
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3212
  assumes "aff_dim S = int(DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3213
  shows "rel_interior S = interior S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3214
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3215
  have "affine hull S = UNIV"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3216
    using assms affine_hull_univ[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3217
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3218
    unfolding rel_interior interior_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3219
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3220
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3221
lemma rel_interior_open:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3222
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3223
  assumes "open S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3224
  shows "rel_interior S = S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3225
  by (metis assms interior_eq interior_subset_rel_interior rel_interior_subset set_eq_subset)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3226
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3227
lemma interior_rel_interior_gen:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3228
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3229
  shows "interior S = (if aff_dim S = int(DIM('n)) then rel_interior S else {})"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3230
  by (metis interior_rel_interior low_dim_interior)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3231
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3232
lemma rel_interior_univ:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3233
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3234
  shows "rel_interior (affine hull S) = affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3235
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3236
  have *: "rel_interior (affine hull S) \<subseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3237
    using rel_interior_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3238
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3239
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3240
    assume x: "x \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3241
    def e \<equiv> "1::real"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3242
    then have "e > 0" "ball x e \<inter> affine hull (affine hull S) \<subseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3243
      using hull_hull[of _ S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3244
    then have "x \<in> rel_interior (affine hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3245
      using x rel_interior_ball[of "affine hull S"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3246
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3247
  then show ?thesis using * by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3248
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3249
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3250
lemma rel_interior_univ2: "rel_interior (UNIV :: ('n::euclidean_space) set) = UNIV"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3251
  by (metis open_UNIV rel_interior_open)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3252
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3253
lemma rel_interior_convex_shrink:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3254
  fixes S :: "'a::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3255
  assumes "convex S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3256
    and "c \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3257
    and "x \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3258
    and "0 < e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3259
    and "e \<le> 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3260
  shows "x - e *\<^sub>R (x - c) \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3261
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3262
  obtain d where "d > 0" and d: "ball c d \<inter> affine hull S \<subseteq> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3263
    using assms(2) unfolding  mem_rel_interior_ball by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3264
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3265
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3266
    assume as: "dist (x - e *\<^sub>R (x - c)) y < e * d" "y \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3267
    have *: "y = (1 - (1 - e)) *\<^sub>R ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) + (1 - e) *\<^sub>R x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3268
      using `e > 0` by (auto simp add: scaleR_left_diff_distrib scaleR_right_diff_distrib)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3269
    have "x \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3270
      using assms hull_subset[of S] by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3271
    moreover have "1 / e + - ((1 - e) / e) = 1"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3272
      using `e > 0` left_diff_distrib[of "1" "(1-e)" "1/e"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3273
    ultimately have **: "(1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3274
      using as affine_affine_hull[of S] mem_affine[of "affine hull S" y x "(1 / e)" "-((1 - e) / e)"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3275
      by (simp add: algebra_simps)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3276
    have "dist c ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) = abs(1/e) * norm (e *\<^sub>R c - y + (1 - e) *\<^sub>R x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3277
      unfolding dist_norm norm_scaleR[symmetric]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3278
      apply (rule arg_cong[where f=norm])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3279
      using `e > 0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3280
      apply (auto simp add: euclidean_eq_iff[where 'a='a] field_simps inner_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3281
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3282
    also have "\<dots> = abs (1/e) * norm (x - e *\<^sub>R (x - c) - y)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3283
      by (auto intro!:arg_cong[where f=norm] simp add: algebra_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3284
    also have "\<dots> < d"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3285
      using as[unfolded dist_norm] and `e > 0`
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
  3286
      by (auto simp add:pos_divide_less_eq[OF `e > 0`] mult.commute)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3287
    finally have "y \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3288
      apply (subst *)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3289
      apply (rule assms(1)[unfolded convex_alt,rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3290
      apply (rule d[unfolded subset_eq,rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3291
      unfolding mem_ball
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3292
      using assms(3-5) **
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3293
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3294
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3295
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3296
  then have "ball (x - e *\<^sub>R (x - c)) (e*d) \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3297
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3298
  moreover have "e * d > 0"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  3299
    using `e > 0` `d > 0` by simp
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3300
  moreover have c: "c \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3301
    using assms rel_interior_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3302
  moreover from c have "x - e *\<^sub>R (x - c) \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3303
    using mem_convex[of S x c e]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3304
    apply (simp add: algebra_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3305
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3306
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3307
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3308
  ultimately show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3309
    using mem_rel_interior_ball[of "x - e *\<^sub>R (x - c)" S] `e > 0` by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3310
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3311
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3312
lemma interior_real_semiline:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3313
  fixes a :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3314
  shows "interior {a..} = {a<..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3315
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3316
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3317
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3318
    assume "a < y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3319
    then have "y \<in> interior {a..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3320
      apply (simp add: mem_interior)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3321
      apply (rule_tac x="(y-a)" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3322
      apply (auto simp add: dist_norm)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3323
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3324
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3325
  moreover
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3326
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3327
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3328
    assume "y \<in> interior {a..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3329
    then obtain e where e: "e > 0" "cball y e \<subseteq> {a..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3330
      using mem_interior_cball[of y "{a..}"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3331
    moreover from e have "y - e \<in> cball y e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3332
      by (auto simp add: cball_def dist_norm)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3333
    ultimately have "a \<le> y - e" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3334
    then have "a < y" using e by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3335
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3336
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3337
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3338
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  3339
lemma rel_interior_real_box:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3340
  fixes a b :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3341
  assumes "a < b"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  3342
  shows "rel_interior {a .. b} = {a <..< b}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3343
proof -
54775
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54465
diff changeset
  3344
  have "box a b \<noteq> {}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3345
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3346
    unfolding set_eq_iff
56189
c4daa97ac57a removed dependencies on theory Ordered_Euclidean_Space
immler
parents: 56188
diff changeset
  3347
    by (auto intro!: exI[of _ "(a + b) / 2"] simp: box_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3348
  then show ?thesis
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  3349
    using interior_rel_interior_gen[of "cbox a b", symmetric]
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  3350
    by (simp split: split_if_asm del: box_real add: box_real[symmetric] interior_cbox)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3351
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3352
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3353
lemma rel_interior_real_semiline:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3354
  fixes a :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3355
  shows "rel_interior {a..} = {a<..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3356
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3357
  have *: "{a<..} \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3358
    unfolding set_eq_iff by (auto intro!: exI[of _ "a + 1"])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3359
  then show ?thesis using interior_real_semiline interior_rel_interior_gen[of "{a..}"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3360
    by (auto split: split_if_asm)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3361
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3362
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  3363
subsubsection {* Relative open sets *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3364
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3365
definition "rel_open S \<longleftrightarrow> rel_interior S = S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3366
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3367
lemma rel_open: "rel_open S \<longleftrightarrow> openin (subtopology euclidean (affine hull S)) S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3368
  unfolding rel_open_def rel_interior_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3369
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3370
  using openin_subopen[of "subtopology euclidean (affine hull S)" S]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3371
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3372
  done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3373
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3374
lemma opein_rel_interior: "openin (subtopology euclidean (affine hull S)) (rel_interior S)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3375
  apply (simp add: rel_interior_def)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3376
  apply (subst openin_subopen)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3377
  apply blast
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3378
  done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3379
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3380
lemma affine_rel_open:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3381
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3382
  assumes "affine S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3383
  shows "rel_open S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3384
  unfolding rel_open_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3385
  using assms rel_interior_univ[of S] affine_hull_eq[of S]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3386
  by metis
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3387
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3388
lemma affine_closed:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3389
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3390
  assumes "affine S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3391
  shows "closed S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3392
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3393
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3394
    assume "S \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3395
    then obtain L where L: "subspace L" "affine_parallel S L"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3396
      using assms affine_parallel_subspace[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3397
    then obtain a where a: "S = (op + a ` L)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3398
      using affine_parallel_def[of L S] affine_parallel_commut by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3399
    from L have "closed L" using closed_subspace by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3400
    then have "closed S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3401
      using closed_translation a by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3402
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3403
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3404
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3405
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3406
lemma closure_affine_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3407
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3408
  shows "closure S \<subseteq> affine hull S"
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  3409
  by (intro closure_minimal hull_subset affine_closed affine_affine_hull)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3410
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3411
lemma closure_same_affine_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3412
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3413
  shows "affine hull (closure S) = affine hull S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3414
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3415
  have "affine hull (closure S) \<subseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3416
    using hull_mono[of "closure S" "affine hull S" "affine"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3417
      closure_affine_hull[of S] hull_hull[of "affine" S]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3418
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3419
  moreover have "affine hull (closure S) \<supseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3420
    using hull_mono[of "S" "closure S" "affine"] closure_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3421
  ultimately show ?thesis by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3422
qed
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3423
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3424
lemma closure_aff_dim:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3425
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3426
  shows "aff_dim (closure S) = aff_dim S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3427
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3428
  have "aff_dim S \<le> aff_dim (closure S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3429
    using aff_dim_subset closure_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3430
  moreover have "aff_dim (closure S) \<le> aff_dim (affine hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3431
    using aff_dim_subset closure_affine_hull by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3432
  moreover have "aff_dim (affine hull S) = aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3433
    using aff_dim_affine_hull by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3434
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3435
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3436
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3437
lemma rel_interior_closure_convex_shrink:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3438
  fixes S :: "_::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3439
  assumes "convex S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3440
    and "c \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3441
    and "x \<in> closure S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3442
    and "e > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3443
    and "e \<le> 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3444
  shows "x - e *\<^sub>R (x - c) \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3445
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3446
  obtain d where "d > 0" and d: "ball c d \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3447
    using assms(2) unfolding mem_rel_interior_ball by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3448
  have "\<exists>y \<in> S. norm (y - x) * (1 - e) < e * d"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3449
  proof (cases "x \<in> S")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3450
    case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3451
    then show ?thesis using `e > 0` `d > 0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3452
      apply (rule_tac bexI[where x=x])
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  3453
      apply (auto)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3454
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3455
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3456
    case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3457
    then have x: "x islimpt S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3458
      using assms(3)[unfolded closure_def] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3459
    show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3460
    proof (cases "e = 1")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3461
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3462
      obtain y where "y \<in> S" "y \<noteq> x" "dist y x < 1"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3463
        using x[unfolded islimpt_approachable,THEN spec[where x=1]] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3464
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3465
        apply (rule_tac x=y in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3466
        unfolding True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3467
        using `d > 0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3468
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3469
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3470
    next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3471
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3472
      then have "0 < e * d / (1 - e)" and *: "1 - e > 0"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  3473
        using `e \<le> 1` `e > 0` `d > 0` by (auto)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3474
      then obtain y where "y \<in> S" "y \<noteq> x" "dist y x < e * d / (1 - e)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3475
        using x[unfolded islimpt_approachable,THEN spec[where x="e*d / (1 - e)"]] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3476
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3477
        apply (rule_tac x=y in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3478
        unfolding dist_norm
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3479
        using pos_less_divide_eq[OF *]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3480
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3481
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3482
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3483
  qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3484
  then obtain y where "y \<in> S" and y: "norm (y - x) * (1 - e) < e * d"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3485
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3486
  def z \<equiv> "c + ((1 - e) / e) *\<^sub>R (x - y)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3487
  have *: "x - e *\<^sub>R (x - c) = y - e *\<^sub>R (y - z)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3488
    unfolding z_def using `e > 0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3489
    by (auto simp add: scaleR_right_diff_distrib scaleR_right_distrib scaleR_left_diff_distrib)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3490
  have zball: "z \<in> ball c d"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3491
    using mem_ball z_def dist_norm[of c]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3492
    using y and assms(4,5)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3493
    by (auto simp add:field_simps norm_minus_commute)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3494
  have "x \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3495
    using closure_affine_hull assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3496
  moreover have "y \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3497
    using `y \<in> S` hull_subset[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3498
  moreover have "c \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3499
    using assms rel_interior_subset hull_subset[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3500
  ultimately have "z \<in> affine hull S"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3501
    using z_def affine_affine_hull[of S]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3502
      mem_affine_3_minus [of "affine hull S" c x y "(1 - e) / e"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3503
      assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3504
    by (auto simp add: field_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3505
  then have "z \<in> S" using d zball by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3506
  obtain d1 where "d1 > 0" and d1: "ball z d1 \<le> ball c d"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3507
    using zball open_ball[of c d] openE[of "ball c d" z] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3508
  then have "ball z d1 \<inter> affine hull S \<subseteq> ball c d \<inter> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3509
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3510
  then have "ball z d1 \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3511
    using d by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3512
  then have "z \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3513
    using mem_rel_interior_ball using `d1 > 0` `z \<in> S` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3514
  then have "y - e *\<^sub>R (y - z) \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3515
    using rel_interior_convex_shrink[of S z y e] assms `y \<in> S` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3516
  then show ?thesis using * by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3517
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3518
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3519
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  3520
subsubsection{* Relative interior preserves under linear transformations *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3521
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3522
lemma rel_interior_translation_aux:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3523
  fixes a :: "'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3524
  shows "((\<lambda>x. a + x) ` rel_interior S) \<subseteq> rel_interior ((\<lambda>x. a + x) ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3525
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3526
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3527
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3528
    assume x: "x \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3529
    then obtain T where "open T" "x \<in> T \<inter> S" "T \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3530
      using mem_rel_interior[of x S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3531
    then have "open ((\<lambda>x. a + x) ` T)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3532
      and "a + x \<in> ((\<lambda>x. a + x) ` T) \<inter> ((\<lambda>x. a + x) ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3533
      and "((\<lambda>x. a + x) ` T) \<inter> affine hull ((\<lambda>x. a + x) ` S) \<subseteq> (\<lambda>x. a + x) ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3534
      using affine_hull_translation[of a S] open_translation[of T a] x by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3535
    then have "a + x \<in> rel_interior ((\<lambda>x. a + x) ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3536
      using mem_rel_interior[of "a+x" "((\<lambda>x. a + x) ` S)"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3537
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3538
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3539
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3540
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3541
lemma rel_interior_translation:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3542
  fixes a :: "'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3543
  shows "rel_interior ((\<lambda>x. a + x) ` S) = (\<lambda>x. a + x) ` rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3544
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3545
  have "(\<lambda>x. (-a) + x) ` rel_interior ((\<lambda>x. a + x) ` S) \<subseteq> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3546
    using rel_interior_translation_aux[of "-a" "(\<lambda>x. a + x) ` S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3547
      translation_assoc[of "-a" "a"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3548
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3549
  then have "((\<lambda>x. a + x) ` rel_interior S) \<supseteq> rel_interior ((\<lambda>x. a + x) ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3550
    using translation_inverse_subset[of a "rel_interior (op + a ` S)" "rel_interior S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3551
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3552
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3553
    using rel_interior_translation_aux[of a S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3554
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3555
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3556
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3557
lemma affine_hull_linear_image:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3558
  assumes "bounded_linear f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3559
  shows "f ` (affine hull s) = affine hull f ` s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3560
  apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3561
  unfolding subset_eq ball_simps
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3562
  apply (rule_tac[!] hull_induct, rule hull_inc)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3563
  prefer 3
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3564
  apply (erule imageE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3565
  apply (rule_tac x=xa in image_eqI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3566
  apply assumption
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3567
  apply (rule hull_subset[unfolded subset_eq, rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3568
  apply assumption
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3569
proof -
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3570
  interpret f: bounded_linear f by fact
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3571
  show "affine {x. f x \<in> affine hull f ` s}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3572
    unfolding affine_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3573
    by (auto simp add: f.scaleR f.add affine_affine_hull[unfolded affine_def, rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3574
  show "affine {x. x \<in> f ` (affine hull s)}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3575
    using affine_affine_hull[unfolded affine_def, of s]
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3576
    unfolding affine_def by (auto simp add: f.scaleR [symmetric] f.add [symmetric])
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3577
qed auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3578
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3579
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3580
lemma rel_interior_injective_on_span_linear_image:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3581
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3582
    and S :: "'m::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3583
  assumes "bounded_linear f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3584
    and "inj_on f (span S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3585
  shows "rel_interior (f ` S) = f ` (rel_interior S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3586
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3587
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3588
    fix z
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3589
    assume z: "z \<in> rel_interior (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3590
    then have "z \<in> f ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3591
      using rel_interior_subset[of "f ` S"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3592
    then obtain x where x: "x \<in> S" "f x = z" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3593
    obtain e2 where e2: "e2 > 0" "cball z e2 \<inter> affine hull (f ` S) \<subseteq> (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3594
      using z rel_interior_cball[of "f ` S"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3595
    obtain K where K: "K > 0" "\<And>x. norm (f x) \<le> norm x * K"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3596
     using assms Real_Vector_Spaces.bounded_linear.pos_bounded[of f] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3597
    def e1 \<equiv> "1 / K"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3598
    then have e1: "e1 > 0" "\<And>x. e1 * norm (f x) \<le> norm x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3599
      using K pos_le_divide_eq[of e1] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3600
    def e \<equiv> "e1 * e2"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  3601
    then have "e > 0" using e1 e2 by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3602
    {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3603
      fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3604
      assume y: "y \<in> cball x e \<inter> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3605
      then have h1: "f y \<in> affine hull (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3606
        using affine_hull_linear_image[of f S] assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3607
      from y have "norm (x-y) \<le> e1 * e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3608
        using cball_def[of x e] dist_norm[of x y] e_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3609
      moreover have "f x - f y = f (x - y)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3610
        using assms linear_sub[of f x y] linear_conv_bounded_linear[of f] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3611
      moreover have "e1 * norm (f (x-y)) \<le> norm (x - y)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3612
        using e1 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3613
      ultimately have "e1 * norm ((f x)-(f y)) \<le> e1 * e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3614
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3615
      then have "f y \<in> cball z e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3616
        using cball_def[of "f x" e2] dist_norm[of "f x" "f y"] e1 x by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3617
      then have "f y \<in> f ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3618
        using y e2 h1 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3619
      then have "y \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3620
        using assms y hull_subset[of S] affine_hull_subset_span
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3621
          inj_on_image_mem_iff[of f "span S" S y]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3622
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3623
    }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3624
    then have "z \<in> f ` (rel_interior S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3625
      using mem_rel_interior_cball[of x S] `e > 0` x by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3626
  }
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3627
  moreover
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3628
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3629
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3630
    assume x: "x \<in> rel_interior S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3631
    then obtain e2 where e2: "e2 > 0" "cball x e2 \<inter> affine hull S \<subseteq> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3632
      using rel_interior_cball[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3633
    have "x \<in> S" using x rel_interior_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3634
    then have *: "f x \<in> f ` S" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3635
    have "\<forall>x\<in>span S. f x = 0 \<longrightarrow> x = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3636
      using assms subspace_span linear_conv_bounded_linear[of f]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3637
        linear_injective_on_subspace_0[of f "span S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3638
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3639
    then obtain e1 where e1: "e1 > 0" "\<forall>x \<in> span S. e1 * norm x \<le> norm (f x)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3640
      using assms injective_imp_isometric[of "span S" f]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3641
        subspace_span[of S] closed_subspace[of "span S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3642
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3643
    def e \<equiv> "e1 * e2"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  3644
    hence "e > 0" using e1 e2 by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3645
    {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3646
      fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3647
      assume y: "y \<in> cball (f x) e \<inter> affine hull (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3648
      then have "y \<in> f ` (affine hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3649
        using affine_hull_linear_image[of f S] assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3650
      then obtain xy where xy: "xy \<in> affine hull S" "f xy = y" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3651
      with y have "norm (f x - f xy) \<le> e1 * e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3652
        using cball_def[of "f x" e] dist_norm[of "f x" y] e_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3653
      moreover have "f x - f xy = f (x - xy)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3654
        using assms linear_sub[of f x xy] linear_conv_bounded_linear[of f] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3655
      moreover have *: "x - xy \<in> span S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3656
        using subspace_sub[of "span S" x xy] subspace_span `x \<in> S` xy
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3657
          affine_hull_subset_span[of S] span_inc
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3658
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3659
      moreover from * have "e1 * norm (x - xy) \<le> norm (f (x - xy))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3660
        using e1 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3661
      ultimately have "e1 * norm (x - xy) \<le> e1 * e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3662
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3663
      then have "xy \<in> cball x e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3664
        using cball_def[of x e2] dist_norm[of x xy] e1 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3665
      then have "y \<in> f ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3666
        using xy e2 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3667
    }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3668
    then have "f x \<in> rel_interior (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3669
      using mem_rel_interior_cball[of "(f x)" "(f ` S)"] * `e > 0` by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3670
  }
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3671
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3672
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3673
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3674
lemma rel_interior_injective_linear_image:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3675
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3676
  assumes "bounded_linear f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3677
    and "inj f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3678
  shows "rel_interior (f ` S) = f ` (rel_interior S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3679
  using assms rel_interior_injective_on_span_linear_image[of f S]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3680
    subset_inj_on[of f "UNIV" "span S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3681
  by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3682
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3683
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3684
subsection{* Some Properties of subset of standard basis *}
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3685
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3686
lemma affine_hull_substd_basis:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3687
  assumes "d \<subseteq> Basis"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3688
  shows "affine hull (insert 0 d) = {x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3689
  (is "affine hull (insert 0 ?A) = ?B")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3690
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3691
  have *: "\<And>A. op + (0\<Colon>'a) ` A = A" "\<And>A. op + (- (0\<Colon>'a)) ` A = A"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3692
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3693
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3694
    unfolding affine_hull_insert_span_gen span_substd_basis[OF assms,symmetric] * ..
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3695
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3696
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3697
lemma affine_hull_convex_hull: "affine hull (convex hull S) = affine hull S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3698
  by (metis Int_absorb1 Int_absorb2 convex_hull_subset_affine_hull hull_hull hull_mono hull_subset)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3699
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3700
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3701
subsection {* Openness and compactness are preserved by convex hull operation. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3702
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  3703
lemma open_convex_hull[intro]:
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3704
  fixes s :: "'a::real_normed_vector set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3705
  assumes "open s"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3706
  shows "open (convex hull s)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3707
  unfolding open_contains_cball convex_hull_explicit
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3708
  unfolding mem_Collect_eq ball_simps(8)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3709
proof (rule, rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3710
  fix a
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3711
  assume "\<exists>sa u. finite sa \<and> sa \<subseteq> s \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = a"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3712
  then obtain t u where obt: "finite t" "t\<subseteq>s" "\<forall>x\<in>t. 0 \<le> u x" "setsum u t = 1" "(\<Sum>v\<in>t. u v *\<^sub>R v) = a"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3713
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3714
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3715
  from assms[unfolded open_contains_cball] obtain b
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3716
    where b: "\<forall>x\<in>s. 0 < b x \<and> cball x (b x) \<subseteq> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3717
    using bchoice[of s "\<lambda>x e. e > 0 \<and> cball x e \<subseteq> s"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3718
  have "b ` t \<noteq> {}"
56889
48a745e1bde7 avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
hoelzl
parents: 56571
diff changeset
  3719
    using obt by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3720
  def i \<equiv> "b ` t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3721
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3722
  show "\<exists>e > 0.
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3723
    cball a e \<subseteq> {y. \<exists>sa u. finite sa \<and> sa \<subseteq> s \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3724
    apply (rule_tac x = "Min i" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3725
    unfolding subset_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3726
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3727
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3728
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3729
    unfolding mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3730
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3731
    show "0 < Min i"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3732
      unfolding i_def and Min_gr_iff[OF finite_imageI[OF obt(1)] `b \` t\<noteq>{}`]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3733
      using b
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3734
      apply simp
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3735
      apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3736
      apply (erule_tac x=x in ballE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3737
      using `t\<subseteq>s`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3738
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3739
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3740
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3741
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3742
    assume "y \<in> cball a (Min i)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3743
    then have y: "norm (a - y) \<le> Min i"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3744
      unfolding dist_norm[symmetric] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3745
    {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3746
      fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3747
      assume "x \<in> t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3748
      then have "Min i \<le> b x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3749
        unfolding i_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3750
        apply (rule_tac Min_le)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3751
        using obt(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3752
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3753
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3754
      then have "x + (y - a) \<in> cball x (b x)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3755
        using y unfolding mem_cball dist_norm by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3756
      moreover from `x\<in>t` have "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3757
        using obt(2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3758
      ultimately have "x + (y - a) \<in> s"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3759
        using y and b[THEN bspec[where x=x]] unfolding subset_eq by fast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3760
    }
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3761
    moreover
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3762
    have *: "inj_on (\<lambda>v. v + (y - a)) t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3763
      unfolding inj_on_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3764
    have "(\<Sum>v\<in>(\<lambda>v. v + (y - a)) ` t. u (v - (y - a))) = 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  3765
      unfolding setsum.reindex[OF *] o_def using obt(4) by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3766
    moreover have "(\<Sum>v\<in>(\<lambda>v. v + (y - a)) ` t. u (v - (y - a)) *\<^sub>R v) = y"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  3767
      unfolding setsum.reindex[OF *] o_def using obt(4,5)
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  3768
      by (simp add: setsum.distrib setsum_subtractf scaleR_left.setsum[symmetric] scaleR_right_distrib)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3769
    ultimately
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3770
    show "\<exists>sa u. finite sa \<and> (\<forall>x\<in>sa. x \<in> s) \<and> (\<forall>x\<in>sa. 0 \<le> u x) \<and> setsum u sa = 1 \<and> (\<Sum>v\<in>sa. u v *\<^sub>R v) = y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3771
      apply (rule_tac x="(\<lambda>v. v + (y - a)) ` t" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3772
      apply (rule_tac x="\<lambda>v. u (v - (y - a))" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3773
      using obt(1, 3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3774
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3775
      done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3776
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3777
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3778
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3779
lemma compact_convex_combinations:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3780
  fixes s t :: "'a::real_normed_vector set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3781
  assumes "compact s" "compact t"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3782
  shows "compact { (1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. 0 \<le> u \<and> u \<le> 1 \<and> x \<in> s \<and> y \<in> t}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3783
proof -
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3784
  let ?X = "{0..1} \<times> s \<times> t"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3785
  let ?h = "(\<lambda>z. (1 - fst z) *\<^sub>R fst (snd z) + fst z *\<^sub>R snd (snd z))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3786
  have *: "{ (1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. 0 \<le> u \<and> u \<le> 1 \<and> x \<in> s \<and> y \<in> t} = ?h ` ?X"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3787
    apply (rule set_eqI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3788
    unfolding image_iff mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3789
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3790
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3791
    apply (rule_tac x=u in rev_bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3792
    apply simp
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3793
    apply (erule rev_bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3794
    apply (erule rev_bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3795
    apply simp
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3796
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3797
    done
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  3798
  have "continuous_on ?X (\<lambda>z. (1 - fst z) *\<^sub>R fst (snd z) + fst z *\<^sub>R snd (snd z))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3799
    unfolding continuous_on by (rule ballI) (intro tendsto_intros)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3800
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3801
    unfolding *
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3802
    apply (rule compact_continuous_image)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  3803
    apply (intro compact_Times compact_Icc assms)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3804
    done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3805
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3806
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3807
lemma finite_imp_compact_convex_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3808
  fixes s :: "'a::real_normed_vector set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3809
  assumes "finite s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3810
  shows "compact (convex hull s)"
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3811
proof (cases "s = {}")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3812
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3813
  then show ?thesis by simp
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3814
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3815
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3816
  with assms show ?thesis
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3817
  proof (induct rule: finite_ne_induct)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3818
    case (singleton x)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3819
    show ?case by simp
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3820
  next
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3821
    case (insert x A)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3822
    let ?f = "\<lambda>(u, y::'a). u *\<^sub>R x + (1 - u) *\<^sub>R y"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3823
    let ?T = "{0..1::real} \<times> (convex hull A)"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3824
    have "continuous_on ?T ?f"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3825
      unfolding split_def continuous_on by (intro ballI tendsto_intros)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3826
    moreover have "compact ?T"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  3827
      by (intro compact_Times compact_Icc insert)
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3828
    ultimately have "compact (?f ` ?T)"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3829
      by (rule compact_continuous_image)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3830
    also have "?f ` ?T = convex hull (insert x A)"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3831
      unfolding convex_hull_insert [OF `A \<noteq> {}`]
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3832
      apply safe
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3833
      apply (rule_tac x=a in exI, simp)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3834
      apply (rule_tac x="1 - a" in exI, simp)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3835
      apply fast
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3836
      apply (rule_tac x="(u, b)" in image_eqI, simp_all)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3837
      done
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3838
    finally show "compact (convex hull (insert x A))" .
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3839
  qed
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3840
qed
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  3841
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3842
lemma compact_convex_hull:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3843
  fixes s :: "'a::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3844
  assumes "compact s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3845
  shows "compact (convex hull s)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3846
proof (cases "s = {}")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3847
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3848
  then show ?thesis using compact_empty by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3849
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3850
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3851
  then obtain w where "w \<in> s" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3852
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3853
    unfolding caratheodory[of s]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3854
  proof (induct ("DIM('a) + 1"))
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3855
    case 0
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3856
    have *: "{x.\<exists>sa. finite sa \<and> sa \<subseteq> s \<and> card sa \<le> 0 \<and> x \<in> convex hull sa} = {}"
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36341
diff changeset
  3857
      using compact_empty by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3858
    from 0 show ?case unfolding * by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3859
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3860
    case (Suc n)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3861
    show ?case
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3862
    proof (cases "n = 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3863
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3864
      have "{x. \<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> Suc n \<and> x \<in> convex hull t} = s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3865
        unfolding set_eq_iff and mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3866
      proof (rule, rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3867
        fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3868
        assume "\<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> Suc n \<and> x \<in> convex hull t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3869
        then obtain t where t: "finite t" "t \<subseteq> s" "card t \<le> Suc n" "x \<in> convex hull t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3870
          by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3871
        show "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3872
        proof (cases "card t = 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3873
          case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3874
          then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3875
            using t(4) unfolding card_0_eq[OF t(1)] by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3876
        next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3877
          case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3878
          then have "card t = Suc 0" using t(3) `n=0` by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3879
          then obtain a where "t = {a}" unfolding card_Suc_eq by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3880
          then show ?thesis using t(2,4) by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3881
        qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3882
      next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3883
        fix x assume "x\<in>s"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3884
        then show "\<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> Suc n \<and> x \<in> convex hull t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3885
          apply (rule_tac x="{x}" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3886
          unfolding convex_hull_singleton
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3887
          apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3888
          done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3889
      qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3890
      then show ?thesis using assms by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3891
    next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3892
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3893
      have "{x. \<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> Suc n \<and> x \<in> convex hull t} =
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3894
        {(1 - u) *\<^sub>R x + u *\<^sub>R y | x y u.
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3895
          0 \<le> u \<and> u \<le> 1 \<and> x \<in> s \<and> y \<in> {x. \<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> n \<and> x \<in> convex hull t}}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3896
        unfolding set_eq_iff and mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3897
      proof (rule, rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3898
        fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3899
        assume "\<exists>u v c. x = (1 - c) *\<^sub>R u + c *\<^sub>R v \<and>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3900
          0 \<le> c \<and> c \<le> 1 \<and> u \<in> s \<and> (\<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> n \<and> v \<in> convex hull t)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3901
        then obtain u v c t where obt: "x = (1 - c) *\<^sub>R u + c *\<^sub>R v"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3902
          "0 \<le> c \<and> c \<le> 1" "u \<in> s" "finite t" "t \<subseteq> s" "card t \<le> n"  "v \<in> convex hull t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3903
          by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3904
        moreover have "(1 - c) *\<^sub>R u + c *\<^sub>R v \<in> convex hull insert u t"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3905
          apply (rule mem_convex)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3906
          using obt(2) and convex_convex_hull and hull_subset[of "insert u t" convex]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3907
          using obt(7) and hull_mono[of t "insert u t"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3908
          apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3909
          done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3910
        ultimately show "\<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> Suc n \<and> x \<in> convex hull t"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3911
          apply (rule_tac x="insert u t" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3912
          apply (auto simp add: card_insert_if)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3913
          done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3914
      next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3915
        fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3916
        assume "\<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> Suc n \<and> x \<in> convex hull t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3917
        then obtain t where t: "finite t" "t \<subseteq> s" "card t \<le> Suc n" "x \<in> convex hull t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3918
          by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3919
        show "\<exists>u v c. x = (1 - c) *\<^sub>R u + c *\<^sub>R v \<and>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3920
          0 \<le> c \<and> c \<le> 1 \<and> u \<in> s \<and> (\<exists>t. finite t \<and> t \<subseteq> s \<and> card t \<le> n \<and> v \<in> convex hull t)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3921
        proof (cases "card t = Suc n")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3922
          case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3923
          then have "card t \<le> n" using t(3) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3924
          then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3925
            apply (rule_tac x=w in exI, rule_tac x=x in exI, rule_tac x=1 in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3926
            using `w\<in>s` and t
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3927
            apply (auto intro!: exI[where x=t])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3928
            done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3929
        next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3930
          case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3931
          then obtain a u where au: "t = insert a u" "a\<notin>u"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3932
            apply (drule_tac card_eq_SucD)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3933
            apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3934
            done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3935
          show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3936
          proof (cases "u = {}")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3937
            case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3938
            then have "x = a" using t(4)[unfolded au] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3939
            show ?thesis unfolding `x = a`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3940
              apply (rule_tac x=a in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3941
              apply (rule_tac x=a in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3942
              apply (rule_tac x=1 in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3943
              using t and `n \<noteq> 0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3944
              unfolding au
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3945
              apply (auto intro!: exI[where x="{a}"])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3946
              done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3947
          next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3948
            case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3949
            obtain ux vx b where obt: "ux\<ge>0" "vx\<ge>0" "ux + vx = 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3950
              "b \<in> convex hull u" "x = ux *\<^sub>R a + vx *\<^sub>R b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3951
              using t(4)[unfolded au convex_hull_insert[OF False]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3952
              by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3953
            have *: "1 - vx = ux" using obt(3) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3954
            show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3955
              apply (rule_tac x=a in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3956
              apply (rule_tac x=b in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3957
              apply (rule_tac x=vx in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3958
              using obt and t(1-3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3959
              unfolding au and * using card_insert_disjoint[OF _ au(2)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3960
              apply (auto intro!: exI[where x=u])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3961
              done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3962
          qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3963
        qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3964
      qed
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3965
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3966
        using compact_convex_combinations[OF assms Suc] by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3967
    qed
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36341
diff changeset
  3968
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3969
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3970
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3971
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3972
subsection {* Extremal points of a simplex are some vertices. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3973
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3974
lemma dist_increases_online:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3975
  fixes a b d :: "'a::real_inner"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3976
  assumes "d \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3977
  shows "dist a (b + d) > dist a b \<or> dist a (b - d) > dist a b"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3978
proof (cases "inner a d - inner b d > 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3979
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3980
  then have "0 < inner d d + (inner a d * 2 - inner b d * 2)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3981
    apply (rule_tac add_pos_pos)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3982
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3983
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3984
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3985
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3986
    apply (rule_tac disjI2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3987
    unfolding dist_norm and norm_eq_sqrt_inner and real_sqrt_less_iff
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3988
    apply  (simp add: algebra_simps inner_commute)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3989
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3990
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3991
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3992
  then have "0 < inner d d + (inner b d * 2 - inner a d * 2)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3993
    apply (rule_tac add_pos_nonneg)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3994
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3995
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3996
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3997
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3998
    apply (rule_tac disjI1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3999
    unfolding dist_norm and norm_eq_sqrt_inner and real_sqrt_less_iff
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4000
    apply (simp add: algebra_simps inner_commute)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4001
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4002
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4003
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4004
lemma norm_increases_online:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4005
  fixes d :: "'a::real_inner"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4006
  shows "d \<noteq> 0 \<Longrightarrow> norm (a + d) > norm a \<or> norm(a - d) > norm a"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4007
  using dist_increases_online[of d a 0] unfolding dist_norm by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4008
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4009
lemma simplex_furthest_lt:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4010
  fixes s :: "'a::real_inner set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4011
  assumes "finite s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4012
  shows "\<forall>x \<in> convex hull s.  x \<notin> s \<longrightarrow> (\<exists>y \<in> convex hull s. norm (x - a) < norm(y - a))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4013
  using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4014
proof induct
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4015
  fix x s
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4016
  assume as: "finite s" "x\<notin>s" "\<forall>x\<in>convex hull s. x \<notin> s \<longrightarrow> (\<exists>y\<in>convex hull s. norm (x - a) < norm (y - a))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4017
  show "\<forall>xa\<in>convex hull insert x s. xa \<notin> insert x s \<longrightarrow>
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4018
    (\<exists>y\<in>convex hull insert x s. norm (xa - a) < norm (y - a))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4019
  proof (rule, rule, cases "s = {}")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4020
    case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4021
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4022
    assume y: "y \<in> convex hull insert x s" "y \<notin> insert x s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4023
    obtain u v b where obt: "u\<ge>0" "v\<ge>0" "u + v = 1" "b \<in> convex hull s" "y = u *\<^sub>R x + v *\<^sub>R b"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4024
      using y(1)[unfolded convex_hull_insert[OF False]] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4025
    show "\<exists>z\<in>convex hull insert x s. norm (y - a) < norm (z - a)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4026
    proof (cases "y \<in> convex hull s")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4027
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4028
      then obtain z where "z \<in> convex hull s" "norm (y - a) < norm (z - a)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4029
        using as(3)[THEN bspec[where x=y]] and y(2) by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4030
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4031
        apply (rule_tac x=z in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4032
        unfolding convex_hull_insert[OF False]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4033
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4034
        done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4035
    next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4036
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4037
      show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4038
        using obt(3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4039
      proof (cases "u = 0", case_tac[!] "v = 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4040
        assume "u = 0" "v \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4041
        then have "y = b" using obt by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4042
        then show ?thesis using False and obt(4) by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4043
      next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4044
        assume "u \<noteq> 0" "v = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4045
        then have "y = x" using obt by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4046
        then show ?thesis using y(2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4047
      next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4048
        assume "u \<noteq> 0" "v \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4049
        then obtain w where w: "w>0" "w<u" "w<v"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4050
          using real_lbound_gt_zero[of u v] and obt(1,2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4051
        have "x \<noteq> b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4052
        proof
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4053
          assume "x = b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4054
          then have "y = b" unfolding obt(5)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4055
            using obt(3) by (auto simp add: scaleR_left_distrib[symmetric])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4056
          then show False using obt(4) and False by simp
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4057
        qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4058
        then have *: "w *\<^sub>R (x - b) \<noteq> 0" using w(1) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4059
        show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4060
          using dist_increases_online[OF *, of a y]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4061
        proof (elim disjE)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4062
          assume "dist a y < dist a (y + w *\<^sub>R (x - b))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4063
          then have "norm (y - a) < norm ((u + w) *\<^sub>R x + (v - w) *\<^sub>R b - a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4064
            unfolding dist_commute[of a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4065
            unfolding dist_norm obt(5)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4066
            by (simp add: algebra_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4067
          moreover have "(u + w) *\<^sub>R x + (v - w) *\<^sub>R b \<in> convex hull insert x s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4068
            unfolding convex_hull_insert[OF `s\<noteq>{}`] and mem_Collect_eq
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4069
            apply (rule_tac x="u + w" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4070
            apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4071
            defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4072
            apply (rule_tac x="v - w" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4073
            using `u \<ge> 0` and w and obt(3,4)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4074
            apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4075
            done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4076
          ultimately show ?thesis by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4077
        next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4078
          assume "dist a y < dist a (y - w *\<^sub>R (x - b))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4079
          then have "norm (y - a) < norm ((u - w) *\<^sub>R x + (v + w) *\<^sub>R b - a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4080
            unfolding dist_commute[of a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4081
            unfolding dist_norm obt(5)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4082
            by (simp add: algebra_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4083
          moreover have "(u - w) *\<^sub>R x + (v + w) *\<^sub>R b \<in> convex hull insert x s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4084
            unfolding convex_hull_insert[OF `s\<noteq>{}`] and mem_Collect_eq
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4085
            apply (rule_tac x="u - w" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4086
            apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4087
            defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4088
            apply (rule_tac x="v + w" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4089
            using `u \<ge> 0` and w and obt(3,4)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4090
            apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4091
            done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4092
          ultimately show ?thesis by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4093
        qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4094
      qed auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4095
    qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4096
  qed auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4097
qed (auto simp add: assms)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4098
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4099
lemma simplex_furthest_le:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4100
  fixes s :: "'a::real_inner set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4101
  assumes "finite s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4102
    and "s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4103
  shows "\<exists>y\<in>s. \<forall>x\<in> convex hull s. norm (x - a) \<le> norm (y - a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4104
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4105
  have "convex hull s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4106
    using hull_subset[of s convex] and assms(2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4107
  then obtain x where x: "x \<in> convex hull s" "\<forall>y\<in>convex hull s. norm (y - a) \<le> norm (x - a)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4108
    using distance_attains_sup[OF finite_imp_compact_convex_hull[OF assms(1)], of a]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4109
    unfolding dist_commute[of a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4110
    unfolding dist_norm
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4111
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4112
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4113
  proof (cases "x \<in> s")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4114
    case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4115
    then obtain y where "y \<in> convex hull s" "norm (x - a) < norm (y - a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4116
      using simplex_furthest_lt[OF assms(1), THEN bspec[where x=x]] and x(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4117
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4118
    then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4119
      using x(2)[THEN bspec[where x=y]] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4120
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4121
    case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4122
    with x show ?thesis by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4123
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4124
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4125
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4126
lemma simplex_furthest_le_exists:
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4127
  fixes s :: "('a::real_inner) set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4128
  shows "finite s \<Longrightarrow> \<forall>x\<in>(convex hull s). \<exists>y\<in>s. norm (x - a) \<le> norm (y - a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4129
  using simplex_furthest_le[of s] by (cases "s = {}") auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4130
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4131
lemma simplex_extremal_le:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4132
  fixes s :: "'a::real_inner set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4133
  assumes "finite s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4134
    and "s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4135
  shows "\<exists>u\<in>s. \<exists>v\<in>s. \<forall>x\<in>convex hull s. \<forall>y \<in> convex hull s. norm (x - y) \<le> norm (u - v)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4136
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4137
  have "convex hull s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4138
    using hull_subset[of s convex] and assms(2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4139
  then obtain u v where obt: "u \<in> convex hull s" "v \<in> convex hull s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4140
    "\<forall>x\<in>convex hull s. \<forall>y\<in>convex hull s. norm (x - y) \<le> norm (u - v)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4141
    using compact_sup_maxdistance[OF finite_imp_compact_convex_hull[OF assms(1)]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4142
    by (auto simp: dist_norm)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4143
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4144
  proof (cases "u\<notin>s \<or> v\<notin>s", elim disjE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4145
    assume "u \<notin> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4146
    then obtain y where "y \<in> convex hull s" "norm (u - v) < norm (y - v)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4147
      using simplex_furthest_lt[OF assms(1), THEN bspec[where x=u]] and obt(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4148
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4149
    then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4150
      using obt(3)[THEN bspec[where x=y], THEN bspec[where x=v]] and obt(2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4151
      by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4152
  next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4153
    assume "v \<notin> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4154
    then obtain y where "y \<in> convex hull s" "norm (v - u) < norm (y - u)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4155
      using simplex_furthest_lt[OF assms(1), THEN bspec[where x=v]] and obt(2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4156
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4157
    then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4158
      using obt(3)[THEN bspec[where x=u], THEN bspec[where x=y]] and obt(1)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4159
      by (auto simp add: norm_minus_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4160
  qed auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4161
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4162
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4163
lemma simplex_extremal_le_exists:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4164
  fixes s :: "'a::real_inner set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4165
  shows "finite s \<Longrightarrow> x \<in> convex hull s \<Longrightarrow> y \<in> convex hull s \<Longrightarrow>
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4166
    \<exists>u\<in>s. \<exists>v\<in>s. norm (x - y) \<le> norm (u - v)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4167
  using convex_hull_empty simplex_extremal_le[of s]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4168
  by(cases "s = {}") auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4169
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4170
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4171
subsection {* Closest point of a convex set is unique, with a continuous projection. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4172
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4173
definition closest_point :: "'a::{real_inner,heine_borel} set \<Rightarrow> 'a \<Rightarrow> 'a"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4174
  where "closest_point s a = (SOME x. x \<in> s \<and> (\<forall>y\<in>s. dist a x \<le> dist a y))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4176
lemma closest_point_exists:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4177
  assumes "closed s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4178
    and "s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4179
  shows "closest_point s a \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4180
    and "\<forall>y\<in>s. dist a (closest_point s a) \<le> dist a y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4181
  unfolding closest_point_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4182
  apply(rule_tac[!] someI2_ex)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4183
  using distance_attains_inf[OF assms(1,2), of a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4184
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4185
  done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4186
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4187
lemma closest_point_in_set: "closed s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> closest_point s a \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4188
  by (meson closest_point_exists)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4189
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4190
lemma closest_point_le: "closed s \<Longrightarrow> x \<in> s \<Longrightarrow> dist a (closest_point s a) \<le> dist a x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4191
  using closest_point_exists[of s] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4192
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4193
lemma closest_point_self:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4194
  assumes "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4195
  shows "closest_point s x = x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4196
  unfolding closest_point_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4197
  apply (rule some1_equality, rule ex1I[of _ x])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4198
  using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4199
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4200
  done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4201
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4202
lemma closest_point_refl: "closed s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> closest_point s x = x \<longleftrightarrow> x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4203
  using closest_point_in_set[of s x] closest_point_self[of x s]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4204
  by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4205
36337
87b6c83d7ed7 generalize constant closest_point
huffman
parents: 36071
diff changeset
  4206
lemma closer_points_lemma:
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4207
  assumes "inner y z > 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4208
  shows "\<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm(v *\<^sub>R z - y) < norm y"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4209
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4210
  have z: "inner z z > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4211
    unfolding inner_gt_zero_iff using assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4212
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4213
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4214
    apply (rule_tac x = "inner y z / inner z z" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4215
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4216
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4217
  proof rule+
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4218
    fix v
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4219
    assume "0 < v" and "v \<le> inner y z / inner z z"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4220
    then show "norm (v *\<^sub>R z - y) < norm y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4221
      unfolding norm_lt using z and assms
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4222
      by (simp add: field_simps inner_diff inner_commute mult_strict_left_mono[OF _ `0<v`])
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  4223
  qed auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4224
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4225
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4226
lemma closer_point_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4227
  assumes "inner (y - x) (z - x) > 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4228
  shows "\<exists>u>0. u \<le> 1 \<and> dist (x + u *\<^sub>R (z - x)) y < dist x y"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4229
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4230
  obtain u where "u > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4231
    and u: "\<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R (z - x) - (y - x)) < norm (y - x)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4232
    using closer_points_lemma[OF assms] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4233
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4234
    apply (rule_tac x="min u 1" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4235
    using u[THEN spec[where x="min u 1"]] and `u > 0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4236
    unfolding dist_norm by (auto simp add: norm_minus_commute field_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4237
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4238
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4239
lemma any_closest_point_dot:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4240
  assumes "convex s" "closed s" "x \<in> s" "y \<in> s" "\<forall>z\<in>s. dist a x \<le> dist a z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4241
  shows "inner (a - x) (y - x) \<le> 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4242
proof (rule ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4243
  assume "\<not> ?thesis"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4244
  then obtain u where u: "u>0" "u\<le>1" "dist (x + u *\<^sub>R (y - x)) a < dist x a"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4245
    using closer_point_lemma[of a x y] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4246
  let ?z = "(1 - u) *\<^sub>R x + u *\<^sub>R y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4247
  have "?z \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4248
    using mem_convex[OF assms(1,3,4), of u] using u by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4249
  then show False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4250
    using assms(5)[THEN bspec[where x="?z"]] and u(3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4251
    by (auto simp add: dist_commute algebra_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4252
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4253
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4254
lemma any_closest_point_unique:
36337
87b6c83d7ed7 generalize constant closest_point
huffman
parents: 36071
diff changeset
  4255
  fixes x :: "'a::real_inner"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4256
  assumes "convex s" "closed s" "x \<in> s" "y \<in> s"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4257
    "\<forall>z\<in>s. dist a x \<le> dist a z" "\<forall>z\<in>s. dist a y \<le> dist a z"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4258
  shows "x = y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4259
  using any_closest_point_dot[OF assms(1-4,5)] and any_closest_point_dot[OF assms(1-2,4,3,6)]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4260
  unfolding norm_pths(1) and norm_le_square
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4261
  by (auto simp add: algebra_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4262
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4263
lemma closest_point_unique:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4264
  assumes "convex s" "closed s" "x \<in> s" "\<forall>z\<in>s. dist a x \<le> dist a z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4265
  shows "x = closest_point s a"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4266
  using any_closest_point_unique[OF assms(1-3) _ assms(4), of "closest_point s a"]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4267
  using closest_point_exists[OF assms(2)] and assms(3) by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4268
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4269
lemma closest_point_dot:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4270
  assumes "convex s" "closed s" "x \<in> s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4271
  shows "inner (a - closest_point s a) (x - closest_point s a) \<le> 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4272
  apply (rule any_closest_point_dot[OF assms(1,2) _ assms(3)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4273
  using closest_point_exists[OF assms(2)] and assms(3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4274
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4275
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4276
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4277
lemma closest_point_lt:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4278
  assumes "convex s" "closed s" "x \<in> s" "x \<noteq> closest_point s a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4279
  shows "dist a (closest_point s a) < dist a x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4280
  apply (rule ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4281
  apply (rule_tac notE[OF assms(4)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4282
  apply (rule closest_point_unique[OF assms(1-3), of a])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4283
  using closest_point_le[OF assms(2), of _ a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4284
  apply fastforce
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4285
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4286
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4287
lemma closest_point_lipschitz:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4288
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4289
    and "closed s" "s \<noteq> {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4290
  shows "dist (closest_point s x) (closest_point s y) \<le> dist x y"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4291
proof -
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4292
  have "inner (x - closest_point s x) (closest_point s y - closest_point s x) \<le> 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4293
    and "inner (y - closest_point s y) (closest_point s x - closest_point s y) \<le> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4294
    apply (rule_tac[!] any_closest_point_dot[OF assms(1-2)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4295
    using closest_point_exists[OF assms(2-3)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4296
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4297
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4298
  then show ?thesis unfolding dist_norm and norm_le
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4299
    using inner_ge_zero[of "(x - closest_point s x) - (y - closest_point s y)"]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4300
    by (simp add: inner_add inner_diff inner_commute)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4301
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4302
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4303
lemma continuous_at_closest_point:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4304
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4305
    and "closed s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4306
    and "s \<noteq> {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4307
  shows "continuous (at x) (closest_point s)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4308
  unfolding continuous_at_eps_delta
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4309
  using le_less_trans[OF closest_point_lipschitz[OF assms]] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4310
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4311
lemma continuous_on_closest_point:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4312
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4313
    and "closed s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4314
    and "s \<noteq> {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4315
  shows "continuous_on t (closest_point s)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4316
  by (metis continuous_at_imp_continuous_on continuous_at_closest_point[OF assms])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4317
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4318
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  4319
subsubsection {* Various point-to-set separating/supporting hyperplane theorems. *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4320
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4321
lemma supporting_hyperplane_closed_point:
36337
87b6c83d7ed7 generalize constant closest_point
huffman
parents: 36071
diff changeset
  4322
  fixes z :: "'a::{real_inner,heine_borel}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4323
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4324
    and "closed s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4325
    and "s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4326
    and "z \<notin> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4327
  shows "\<exists>a b. \<exists>y\<in>s. inner a z < b \<and> inner a y = b \<and> (\<forall>x\<in>s. inner a x \<ge> b)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4328
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4329
  from distance_attains_inf[OF assms(2-3)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4330
  obtain y where "y \<in> s" and y: "\<forall>x\<in>s. dist z y \<le> dist z x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4331
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4332
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4333
    apply (rule_tac x="y - z" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4334
    apply (rule_tac x="inner (y - z) y" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4335
    apply (rule_tac x=y in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4336
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4337
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4338
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4339
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4340
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4341
    apply (rule ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4342
    using `y \<in> s`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4343
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4344
    show "inner (y - z) z < inner (y - z) y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4345
      apply (subst diff_less_iff(1)[symmetric])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4346
      unfolding inner_diff_right[symmetric] and inner_gt_zero_iff
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4347
      using `y\<in>s` `z\<notin>s`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4348
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4349
      done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4350
  next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4351
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4352
    assume "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4353
    have *: "\<forall>u. 0 \<le> u \<and> u \<le> 1 \<longrightarrow> dist z y \<le> dist z ((1 - u) *\<^sub>R y + u *\<^sub>R x)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4354
      using assms(1)[unfolded convex_alt] and y and `x\<in>s` and `y\<in>s` by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4355
    assume "\<not> inner (y - z) y \<le> inner (y - z) x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4356
    then obtain v where "v > 0" "v \<le> 1" "dist (y + v *\<^sub>R (x - y)) z < dist y z"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4357
      using closer_point_lemma[of z y x] by (auto simp add: inner_diff)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4358
    then show False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4359
      using *[THEN spec[where x=v]] by (auto simp add: dist_commute algebra_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4360
  qed auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4361
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4362
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4363
lemma separating_hyperplane_closed_point:
36337
87b6c83d7ed7 generalize constant closest_point
huffman
parents: 36071
diff changeset
  4364
  fixes z :: "'a::{real_inner,heine_borel}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4365
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4366
    and "closed s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4367
    and "z \<notin> s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4368
  shows "\<exists>a b. inner a z < b \<and> (\<forall>x\<in>s. inner a x > b)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4369
proof (cases "s = {}")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4370
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4371
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4372
    apply (rule_tac x="-z" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4373
    apply (rule_tac x=1 in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4374
    using less_le_trans[OF _ inner_ge_zero[of z]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4375
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4376
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4377
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4378
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4379
  obtain y where "y \<in> s" and y: "\<forall>x\<in>s. dist z y \<le> dist z x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4380
    using distance_attains_inf[OF assms(2) False] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4381
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4382
    apply (rule_tac x="y - z" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4383
    apply (rule_tac x="inner (y - z) z + (norm (y - z))\<^sup>2 / 2" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4384
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4385
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4386
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4387
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4388
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4389
    assume "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4390
    have "\<not> 0 < inner (z - y) (x - y)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4391
      apply (rule notI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4392
      apply (drule closer_point_lemma)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4393
    proof -
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4394
      assume "\<exists>u>0. u \<le> 1 \<and> dist (y + u *\<^sub>R (x - y)) z < dist y z"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4395
      then obtain u where "u > 0" "u \<le> 1" "dist (y + u *\<^sub>R (x - y)) z < dist y z"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4396
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4397
      then show False using y[THEN bspec[where x="y + u *\<^sub>R (x - y)"]]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4398
        using assms(1)[unfolded convex_alt, THEN bspec[where x=y]]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4399
        using `x\<in>s` `y\<in>s` by (auto simp add: dist_commute algebra_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4400
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4401
    moreover have "0 < (norm (y - z))\<^sup>2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4402
      using `y\<in>s` `z\<notin>s` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4403
    then have "0 < inner (y - z) (y - z)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4404
      unfolding power2_norm_eq_inner by simp
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51524
diff changeset
  4405
    ultimately show "inner (y - z) z + (norm (y - z))\<^sup>2 / 2 < inner (y - z) x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4406
      unfolding power2_norm_eq_inner and not_less
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4407
      by (auto simp add: field_simps inner_commute inner_diff)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4408
  qed (insert `y\<in>s` `z\<notin>s`, auto)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4409
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4410
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4411
lemma separating_hyperplane_closed_0:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4412
  assumes "convex (s::('a::euclidean_space) set)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4413
    and "closed s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4414
    and "0 \<notin> s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4415
  shows "\<exists>a b. a \<noteq> 0 \<and> 0 < b \<and> (\<forall>x\<in>s. inner a x > b)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4416
proof (cases "s = {}")
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  4417
  case True
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4418
  have "norm ((SOME i. i\<in>Basis)::'a) = 1" "(SOME i. i\<in>Basis) \<noteq> (0::'a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4419
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4420
    apply (subst norm_le_zero_iff[symmetric])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4421
    apply (auto simp: SOME_Basis)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4422
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4423
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4424
    apply (rule_tac x="SOME i. i\<in>Basis" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4425
    apply (rule_tac x=1 in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4426
    using True using DIM_positive[where 'a='a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4427
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4428
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4429
next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4430
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4431
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4432
    using False using separating_hyperplane_closed_point[OF assms]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4433
    apply (elim exE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4434
    unfolding inner_zero_right
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4435
    apply (rule_tac x=a in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4436
    apply (rule_tac x=b in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4437
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4438
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4439
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4440
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4441
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  4442
subsubsection {* Now set-to-set for closed/compact sets *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4443
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4444
lemma separating_hyperplane_closed_compact:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4445
  fixes s :: "'a::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4446
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4447
    and "closed s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4448
    and "convex t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4449
    and "compact t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4450
    and "t \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4451
    and "s \<inter> t = {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4452
  shows "\<exists>a b. (\<forall>x\<in>s. inner a x < b) \<and> (\<forall>x\<in>t. inner a x > b)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4453
proof (cases "s = {}")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4454
  case True
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4455
  obtain b where b: "b > 0" "\<forall>x\<in>t. norm x \<le> b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4456
    using compact_imp_bounded[OF assms(4)] unfolding bounded_pos by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4457
  obtain z :: 'a where z: "norm z = b + 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4458
    using vector_choose_size[of "b + 1"] and b(1) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4459
  then have "z \<notin> t" using b(2)[THEN bspec[where x=z]] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4460
  then obtain a b where ab: "inner a z < b" "\<forall>x\<in>t. b < inner a x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4461
    using separating_hyperplane_closed_point[OF assms(3) compact_imp_closed[OF assms(4)], of z]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4462
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4463
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4464
    using True by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4465
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4466
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4467
  then obtain y where "y \<in> s" by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4468
  obtain a b where "0 < b" "\<forall>x\<in>{x - y |x y. x \<in> s \<and> y \<in> t}. b < inner a x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4469
    using separating_hyperplane_closed_point[OF convex_differences[OF assms(1,3)], of 0]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4470
    using closed_compact_differences[OF assms(2,4)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4471
    using assms(6) by auto blast
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4472
  then have ab: "\<forall>x\<in>s. \<forall>y\<in>t. b + inner a y < inner a x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4473
    apply -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4474
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4475
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4476
    apply (erule_tac x="x - y" in ballE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4477
    apply (auto simp add: inner_diff)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4478
    done
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4479
  def k \<equiv> "SUP x:t. a \<bullet> x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4480
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4481
    apply (rule_tac x="-a" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4482
    apply (rule_tac x="-(k + b / 2)" in exI)
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4483
    apply (intro conjI ballI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4484
    unfolding inner_minus_left and neg_less_iff_less
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4485
  proof -
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4486
    fix x assume "x \<in> t"
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4487
    then have "inner a x - b / 2 < k"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4488
      unfolding k_def
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4489
    proof (subst less_cSUP_iff)
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4490
      show "t \<noteq> {}" by fact
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4491
      show "bdd_above (op \<bullet> a ` t)"
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4492
        using ab[rule_format, of y] `y \<in> s`
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4493
        by (intro bdd_aboveI2[where M="inner a y - b"]) (auto simp: field_simps intro: less_imp_le)
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4494
    qed (auto intro!: bexI[of _ x] `0<b`)
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4495
    then show "inner a x < k + b / 2"
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4496
      by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4497
  next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4498
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4499
    assume "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4500
    then have "k \<le> inner a x - b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4501
      unfolding k_def
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4502
      apply (rule_tac cSUP_least)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4503
      using assms(5)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4504
      using ab[THEN bspec[where x=x]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4505
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4506
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4507
    then show "k + b / 2 < inner a x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4508
      using `0 < b` by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4509
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4510
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4511
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4512
lemma separating_hyperplane_compact_closed:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4513
  fixes s :: "'a::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4514
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4515
    and "compact s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4516
    and "s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4517
    and "convex t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4518
    and "closed t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4519
    and "s \<inter> t = {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4520
  shows "\<exists>a b. (\<forall>x\<in>s. inner a x < b) \<and> (\<forall>x\<in>t. inner a x > b)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4521
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4522
  obtain a b where "(\<forall>x\<in>t. inner a x < b) \<and> (\<forall>x\<in>s. b < inner a x)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4523
    using separating_hyperplane_closed_compact[OF assms(4-5,1-2,3)] and assms(6)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4524
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4525
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4526
    apply (rule_tac x="-a" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4527
    apply (rule_tac x="-b" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4528
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4529
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4530
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4531
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4532
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  4533
subsubsection {* General case without assuming closure and getting non-strict separation *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4534
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4535
lemma separating_hyperplane_set_0:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  4536
  assumes "convex s" "(0::'a::euclidean_space) \<notin> s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4537
  shows "\<exists>a. a \<noteq> 0 \<and> (\<forall>x\<in>s. 0 \<le> inner a x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4538
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4539
  let ?k = "\<lambda>c. {x::'a. 0 \<le> inner c x}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4540
  have "frontier (cball 0 1) \<inter> (\<Inter> (?k ` s)) \<noteq> {}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4541
    apply (rule compact_imp_fip)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4542
    apply (rule compact_frontier[OF compact_cball])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4543
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4544
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4545
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4546
    apply (erule conjE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4547
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4548
    fix f
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4549
    assume as: "f \<subseteq> ?k ` s" "finite f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4550
    obtain c where c: "f = ?k ` c" "c \<subseteq> s" "finite c"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4551
      using finite_subset_image[OF as(2,1)] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4552
    then obtain a b where ab: "a \<noteq> 0" "0 < b" "\<forall>x\<in>convex hull c. b < inner a x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4553
      using separating_hyperplane_closed_0[OF convex_convex_hull, of c]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4554
      using finite_imp_compact_convex_hull[OF c(3), THEN compact_imp_closed] and assms(2)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4555
      using subset_hull[of convex, OF assms(1), symmetric, of c]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4556
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4557
    then have "\<exists>x. norm x = 1 \<and> (\<forall>y\<in>c. 0 \<le> inner y x)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4558
      apply (rule_tac x = "inverse(norm a) *\<^sub>R a" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4559
      using hull_subset[of c convex]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4560
      unfolding subset_eq and inner_scaleR
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  4561
      by (auto simp add: inner_commute del: ballE elim!: ballE)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4562
    then show "frontier (cball 0 1) \<inter> \<Inter>f \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4563
      unfolding c(1) frontier_cball dist_norm by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4564
  qed (insert closed_halfspace_ge, auto)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4565
  then obtain x where "norm x = 1" "\<forall>y\<in>s. x\<in>?k y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4566
    unfolding frontier_cball dist_norm by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4567
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4568
    apply (rule_tac x=x in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4569
    apply (auto simp add: inner_commute)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4570
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4571
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4572
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4573
lemma separating_hyperplane_sets:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4574
  fixes s t :: "'a::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4575
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4576
    and "convex t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4577
    and "s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4578
    and "t \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4579
    and "s \<inter> t = {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4580
  shows "\<exists>a b. a \<noteq> 0 \<and> (\<forall>x\<in>s. inner a x \<le> b) \<and> (\<forall>x\<in>t. inner a x \<ge> b)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4581
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4582
  from separating_hyperplane_set_0[OF convex_differences[OF assms(2,1)]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4583
  obtain a where "a \<noteq> 0" "\<forall>x\<in>{x - y |x y. x \<in> t \<and> y \<in> s}. 0 \<le> inner a x"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4584
    using assms(3-5) by auto
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4585
  then have *: "\<And>x y. x \<in> t \<Longrightarrow> y \<in> s \<Longrightarrow> inner a y \<le> inner a x"
33270
paulson
parents: 33175
diff changeset
  4586
    by (force simp add: inner_diff)
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4587
  then have bdd: "bdd_above ((op \<bullet> a)`s)"
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4588
    using `t \<noteq> {}` by (auto intro: bdd_aboveI2[OF *])
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4589
  show ?thesis
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4590
    using `a\<noteq>0`
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4591
    by (intro exI[of _ a] exI[of _ "SUP x:s. a \<bullet> x"])
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  4592
       (auto intro!: cSUP_upper bdd cSUP_least `a \<noteq> 0` `s \<noteq> {}` *)
33270
paulson
parents: 33175
diff changeset
  4593
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4594
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4595
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  4596
subsection {* More convexity generalities *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4597
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4598
lemma convex_closure:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4599
  fixes s :: "'a::real_normed_vector set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4600
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4601
  shows "convex (closure s)"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4602
  apply (rule convexI)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4603
  apply (unfold closure_sequential, elim exE)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4604
  apply (rule_tac x="\<lambda>n. u *\<^sub>R xa n + v *\<^sub>R xb n" in exI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4605
  apply (rule,rule)
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4606
  apply (rule convexD [OF assms])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4607
  apply (auto del: tendsto_const intro!: tendsto_intros)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4608
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4609
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4610
lemma convex_interior:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4611
  fixes s :: "'a::real_normed_vector set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4612
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4613
  shows "convex (interior s)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4614
  unfolding convex_alt Ball_def mem_interior
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4615
  apply (rule,rule,rule,rule,rule,rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4616
  apply (elim exE conjE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4617
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4618
  fix x y u
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4619
  assume u: "0 \<le> u" "u \<le> (1::real)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4620
  fix e d
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4621
  assume ed: "ball x e \<subseteq> s" "ball y d \<subseteq> s" "0<d" "0<e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4622
  show "\<exists>e>0. ball ((1 - u) *\<^sub>R x + u *\<^sub>R y) e \<subseteq> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4623
    apply (rule_tac x="min d e" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4624
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4625
    unfolding subset_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4626
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4627
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4628
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4629
    fix z
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4630
    assume "z \<in> ball ((1 - u) *\<^sub>R x + u *\<^sub>R y) (min d e)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4631
    then have "(1- u) *\<^sub>R (z - u *\<^sub>R (y - x)) + u *\<^sub>R (z + (1 - u) *\<^sub>R (y - x)) \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4632
      apply (rule_tac assms[unfolded convex_alt, rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4633
      using ed(1,2) and u
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4634
      unfolding subset_eq mem_ball Ball_def dist_norm
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4635
      apply (auto simp add: algebra_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4636
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4637
    then show "z \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4638
      using u by (auto simp add: algebra_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4639
  qed(insert u ed(3-4), auto)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4640
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4641
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  4642
lemma convex_hull_eq_empty[simp]: "convex hull s = {} \<longleftrightarrow> s = {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4643
  using hull_subset[of s convex] convex_hull_empty by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4644
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4645
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4646
subsection {* Moving and scaling convex hulls. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4647
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4648
lemma convex_hull_set_plus:
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4649
  "convex hull (s + t) = convex hull s + convex hull t"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4650
  unfolding set_plus_image
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4651
  apply (subst convex_hull_linear_image [symmetric])
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4652
  apply (simp add: linear_iff scaleR_right_distrib)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4653
  apply (simp add: convex_hull_Times)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4654
  done
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4655
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4656
lemma translation_eq_singleton_plus: "(\<lambda>x. a + x) ` t = {a} + t"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4657
  unfolding set_plus_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4658
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4659
lemma convex_hull_translation:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4660
  "convex hull ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (convex hull s)"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4661
  unfolding translation_eq_singleton_plus
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4662
  by (simp only: convex_hull_set_plus convex_hull_singleton)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4663
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4664
lemma convex_hull_scaling:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4665
  "convex hull ((\<lambda>x. c *\<^sub>R x) ` s) = (\<lambda>x. c *\<^sub>R x) ` (convex hull s)"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4666
  using linear_scaleR by (rule convex_hull_linear_image [symmetric])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4667
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4668
lemma convex_hull_affinity:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4669
  "convex hull ((\<lambda>x. a + c *\<^sub>R x) ` s) = (\<lambda>x. a + c *\<^sub>R x) ` (convex hull s)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4670
  by(simp only: image_image[symmetric] convex_hull_scaling convex_hull_translation)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4671
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4672
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4673
subsection {* Convexity of cone hulls *}
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4674
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4675
lemma convex_cone_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4676
  assumes "convex S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4677
  shows "convex (cone hull S)"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4678
proof (rule convexI)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4679
  fix x y
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4680
  assume xy: "x \<in> cone hull S" "y \<in> cone hull S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4681
  then have "S \<noteq> {}"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4682
    using cone_hull_empty_iff[of S] by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4683
  fix u v :: real
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4684
  assume uv: "u \<ge> 0" "v \<ge> 0" "u + v = 1"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4685
  then have *: "u *\<^sub>R x \<in> cone hull S" "v *\<^sub>R y \<in> cone hull S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4686
    using cone_cone_hull[of S] xy cone_def[of "cone hull S"] by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4687
  from * obtain cx :: real and xx where x: "u *\<^sub>R x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4688
    using cone_hull_expl[of S] by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4689
  from * obtain cy :: real and yy where y: "v *\<^sub>R y = cy *\<^sub>R yy" "cy \<ge> 0" "yy \<in> S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4690
    using cone_hull_expl[of S] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4691
  {
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4692
    assume "cx + cy \<le> 0"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4693
    then have "u *\<^sub>R x = 0" and "v *\<^sub>R y = 0"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4694
      using x y by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4695
    then have "u *\<^sub>R x + v *\<^sub>R y = 0"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4696
      by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4697
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4698
      using cone_hull_contains_0[of S] `S \<noteq> {}` by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4699
  }
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4700
  moreover
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4701
  {
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4702
    assume "cx + cy > 0"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4703
    then have "(cx / (cx + cy)) *\<^sub>R xx + (cy / (cx + cy)) *\<^sub>R yy \<in> S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4704
      using assms mem_convex_alt[of S xx yy cx cy] x y by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4705
    then have "cx *\<^sub>R xx + cy *\<^sub>R yy \<in> cone hull S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4706
      using mem_cone_hull[of "(cx/(cx+cy)) *\<^sub>R xx + (cy/(cx+cy)) *\<^sub>R yy" S "cx+cy"] `cx+cy>0`
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4707
      by (auto simp add: scaleR_right_distrib)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4708
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4709
      using x y by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4710
  }
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4711
  moreover have "cx + cy \<le> 0 \<or> cx + cy > 0" by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  4712
  ultimately show "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S" by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4713
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4714
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4715
lemma cone_convex_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4716
  assumes "cone S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4717
  shows "cone (convex hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4718
proof (cases "S = {}")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4719
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4720
  then show ?thesis by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4721
next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4722
  case False
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  4723
  then have *: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` S = S)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  4724
    using cone_iff[of S] assms by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4725
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4726
    fix c :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4727
    assume "c > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4728
    then have "op *\<^sub>R c ` (convex hull S) = convex hull (op *\<^sub>R c ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4729
      using convex_hull_scaling[of _ S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4730
    also have "\<dots> = convex hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4731
      using * `c > 0` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4732
    finally have "op *\<^sub>R c ` (convex hull S) = convex hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4733
      by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4734
  }
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4735
  then have "0 \<in> convex hull S" "\<And>c. c > 0 \<Longrightarrow> (op *\<^sub>R c ` (convex hull S)) = (convex hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4736
    using * hull_subset[of S convex] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4737
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4738
    using `S \<noteq> {}` cone_iff[of "convex hull S"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4739
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4740
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  4741
subsection {* Convex set as intersection of halfspaces *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4742
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4743
lemma convex_halfspace_intersection:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  4744
  fixes s :: "('a::euclidean_space) set"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4745
  assumes "closed s" "convex s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4746
  shows "s = \<Inter> {h. s \<subseteq> h \<and> (\<exists>a b. h = {x. inner a x \<le> b})}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4747
  apply (rule set_eqI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4748
  apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4749
  unfolding Inter_iff Ball_def mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4750
  apply (rule,rule,erule conjE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4751
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  4752
  fix x
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4753
  assume "\<forall>xa. s \<subseteq> xa \<and> (\<exists>a b. xa = {x. inner a x \<le> b}) \<longrightarrow> x \<in> xa"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4754
  then have "\<forall>a b. s \<subseteq> {x. inner a x \<le> b} \<longrightarrow> x \<in> {x. inner a x \<le> b}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4755
    by blast
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4756
  then show "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4757
    apply (rule_tac ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4758
    apply (drule separating_hyperplane_closed_point[OF assms(2,1)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4759
    apply (erule exE)+
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4760
    apply (erule_tac x="-a" in allE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4761
    apply (erule_tac x="-b" in allE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4762
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4763
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4764
qed auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4765
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4766
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  4767
subsection {* Radon's theorem (from Lars Schewe) *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4768
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4769
lemma radon_ex_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4770
  assumes "finite c" "affine_dependent c"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4771
  shows "\<exists>u. setsum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> setsum (\<lambda>v. u v *\<^sub>R v) c = 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4772
proof -
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4773
  from assms(2)[unfolded affine_dependent_explicit]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4774
  obtain s u where
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4775
      "finite s" "s \<subseteq> c" "setsum u s = 0" "\<exists>v\<in>s. u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4776
    by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4777
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4778
    apply (rule_tac x="\<lambda>v. if v\<in>s then u v else 0" in exI)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  4779
    unfolding if_smult scaleR_zero_left and setsum.inter_restrict[OF assms(1), symmetric]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4780
    apply (auto simp add: Int_absorb1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4781
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4782
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4783
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4784
lemma radon_s_lemma:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4785
  assumes "finite s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4786
    and "setsum f s = (0::real)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4787
  shows "setsum f {x\<in>s. 0 < f x} = - setsum f {x\<in>s. f x < 0}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4788
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4789
  have *: "\<And>x. (if f x < 0 then f x else 0) + (if 0 < f x then f x else 0) = f x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4790
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4791
  show ?thesis
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  4792
    unfolding real_add_eq_0_iff[symmetric] and setsum.inter_filter[OF assms(1)]
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  4793
      and setsum.distrib[symmetric] and *
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4794
    using assms(2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4795
    apply assumption
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4796
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4797
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4798
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4799
lemma radon_v_lemma:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4800
  assumes "finite s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4801
    and "setsum f s = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4802
    and "\<forall>x. g x = (0::real) \<longrightarrow> f x = (0::'a::euclidean_space)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4803
  shows "(setsum f {x\<in>s. 0 < g x}) = - setsum f {x\<in>s. g x < 0}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4804
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4805
  have *: "\<And>x. (if 0 < g x then f x else 0) + (if g x < 0 then f x else 0) = f x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4806
    using assms(3) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4807
  show ?thesis
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  4808
    unfolding eq_neg_iff_add_eq_0 and setsum.inter_filter[OF assms(1)]
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  4809
      and setsum.distrib[symmetric] and *
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4810
    using assms(2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4811
    apply assumption
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4812
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4813
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4814
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4815
lemma radon_partition:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4816
  assumes "finite c" "affine_dependent c"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4817
  shows "\<exists>m p. m \<inter> p = {} \<and> m \<union> p = c \<and> (convex hull m) \<inter> (convex hull p) \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4818
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4819
  obtain u v where uv: "setsum u c = 0" "v\<in>c" "u v \<noteq> 0"  "(\<Sum>v\<in>c. u v *\<^sub>R v) = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4820
    using radon_ex_lemma[OF assms] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4821
  have fin: "finite {x \<in> c. 0 < u x}" "finite {x \<in> c. 0 > u x}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4822
    using assms(1) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4823
  def z \<equiv> "inverse (setsum u {x\<in>c. u x > 0}) *\<^sub>R setsum (\<lambda>x. u x *\<^sub>R x) {x\<in>c. u x > 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4824
  have "setsum u {x \<in> c. 0 < u x} \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4825
  proof (cases "u v \<ge> 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4826
    case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4827
    then have "u v < 0" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4828
    then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4829
    proof (cases "\<exists>w\<in>{x \<in> c. 0 < u x}. u w > 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4830
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4831
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4832
        using setsum_nonneg_eq_0_iff[of _ u, OF fin(1)] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4833
    next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4834
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4835
      then have "setsum u c \<le> setsum (\<lambda>x. if x=v then u v else 0) c"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4836
        apply (rule_tac setsum_mono)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4837
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4838
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4839
      then show ?thesis
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  4840
        unfolding setsum.delta[OF assms(1)] using uv(2) and `u v < 0` and uv(1) by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4841
    qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4842
  qed (insert setsum_nonneg_eq_0_iff[of _ u, OF fin(1)] uv(2-3), auto)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4843
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4844
  then have *: "setsum u {x\<in>c. u x > 0} > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4845
    unfolding less_le
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4846
    apply (rule_tac conjI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4847
    apply (rule_tac setsum_nonneg)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4848
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4849
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4850
  moreover have "setsum u ({x \<in> c. 0 < u x} \<union> {x \<in> c. u x < 0}) = setsum u c"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4851
    "(\<Sum>x\<in>{x \<in> c. 0 < u x} \<union> {x \<in> c. u x < 0}. u x *\<^sub>R x) = (\<Sum>x\<in>c. u x *\<^sub>R x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4852
    using assms(1)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  4853
    apply (rule_tac[!] setsum.mono_neutral_left)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4854
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4855
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4856
  then have "setsum u {x \<in> c. 0 < u x} = - setsum u {x \<in> c. 0 > u x}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4857
    "(\<Sum>x\<in>{x \<in> c. 0 < u x}. u x *\<^sub>R x) = - (\<Sum>x\<in>{x \<in> c. 0 > u x}. u x *\<^sub>R x)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4858
    unfolding eq_neg_iff_add_eq_0
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4859
    using uv(1,4)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  4860
    by (auto simp add: setsum.union_inter_neutral[OF fin, symmetric])
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4861
  moreover have "\<forall>x\<in>{v \<in> c. u v < 0}. 0 \<le> inverse (setsum u {x \<in> c. 0 < u x}) * - u x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4862
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4863
    apply (rule mult_nonneg_nonneg)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4864
    using *
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4865
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4866
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4867
  ultimately have "z \<in> convex hull {v \<in> c. u v \<le> 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4868
    unfolding convex_hull_explicit mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4869
    apply (rule_tac x="{v \<in> c. u v < 0}" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4870
    apply (rule_tac x="\<lambda>y. inverse (setsum u {x\<in>c. u x > 0}) * - u y" in exI)
49530
wenzelm
parents: 49529
diff changeset
  4871
    using assms(1) unfolding scaleR_scaleR[symmetric] scaleR_right.setsum [symmetric] and z_def
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4872
    apply (auto simp add: setsum_negf setsum_right_distrib[symmetric])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4873
    done
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4874
  moreover have "\<forall>x\<in>{v \<in> c. 0 < u v}. 0 \<le> inverse (setsum u {x \<in> c. 0 < u x}) * u x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4875
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4876
    apply (rule mult_nonneg_nonneg)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4877
    using *
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4878
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4879
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4880
  then have "z \<in> convex hull {v \<in> c. u v > 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4881
    unfolding convex_hull_explicit mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4882
    apply (rule_tac x="{v \<in> c. 0 < u v}" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4883
    apply (rule_tac x="\<lambda>y. inverse (setsum u {x\<in>c. u x > 0}) * u y" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4884
    using assms(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4885
    unfolding scaleR_scaleR[symmetric] scaleR_right.setsum [symmetric] and z_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4886
    using *
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4887
    apply (auto simp add: setsum_negf setsum_right_distrib[symmetric])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4888
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4889
  ultimately show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4890
    apply (rule_tac x="{v\<in>c. u v \<le> 0}" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4891
    apply (rule_tac x="{v\<in>c. u v > 0}" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4892
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4893
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4894
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4895
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4896
lemma radon:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4897
  assumes "affine_dependent c"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4898
  obtains m p where "m \<subseteq> c" "p \<subseteq> c" "m \<inter> p = {}" "(convex hull m) \<inter> (convex hull p) \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4899
proof -
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4900
  from assms[unfolded affine_dependent_explicit]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4901
  obtain s u where
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4902
      "finite s" "s \<subseteq> c" "setsum u s = 0" "\<exists>v\<in>s. u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4903
    by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4904
  then have *: "finite s" "affine_dependent s" and s: "s \<subseteq> c"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4905
    unfolding affine_dependent_explicit by auto
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4906
  from radon_partition[OF *]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4907
  obtain m p where "m \<inter> p = {}" "m \<union> p = s" "convex hull m \<inter> convex hull p \<noteq> {}"
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  4908
    by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4909
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4910
    apply (rule_tac that[of p m])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4911
    using s
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4912
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4913
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4914
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4915
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4916
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  4917
subsection {* Helly's theorem *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4918
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4919
lemma helly_induct:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4920
  fixes f :: "'a::euclidean_space set set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4921
  assumes "card f = n"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4922
    and "n \<ge> DIM('a) + 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4923
    and "\<forall>s\<in>f. convex s" "\<forall>t\<subseteq>f. card t = DIM('a) + 1 \<longrightarrow> \<Inter> t \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4924
  shows "\<Inter>f \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4925
  using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4926
proof (induct n arbitrary: f)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4927
  case 0
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4928
  then show ?case by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4929
next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4930
  case (Suc n)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4931
  have "finite f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4932
    using `card f = Suc n` by (auto intro: card_ge_0_finite)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4933
  show "\<Inter>f \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4934
    apply (cases "n = DIM('a)")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4935
    apply (rule Suc(5)[rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4936
    unfolding `card f = Suc n`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4937
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4938
    assume ng: "n \<noteq> DIM('a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4939
    then have "\<exists>X. \<forall>s\<in>f. X s \<in> \<Inter>(f - {s})"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4940
      apply (rule_tac bchoice)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4941
      unfolding ex_in_conv
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4942
      apply (rule, rule Suc(1)[rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4943
      unfolding card_Diff_singleton_if[OF `finite f`] `card f = Suc n`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4944
      defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4945
      defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4946
      apply (rule Suc(4)[rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4947
      defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4948
      apply (rule Suc(5)[rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4949
      using Suc(3) `finite f`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4950
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4951
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4952
    then obtain X where X: "\<forall>s\<in>f. X s \<in> \<Inter>(f - {s})" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4953
    show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4954
    proof (cases "inj_on X f")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4955
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4956
      then obtain s t where st: "s\<noteq>t" "s\<in>f" "t\<in>f" "X s = X t"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4957
        unfolding inj_on_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4958
      then have *: "\<Inter>f = \<Inter>(f - {s}) \<inter> \<Inter>(f - {t})" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4959
      show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4960
        unfolding *
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4961
        unfolding ex_in_conv[symmetric]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4962
        apply (rule_tac x="X s" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4963
        apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4964
        apply (rule X[rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4965
        using X st
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4966
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4967
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4968
    next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4969
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4970
      then obtain m p where mp: "m \<inter> p = {}" "m \<union> p = X ` f" "convex hull m \<inter> convex hull p \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4971
        using radon_partition[of "X ` f"] and affine_dependent_biggerset[of "X ` f"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4972
        unfolding card_image[OF True] and `card f = Suc n`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4973
        using Suc(3) `finite f` and ng
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4974
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4975
      have "m \<subseteq> X ` f" "p \<subseteq> X ` f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4976
        using mp(2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4977
      then obtain g h where gh:"m = X ` g" "p = X ` h" "g \<subseteq> f" "h \<subseteq> f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4978
        unfolding subset_image_iff by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4979
      then have "f \<union> (g \<union> h) = f" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4980
      then have f: "f = g \<union> h"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4981
        using inj_on_Un_image_eq_iff[of X f "g \<union> h"] and True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4982
        unfolding mp(2)[unfolded image_Un[symmetric] gh]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4983
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4984
      have *: "g \<inter> h = {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4985
        using mp(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4986
        unfolding gh
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4987
        using inj_on_image_Int[OF True gh(3,4)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4988
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4989
      have "convex hull (X ` h) \<subseteq> \<Inter>g" "convex hull (X ` g) \<subseteq> \<Inter>h"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4990
        apply (rule_tac [!] hull_minimal)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4991
        using Suc gh(3-4)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4992
        unfolding subset_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4993
        apply (rule_tac [2] convex_Inter, rule_tac [4] convex_Inter)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4994
        apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4995
        prefer 3
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4996
        apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4997
      proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4998
        fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4999
        assume "x \<in> X ` g"
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5000
        then obtain y where "y \<in> g" "x = X y"
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5001
          unfolding image_iff ..
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5002
        then show "x \<in> \<Inter>h"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5003
          using X[THEN bspec[where x=y]] using * f by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5004
      next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5005
        fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5006
        assume "x \<in> X ` h"
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5007
        then obtain y where "y \<in> h" "x = X y"
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5008
          unfolding image_iff ..
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5009
        then show "x \<in> \<Inter>g"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5010
          using X[THEN bspec[where x=y]] using * f by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5011
      qed auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5012
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5013
        unfolding f using mp(3)[unfolded gh] by blast
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5014
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5015
  qed auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5016
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5017
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5018
lemma helly:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5019
  fixes f :: "'a::euclidean_space set set"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5020
  assumes "card f \<ge> DIM('a) + 1" "\<forall>s\<in>f. convex s"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5021
    and "\<forall>t\<subseteq>f. card t = DIM('a) + 1 \<longrightarrow> \<Inter> t \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5022
  shows "\<Inter>f \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5023
  apply (rule helly_induct)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5024
  using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5025
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5026
  done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5027
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5028
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5029
subsection {* Homeomorphism of all convex compact sets with nonempty interior *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5030
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5031
lemma compact_frontier_line_lemma:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5032
  fixes s :: "'a::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5033
  assumes "compact s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5034
    and "0 \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5035
    and "x \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5036
  obtains u where "0 \<le> u" and "(u *\<^sub>R x) \<in> frontier s" "\<forall>v>u. (v *\<^sub>R x) \<notin> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5037
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5038
  obtain b where b: "b > 0" "\<forall>x\<in>s. norm x \<le> b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5039
    using compact_imp_bounded[OF assms(1), unfolded bounded_pos] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5040
  let ?A = "{y. \<exists>u. 0 \<le> u \<and> u \<le> b / norm(x) \<and> (y = u *\<^sub>R x)}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5041
  have A: "?A = (\<lambda>u. u *\<^sub>R x) ` {0 .. b / norm x}"
36431
340755027840 move definitions and theorems for type real^1 to separate theory file
huffman
parents: 36365
diff changeset
  5042
    by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5043
  have *: "\<And>x A B. x\<in>A \<Longrightarrow> x\<in>B \<Longrightarrow> A\<inter>B \<noteq> {}" by blast
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5044
  have "compact ?A"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5045
    unfolding A
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5046
    apply (rule compact_continuous_image)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5047
    apply (rule continuous_at_imp_continuous_on)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5048
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5049
    apply (intro continuous_intros)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5050
    apply (rule compact_Icc)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5051
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5052
  moreover have "{y. \<exists>u\<ge>0. u \<le> b / norm x \<and> y = u *\<^sub>R x} \<inter> s \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5053
    apply(rule *[OF _ assms(2)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5054
    unfolding mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5055
    using `b > 0` assms(3)
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  5056
    apply auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5057
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5058
  ultimately obtain u y where obt: "u\<ge>0" "u \<le> b / norm x" "y = u *\<^sub>R x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5059
    "y \<in> ?A" "y \<in> s" "\<forall>z\<in>?A \<inter> s. dist 0 z \<le> dist 0 y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5060
    using distance_attains_sup[OF compact_inter[OF _ assms(1), of ?A], of 0]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5061
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5062
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5063
  have "norm x > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5064
    using assms(3)[unfolded zero_less_norm_iff[symmetric]] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5065
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5066
    fix v
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5067
    assume as: "v > u" "v *\<^sub>R x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5068
    then have "v \<le> b / norm x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5069
      using b(2)[rule_format, OF as(2)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5070
      using `u\<ge>0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5071
      unfolding pos_le_divide_eq[OF `norm x > 0`]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5072
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5073
    then have "norm (v *\<^sub>R x) \<le> norm y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5074
      apply (rule_tac obt(6)[rule_format, unfolded dist_0_norm])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5075
      apply (rule IntI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5076
      defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5077
      apply (rule as(2))
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5078
      unfolding mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5079
      apply (rule_tac x=v in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5080
      using as(1) `u\<ge>0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5081
      apply (auto simp add: field_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5082
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5083
    then have False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5084
      unfolding obt(3) using `u\<ge>0` `norm x > 0` `v > u`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5085
      by (auto simp add:field_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5086
  } note u_max = this
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5087
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5088
  have "u *\<^sub>R x \<in> frontier s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5089
    unfolding frontier_straddle
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5090
    apply (rule,rule,rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5091
    apply (rule_tac x="u *\<^sub>R x" in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5092
    unfolding obt(3)[symmetric]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5093
    prefer 3
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5094
    apply (rule_tac x="(u + (e / 2) / norm x) *\<^sub>R x" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5095
    apply (rule, rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5096
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5097
    fix e
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5098
    assume "e > 0" and as: "(u + e / 2 / norm x) *\<^sub>R x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5099
    then have "u + e / 2 / norm x > u"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  5100
      using `norm x > 0` by (auto simp del:zero_less_norm_iff)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5101
    then show False using u_max[OF _ as] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5102
  qed (insert `y\<in>s`, auto simp add: dist_norm scaleR_left_distrib obt(3))
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5103
  then show ?thesis by(metis that[of u] u_max obt(1))
36071
c8ae8e56d42e tuned many proofs a bit
nipkow
parents: 35577
diff changeset
  5104
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5105
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5106
lemma starlike_compact_projective:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5107
  assumes "compact s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5108
    and "cball (0::'a::euclidean_space) 1 \<subseteq> s "
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5109
    and "\<forall>x\<in>s. \<forall>u. 0 \<le> u \<and> u < 1 \<longrightarrow> u *\<^sub>R x \<in> s - frontier s"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5110
  shows "s homeomorphic (cball (0::'a::euclidean_space) 1)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5111
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5112
  have fs: "frontier s \<subseteq> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5113
    apply (rule frontier_subset_closed)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5114
    using compact_imp_closed[OF assms(1)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5115
    apply simp
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5116
    done
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5117
  def pi \<equiv> "\<lambda>x::'a. inverse (norm x) *\<^sub>R x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5118
  have "0 \<notin> frontier s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5119
    unfolding frontier_straddle
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5120
    apply (rule notI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5121
    apply (erule_tac x=1 in allE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5122
    using assms(2)[unfolded subset_eq Ball_def mem_cball]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5123
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5124
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5125
  have injpi: "\<And>x y. pi x = pi y \<and> norm x = norm y \<longleftrightarrow> x = y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5126
    unfolding pi_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5127
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5128
  have contpi: "continuous_on (UNIV - {0}) pi"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5129
    apply (rule continuous_at_imp_continuous_on)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5130
    apply rule unfolding pi_def
44647
e4de7750cdeb modernize lemmas about 'continuous' and 'continuous_on';
huffman
parents: 44629
diff changeset
  5131
    apply (intro continuous_intros)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5132
    apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5133
    done
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5134
  def sphere \<equiv> "{x::'a. norm x = 1}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5135
  have pi: "\<And>x. x \<noteq> 0 \<Longrightarrow> pi x \<in> sphere" "\<And>x u. u>0 \<Longrightarrow> pi (u *\<^sub>R x) = pi x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5136
    unfolding pi_def sphere_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5137
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5138
  have "0 \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5139
    using assms(2) and centre_in_cball[of 0 1] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5140
  have front_smul: "\<forall>x\<in>frontier s. \<forall>u\<ge>0. u *\<^sub>R x \<in> s \<longleftrightarrow> u \<le> 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5141
  proof (rule,rule,rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5142
    fix x and u :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5143
    assume x: "x \<in> frontier s" and "0 \<le> u"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5144
    then have "x \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5145
      using `0 \<notin> frontier s` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5146
    obtain v where v: "0 \<le> v" "v *\<^sub>R x \<in> frontier s" "\<forall>w>v. w *\<^sub>R x \<notin> s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5147
      using compact_frontier_line_lemma[OF assms(1) `0\<in>s` `x\<noteq>0`] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5148
    have "v = 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5149
      apply (rule ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5150
      unfolding neq_iff
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5151
      apply (erule disjE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5152
    proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5153
      assume "v < 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5154
      then show False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5155
        using v(3)[THEN spec[where x=1]] using x and fs by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5156
    next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5157
      assume "v > 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5158
      then show False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5159
        using assms(3)[THEN bspec[where x="v *\<^sub>R x"], THEN spec[where x="inverse v"]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5160
        using v and x and fs
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5161
        unfolding inverse_less_1_iff by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5162
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5163
    show "u *\<^sub>R x \<in> s \<longleftrightarrow> u \<le> 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5164
      apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5165
      using v(3)[unfolded `v=1`, THEN spec[where x=u]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5166
    proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5167
      assume "u \<le> 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5168
      then show "u *\<^sub>R x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5169
      apply (cases "u = 1")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5170
        using assms(3)[THEN bspec[where x=x], THEN spec[where x=u]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5171
        using `0\<le>u` and x and fs
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5172
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5173
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5174
    qed auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5175
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5176
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5177
  have "\<exists>surf. homeomorphism (frontier s) sphere pi surf"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5178
    apply (rule homeomorphism_compact)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5179
    apply (rule compact_frontier[OF assms(1)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5180
    apply (rule continuous_on_subset[OF contpi])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5181
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5182
    apply (rule set_eqI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5183
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5184
    unfolding inj_on_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5185
    prefer 3
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5186
    apply(rule,rule,rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5187
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5188
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5189
    assume "x \<in> pi ` frontier s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5190
    then obtain y where "y \<in> frontier s" "x = pi y" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5191
    then show "x \<in> sphere"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5192
      using pi(1)[of y] and `0 \<notin> frontier s` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5193
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5194
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5195
    assume "x \<in> sphere"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5196
    then have "norm x = 1" "x \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5197
      unfolding sphere_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5198
    then obtain u where "0 \<le> u" "u *\<^sub>R x \<in> frontier s" "\<forall>v>u. v *\<^sub>R x \<notin> s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5199
      using compact_frontier_line_lemma[OF assms(1) `0\<in>s`, of x] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5200
    then show "x \<in> pi ` frontier s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5201
      unfolding image_iff le_less pi_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5202
      apply (rule_tac x="u *\<^sub>R x" in bexI)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5203
      using `norm x = 1` `0 \<notin> frontier s`
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5204
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5205
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5206
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5207
    fix x y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5208
    assume as: "x \<in> frontier s" "y \<in> frontier s" "pi x = pi y"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5209
    then have xys: "x \<in> s" "y \<in> s"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5210
      using fs by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5211
    from as(1,2) have nor: "norm x \<noteq> 0" "norm y \<noteq> 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5212
      using `0\<notin>frontier s` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5213
    from nor have x: "x = norm x *\<^sub>R ((inverse (norm y)) *\<^sub>R y)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5214
      unfolding as(3)[unfolded pi_def, symmetric] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5215
    from nor have y: "y = norm y *\<^sub>R ((inverse (norm x)) *\<^sub>R x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5216
      unfolding as(3)[unfolded pi_def] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5217
    have "0 \<le> norm y * inverse (norm x)" and "0 \<le> norm x * inverse (norm y)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5218
      using nor
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5219
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5220
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5221
    then have "norm x = norm y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5222
      apply -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5223
      apply (rule ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5224
      unfolding neq_iff
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5225
      using x y and front_smul[THEN bspec, OF as(1), THEN spec[where x="norm y * (inverse (norm x))"]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5226
      using front_smul[THEN bspec, OF as(2), THEN spec[where x="norm x * (inverse (norm y))"]]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5227
      using xys nor
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  5228
      apply (auto simp add: field_simps)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5229
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5230
    then show "x = y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5231
      apply (subst injpi[symmetric])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5232
      using as(3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5233
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5234
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5235
  qed (insert `0 \<notin> frontier s`, auto)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5236
  then obtain surf where
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5237
    surf: "\<forall>x\<in>frontier s. surf (pi x) = x"  "pi ` frontier s = sphere" "continuous_on (frontier s) pi"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5238
    "\<forall>y\<in>sphere. pi (surf y) = y" "surf ` sphere = frontier s" "continuous_on sphere surf"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5239
    unfolding homeomorphism_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5240
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5241
  have cont_surfpi: "continuous_on (UNIV -  {0}) (surf \<circ> pi)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5242
    apply (rule continuous_on_compose)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5243
    apply (rule contpi)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5244
    apply (rule continuous_on_subset[of sphere])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5245
    apply (rule surf(6))
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5246
    using pi(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5247
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5248
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5249
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5250
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5251
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5252
    assume as: "x \<in> cball (0::'a) 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5253
    have "norm x *\<^sub>R surf (pi x) \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5254
    proof (cases "x=0 \<or> norm x = 1")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5255
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5256
      then have "pi x \<in> sphere" "norm x < 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5257
        using pi(1)[of x] as by(auto simp add: dist_norm)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5258
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5259
        apply (rule_tac assms(3)[rule_format, THEN DiffD1])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5260
        apply (rule_tac fs[unfolded subset_eq, rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5261
        unfolding surf(5)[symmetric]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5262
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5263
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5264
    next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5265
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5266
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5267
        apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5268
        defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5269
        unfolding pi_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5270
        apply (rule fs[unfolded subset_eq, rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5271
        unfolding surf(5)[unfolded sphere_def, symmetric]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5272
        using `0\<in>s`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5273
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5274
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5275
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5276
  } note hom = this
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5277
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5278
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5279
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5280
    assume "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5281
    then have "x \<in> (\<lambda>x. norm x *\<^sub>R surf (pi x)) ` cball 0 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5282
    proof (cases "x = 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5283
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5284
      show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5285
        unfolding image_iff True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5286
        apply (rule_tac x=0 in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5287
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5288
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5289
    next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5290
      let ?a = "inverse (norm (surf (pi x)))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5291
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5292
      then have invn: "inverse (norm x) \<noteq> 0" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5293
      from False have pix: "pi x\<in>sphere" using pi(1) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5294
      then have "pi (surf (pi x)) = pi x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5295
        apply (rule_tac surf(4)[rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5296
        apply assumption
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5297
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5298
      then have **: "norm x *\<^sub>R (?a *\<^sub>R surf (pi x)) = x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5299
        apply (rule_tac scaleR_left_imp_eq[OF invn])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5300
        unfolding pi_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5301
        using invn
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5302
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5303
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5304
      then have *: "?a * norm x > 0" and "?a > 0" "?a \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5305
        using surf(5) `0\<notin>frontier s`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5306
        apply -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5307
        apply (rule mult_pos_pos)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5308
        using False[unfolded zero_less_norm_iff[symmetric]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5309
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5310
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5311
      have "norm (surf (pi x)) \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5312
        using ** False by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5313
      then have "norm x = norm ((?a * norm x) *\<^sub>R surf (pi x))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5314
        unfolding norm_scaleR abs_mult abs_norm_cancel abs_of_pos[OF `?a > 0`] by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  5315
      moreover have "pi x = pi ((inverse (norm (surf (pi x))) * norm x) *\<^sub>R surf (pi x))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5316
        unfolding pi(2)[OF *] surf(4)[rule_format, OF pix] ..
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5317
      moreover have "surf (pi x) \<in> frontier s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5318
        using surf(5) pix by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5319
      then have "dist 0 (inverse (norm (surf (pi x))) *\<^sub>R x) \<le> 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5320
        unfolding dist_norm
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5321
        using ** and *
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5322
        using front_smul[THEN bspec[where x="surf (pi x)"], THEN spec[where x="norm x * ?a"]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5323
        using False `x\<in>s`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5324
        by (auto simp add: field_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5325
      ultimately show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5326
        unfolding image_iff
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5327
        apply (rule_tac x="inverse (norm (surf(pi x))) *\<^sub>R x" in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5328
        apply (subst injpi[symmetric])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5329
        unfolding abs_mult abs_norm_cancel abs_of_pos[OF `?a > 0`]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5330
        unfolding pi(2)[OF `?a > 0`]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5331
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5332
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5333
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5334
  } note hom2 = this
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5335
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5336
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5337
    apply (subst homeomorphic_sym)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5338
    apply (rule homeomorphic_compact[where f="\<lambda>x. norm x *\<^sub>R surf (pi x)"])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5339
    apply (rule compact_cball)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5340
    defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5341
    apply (rule set_eqI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5342
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5343
    apply (erule imageE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5344
    apply (drule hom)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5345
    prefer 4
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5346
    apply (rule continuous_at_imp_continuous_on)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5347
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5348
    apply (rule_tac [3] hom2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5349
  proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5350
    fix x :: 'a
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5351
    assume as: "x \<in> cball 0 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5352
    then show "continuous (at x) (\<lambda>x. norm x *\<^sub>R surf (pi x))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5353
    proof (cases "x = 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5354
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5355
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5356
        apply (intro continuous_intros)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5357
        using cont_surfpi
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5358
        unfolding continuous_on_eq_continuous_at[OF open_delete[OF open_UNIV]] o_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5359
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5360
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5361
    next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5362
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5363
      obtain B where B: "\<forall>x\<in>s. norm x \<le> B"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5364
        using compact_imp_bounded[OF assms(1)] unfolding bounded_iff by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5365
      then have "B > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5366
        using assms(2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5367
        unfolding subset_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5368
        apply (erule_tac x="SOME i. i\<in>Basis" in ballE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5369
        defer
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5370
        apply (erule_tac x="SOME i. i\<in>Basis" in ballE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5371
        unfolding Ball_def mem_cball dist_norm
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5372
        using DIM_positive[where 'a='a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5373
        apply (auto simp: SOME_Basis)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5374
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5375
      show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5376
        unfolding True continuous_at Lim_at
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5377
        apply(rule,rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5378
        apply(rule_tac x="e / B" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5379
        apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5380
        apply (rule divide_pos_pos)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5381
        prefer 3
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5382
        apply(rule,rule,erule conjE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5383
        unfolding norm_zero scaleR_zero_left dist_norm diff_0_right norm_scaleR abs_norm_cancel
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5384
      proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5385
        fix e and x :: 'a
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5386
        assume as: "norm x < e / B" "0 < norm x" "e > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5387
        then have "surf (pi x) \<in> frontier s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5388
          using pi(1)[of x] unfolding surf(5)[symmetric] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5389
        then have "norm (surf (pi x)) \<le> B"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5390
          using B fs by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5391
        then have "norm x * norm (surf (pi x)) \<le> norm x * B"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5392
          using as(2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5393
        also have "\<dots> < e / B * B"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5394
          apply (rule mult_strict_right_mono)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5395
          using as(1) `B>0`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5396
          apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5397
          done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5398
        also have "\<dots> = e" using `B > 0` by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5399
        finally show "norm x * norm (surf (pi x)) < e" .
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5400
      qed (insert `B>0`, auto)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5401
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5402
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5403
    {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5404
      fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5405
      assume as: "surf (pi x) = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5406
      have "x = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5407
      proof (rule ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5408
        assume "x \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5409
        then have "pi x \<in> sphere"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5410
          using pi(1) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5411
        then have "surf (pi x) \<in> frontier s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5412
          using surf(5) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5413
        then show False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5414
          using `0\<notin>frontier s` unfolding as by simp
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5415
      qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5416
    } note surf_0 = this
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5417
    show "inj_on (\<lambda>x. norm x *\<^sub>R surf (pi x)) (cball 0 1)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5418
      unfolding inj_on_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5419
    proof (rule,rule,rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5420
      fix x y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5421
      assume as: "x \<in> cball 0 1" "y \<in> cball 0 1" "norm x *\<^sub>R surf (pi x) = norm y *\<^sub>R surf (pi y)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5422
      then show "x = y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5423
      proof (cases "x=0 \<or> y=0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5424
        case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5425
        then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5426
          using as by (auto elim: surf_0)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5427
      next
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5428
        case False
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5429
        then have "pi (surf (pi x)) = pi (surf (pi y))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5430
          using as(3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5431
          using pi(2)[of "norm x" "surf (pi x)"] pi(2)[of "norm y" "surf (pi y)"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5432
          by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5433
        moreover have "pi x \<in> sphere" "pi y \<in> sphere"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5434
          using pi(1) False by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5435
        ultimately have *: "pi x = pi y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5436
          using surf(4)[THEN bspec[where x="pi x"]] surf(4)[THEN bspec[where x="pi y"]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5437
          by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5438
        moreover have "norm x = norm y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5439
          using as(3)[unfolded *] using False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5440
          by (auto dest:surf_0)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5441
        ultimately show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5442
          using injpi by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5443
      qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5444
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5445
  qed auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5446
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5447
44519
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5448
lemma homeomorphic_convex_compact_lemma:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5449
  fixes s :: "'a::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5450
  assumes "convex s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5451
    and "compact s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5452
    and "cball 0 1 \<subseteq> s"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5453
  shows "s homeomorphic (cball (0::'a) 1)"
44519
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5454
proof (rule starlike_compact_projective[OF assms(2-3)], clarify)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5455
  fix x u
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5456
  assume "x \<in> s" and "0 \<le> u" and "u < (1::real)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5457
  have "open (ball (u *\<^sub>R x) (1 - u))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5458
    by (rule open_ball)
44519
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5459
  moreover have "u *\<^sub>R x \<in> ball (u *\<^sub>R x) (1 - u)"
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5460
    unfolding centre_in_ball using `u < 1` by simp
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5461
  moreover have "ball (u *\<^sub>R x) (1 - u) \<subseteq> s"
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5462
  proof
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5463
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5464
    assume "y \<in> ball (u *\<^sub>R x) (1 - u)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5465
    then have "dist (u *\<^sub>R x) y < 1 - u"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5466
      unfolding mem_ball .
44519
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5467
    with `u < 1` have "inverse (1 - u) *\<^sub>R (y - u *\<^sub>R x) \<in> cball 0 1"
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5468
      by (simp add: dist_norm inverse_eq_divide norm_minus_commute)
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5469
    with assms(3) have "inverse (1 - u) *\<^sub>R (y - u *\<^sub>R x) \<in> s" ..
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5470
    with assms(1) have "(1 - u) *\<^sub>R ((y - u *\<^sub>R x) /\<^sub>R (1 - u)) + u *\<^sub>R x \<in> s"
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5471
      using `x \<in> s` `0 \<le> u` `u < 1` [THEN less_imp_le] by (rule mem_convex)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5472
    then show "y \<in> s" using `u < 1`
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5473
      by simp
44519
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5474
  qed
ea85d78a994e simplify definition of 'interior';
huffman
parents: 44467
diff changeset
  5475
  ultimately have "u *\<^sub>R x \<in> interior s" ..
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5476
  then show "u *\<^sub>R x \<in> s - frontier s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5477
    using frontier_def and interior_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5478
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5479
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5480
lemma homeomorphic_convex_compact_cball:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5481
  fixes e :: real
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5482
    and s :: "'a::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5483
  assumes "convex s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5484
    and "compact s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5485
    and "interior s \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5486
    and "e > 0"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5487
  shows "s homeomorphic (cball (b::'a) e)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5488
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5489
  obtain a where "a \<in> interior s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5490
    using assms(3) by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5491
  then obtain d where "d > 0" and d: "cball a d \<subseteq> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5492
    unfolding mem_interior_cball by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5493
  let ?d = "inverse d" and ?n = "0::'a"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5494
  have "cball ?n 1 \<subseteq> (\<lambda>x. inverse d *\<^sub>R (x - a)) ` s"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5495
    apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5496
    apply (rule_tac x="d *\<^sub>R x + a" in image_eqI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5497
    defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5498
    apply (rule d[unfolded subset_eq, rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5499
    using `d > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5500
    unfolding mem_cball dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5501
    apply (auto simp add: mult_right_le_one_le)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5502
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5503
  then have "(\<lambda>x. inverse d *\<^sub>R (x - a)) ` s homeomorphic cball ?n 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5504
    using homeomorphic_convex_compact_lemma[of "(\<lambda>x. ?d *\<^sub>R -a + ?d *\<^sub>R x) ` s",
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5505
      OF convex_affinity compact_affinity]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5506
    using assms(1,2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5507
    by (auto simp add: uminus_add_conv_diff scaleR_right_diff_distrib)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5508
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5509
    apply (rule_tac homeomorphic_trans[OF _ homeomorphic_balls(2)[of 1 _ ?n]])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5510
    apply (rule homeomorphic_trans[OF homeomorphic_affinity[of "?d" s "?d *\<^sub>R -a"]])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5511
    using `d>0` `e>0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5512
    apply (auto simp add: uminus_add_conv_diff scaleR_right_diff_distrib)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5513
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5514
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5515
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5516
lemma homeomorphic_convex_compact:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5517
  fixes s :: "'a::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5518
    and t :: "'a set"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5519
  assumes "convex s" "compact s" "interior s \<noteq> {}"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5520
    and "convex t" "compact t" "interior t \<noteq> {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5521
  shows "s homeomorphic t"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5522
  using assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5523
  by (meson zero_less_one homeomorphic_trans homeomorphic_convex_compact_cball homeomorphic_sym)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5524
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5525
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5526
subsection {* Epigraphs of convex functions *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5527
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5528
definition "epigraph s (f :: _ \<Rightarrow> real) = {xy. fst xy \<in> s \<and> f (fst xy) \<le> snd xy}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5529
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5530
lemma mem_epigraph: "(x, y) \<in> epigraph s f \<longleftrightarrow> x \<in> s \<and> f x \<le> y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5531
  unfolding epigraph_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5532
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5533
lemma convex_epigraph: "convex (epigraph s f) \<longleftrightarrow> convex_on s f \<and> convex s"
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5534
  unfolding convex_def convex_on_def
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5535
  unfolding Ball_def split_paired_All epigraph_def
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5536
  unfolding mem_Collect_eq fst_conv snd_conv fst_add snd_add fst_scaleR snd_scaleR Ball_def[symmetric]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5537
  apply safe
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5538
  defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5539
  apply (erule_tac x=x in allE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5540
  apply (erule_tac x="f x" in allE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5541
  apply safe
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5542
  apply (erule_tac x=xa in allE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5543
  apply (erule_tac x="f xa" in allE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5544
  prefer 3
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5545
  apply (rule_tac y="u * f a + v * f aa" in order_trans)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5546
  defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5547
  apply (auto intro!:mult_left_mono add_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5548
  done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5549
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5550
lemma convex_epigraphI: "convex_on s f \<Longrightarrow> convex s \<Longrightarrow> convex (epigraph s f)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5551
  unfolding convex_epigraph by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5552
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5553
lemma convex_epigraph_convex: "convex s \<Longrightarrow> convex_on s f \<longleftrightarrow> convex(epigraph s f)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5554
  by (simp add: convex_epigraph)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5555
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5556
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5557
subsubsection {* Use this to derive general bound property of convex function *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5558
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5559
lemma convex_on:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5560
  assumes "convex s"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5561
  shows "convex_on s f \<longleftrightarrow>
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5562
    (\<forall>k u x. (\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> x i \<in> s) \<and> setsum u {1..k} = 1 \<longrightarrow>
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5563
      f (setsum (\<lambda>i. u i *\<^sub>R x i) {1..k} ) \<le> setsum (\<lambda>i. u i * f(x i)) {1..k})"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5564
  unfolding convex_epigraph_convex[OF assms] convex epigraph_def Ball_def mem_Collect_eq
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5565
  unfolding fst_setsum snd_setsum fst_scaleR snd_scaleR
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5566
  apply safe
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5567
  apply (drule_tac x=k in spec)
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5568
  apply (drule_tac x=u in spec)
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5569
  apply (drule_tac x="\<lambda>i. (x i, f (x i))" in spec)
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5570
  apply simp
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5571
  using assms[unfolded convex]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5572
  apply simp
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5573
  apply (rule_tac y="\<Sum>i = 1..k. u i * f (fst (x i))" in order_trans)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5574
  defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5575
  apply (rule setsum_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5576
  apply (erule_tac x=i in allE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5577
  unfolding real_scaleR_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5578
  apply (rule mult_left_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5579
  using assms[unfolded convex]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5580
  apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5581
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5582
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5583
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5584
subsection {* Convexity of general and special intervals *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5585
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5586
lemma is_interval_convex:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5587
  fixes s :: "'a::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5588
  assumes "is_interval s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5589
  shows "convex s"
37732
6432bf0d7191 generalize type of is_interval to class euclidean_space
huffman
parents: 37673
diff changeset
  5590
proof (rule convexI)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5591
  fix x y and u v :: real
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5592
  assume as: "x \<in> s" "y \<in> s" "0 \<le> u" "0 \<le> v" "u + v = 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5593
  then have *: "u = 1 - v" "1 - v \<ge> 0" and **: "v = 1 - u" "1 - u \<ge> 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5594
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5595
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5596
    fix a b
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5597
    assume "\<not> b \<le> u * a + v * b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5598
    then have "u * a < (1 - v) * b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5599
      unfolding not_le using as(4) by (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5600
    then have "a < b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5601
      unfolding * using as(4) *(2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5602
      apply (rule_tac mult_left_less_imp_less[of "1 - v"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5603
      apply (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5604
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5605
    then have "a \<le> u * a + v * b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5606
      unfolding * using as(4)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5607
      by (auto simp add: field_simps intro!:mult_right_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5608
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5609
  moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5610
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5611
    fix a b
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5612
    assume "\<not> u * a + v * b \<le> a"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5613
    then have "v * b > (1 - u) * a"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5614
      unfolding not_le using as(4) by (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5615
    then have "a < b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5616
      unfolding * using as(4)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5617
      apply (rule_tac mult_left_less_imp_less)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5618
      apply (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5619
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5620
    then have "u * a + v * b \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5621
      unfolding **
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5622
      using **(2) as(3)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5623
      by (auto simp add: field_simps intro!:mult_right_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5624
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5625
  ultimately show "u *\<^sub>R x + v *\<^sub>R y \<in> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5626
    apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5627
    apply (rule assms[unfolded is_interval_def, rule_format, OF as(1,2)])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5628
    using as(3-) DIM_positive[where 'a='a]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5629
    apply (auto simp: inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5630
    done
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5631
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5632
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5633
lemma is_interval_connected:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5634
  fixes s :: "'a::euclidean_space set"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5635
  shows "is_interval s \<Longrightarrow> connected s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5636
  using is_interval_convex convex_connected by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5637
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5638
lemma convex_box: "convex (cbox a b)" "convex (box a (b::'a::euclidean_space))"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5639
  apply (rule_tac[!] is_interval_convex)+
56189
c4daa97ac57a removed dependencies on theory Ordered_Euclidean_Space
immler
parents: 56188
diff changeset
  5640
  using is_interval_box is_interval_cbox
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5641
  apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5642
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5643
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5644
subsection {* On @{text "real"}, @{text "is_interval"}, @{text "convex"} and @{text "connected"} are all equivalent. *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5645
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5646
lemma is_interval_1:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5647
  "is_interval (s::real set) \<longleftrightarrow> (\<forall>a\<in>s. \<forall>b\<in>s. \<forall> x. a \<le> x \<and> x \<le> b \<longrightarrow> x \<in> s)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5648
  unfolding is_interval_def by auto
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5649
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5650
lemma is_interval_connected_1:
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5651
  fixes s :: "real set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5652
  shows "is_interval s \<longleftrightarrow> connected s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5653
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5654
  apply (rule is_interval_connected, assumption)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5655
  unfolding is_interval_1
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5656
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5657
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5658
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5659
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5660
  apply (erule conjE)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5661
  apply (rule ccontr)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5662
proof -
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5663
  fix a b x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5664
  assume as: "connected s" "a \<in> s" "b \<in> s" "a \<le> x" "x \<le> b" "x \<notin> s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5665
  then have *: "a < x" "x < b"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5666
    unfolding not_le [symmetric] by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5667
  let ?halfl = "{..<x} "
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5668
  let ?halfr = "{x<..}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5669
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5670
    fix y
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5671
    assume "y \<in> s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5672
    with `x \<notin> s` have "x \<noteq> y" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5673
    then have "y \<in> ?halfr \<union> ?halfl" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5674
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5675
  moreover have "a \<in> ?halfl" "b \<in> ?halfr" using * by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5676
  then have "?halfl \<inter> s \<noteq> {}" "?halfr \<inter> s \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5677
    using as(2-3) by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5678
  ultimately show False
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5679
    apply (rule_tac notE[OF as(1)[unfolded connected_def]])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5680
    apply (rule_tac x = ?halfl in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5681
    apply (rule_tac x = ?halfr in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5682
    apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5683
    apply (rule open_lessThan)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5684
    apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5685
    apply (rule open_greaterThan)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5686
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5687
    done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5688
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5689
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5690
lemma is_interval_convex_1:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5691
  fixes s :: "real set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5692
  shows "is_interval s \<longleftrightarrow> convex s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5693
  by (metis is_interval_convex convex_connected is_interval_connected_1)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5694
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5695
lemma convex_connected_1:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5696
  fixes s :: "real set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5697
  shows "connected s \<longleftrightarrow> convex s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5698
  by (metis is_interval_convex convex_connected is_interval_connected_1)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5699
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5700
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5701
subsection {* Another intermediate value theorem formulation *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5702
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5703
lemma ivt_increasing_component_on_1:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5704
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5705
  assumes "a \<le> b"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5706
    and "continuous_on (cbox a b) f"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5707
    and "(f a)\<bullet>k \<le> y" "y \<le> (f b)\<bullet>k"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5708
  shows "\<exists>x\<in>cbox a b. (f x)\<bullet>k = y"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5709
proof -
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5710
  have "f a \<in> f ` cbox a b" "f b \<in> f ` cbox a b"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5711
    apply (rule_tac[!] imageI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5712
    using assms(1)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5713
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5714
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5715
  then show ?thesis
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5716
    using connected_ivt_component[of "f ` cbox a b" "f a" "f b" k y]
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5717
    using connected_continuous_image[OF assms(2) convex_connected[OF convex_box(1)]]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5718
    using assms
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5719
    by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5720
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5721
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5722
lemma ivt_increasing_component_1:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5723
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5724
  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>cbox a b. continuous (at x) f \<Longrightarrow>
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5725
    f a\<bullet>k \<le> y \<Longrightarrow> y \<le> f b\<bullet>k \<Longrightarrow> \<exists>x\<in>cbox a b. (f x)\<bullet>k = y"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5726
  by (rule ivt_increasing_component_on_1) (auto simp add: continuous_at_imp_continuous_on)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5727
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5728
lemma ivt_decreasing_component_on_1:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5729
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5730
  assumes "a \<le> b"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5731
    and "continuous_on (cbox a b) f"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5732
    and "(f b)\<bullet>k \<le> y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5733
    and "y \<le> (f a)\<bullet>k"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5734
  shows "\<exists>x\<in>cbox a b. (f x)\<bullet>k = y"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5735
  apply (subst neg_equal_iff_equal[symmetric])
44531
1d477a2b1572 replace some continuous_on lemmas with more general versions
huffman
parents: 44525
diff changeset
  5736
  using ivt_increasing_component_on_1[of a b "\<lambda>x. - f x" k "- y"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5737
  using assms using continuous_on_minus
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5738
  apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5739
  done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5740
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5741
lemma ivt_decreasing_component_1:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5742
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5743
  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>cbox a b. continuous (at x) f \<Longrightarrow>
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5744
    f b\<bullet>k \<le> y \<Longrightarrow> y \<le> f a\<bullet>k \<Longrightarrow> \<exists>x\<in>cbox a b. (f x)\<bullet>k = y"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5745
  by (rule ivt_decreasing_component_on_1) (auto simp: continuous_at_imp_continuous_on)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5746
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5747
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5748
subsection {* A bound within a convex hull, and so an interval *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5749
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5750
lemma convex_on_convex_hull_bound:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5751
  assumes "convex_on (convex hull s) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5752
    and "\<forall>x\<in>s. f x \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5753
  shows "\<forall>x\<in> convex hull s. f x \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5754
proof
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5755
  fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5756
  assume "x \<in> convex hull s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5757
  then obtain k u v where
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5758
    obt: "\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> v i \<in> s" "setsum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R v i) = x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5759
    unfolding convex_hull_indexed mem_Collect_eq by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5760
  have "(\<Sum>i = 1..k. u i * f (v i)) \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5761
    using setsum_mono[of "{1..k}" "\<lambda>i. u i * f (v i)" "\<lambda>i. u i * b"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5762
    unfolding setsum_left_distrib[symmetric] obt(2) mult_1
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5763
    apply (drule_tac meta_mp)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5764
    apply (rule mult_left_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5765
    using assms(2) obt(1)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5766
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5767
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5768
  then show "f x \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5769
    using assms(1)[unfolded convex_on[OF convex_convex_hull], rule_format, of k u v]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5770
    unfolding obt(2-3)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5771
    using obt(1) and hull_subset[unfolded subset_eq, rule_format, of _ s]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5772
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5773
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5774
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5775
lemma inner_setsum_Basis[simp]: "i \<in> Basis \<Longrightarrow> (\<Sum>Basis) \<bullet> i = 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  5776
  by (simp add: inner_setsum_left setsum.If_cases inner_Basis)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5777
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5778
lemma convex_set_plus:
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5779
  assumes "convex s" and "convex t" shows "convex (s + t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5780
proof -
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5781
  have "convex {x + y |x y. x \<in> s \<and> y \<in> t}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5782
    using assms by (rule convex_sums)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5783
  moreover have "{x + y |x y. x \<in> s \<and> y \<in> t} = s + t"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5784
    unfolding set_plus_def by auto
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5785
  finally show "convex (s + t)" .
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5786
qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5787
55929
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  5788
lemma convex_set_setsum:
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  5789
  assumes "\<And>i. i \<in> A \<Longrightarrow> convex (B i)"
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  5790
  shows "convex (\<Sum>i\<in>A. B i)"
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  5791
proof (cases "finite A")
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  5792
  case True then show ?thesis using assms
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  5793
    by induct (auto simp: convex_set_plus)
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  5794
qed auto
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  5795
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5796
lemma finite_set_setsum:
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5797
  assumes "finite A" and "\<forall>i\<in>A. finite (B i)" shows "finite (\<Sum>i\<in>A. B i)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5798
  using assms by (induct set: finite, simp, simp add: finite_set_plus)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5799
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5800
lemma set_setsum_eq:
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5801
  "finite A \<Longrightarrow> (\<Sum>i\<in>A. B i) = {\<Sum>i\<in>A. f i |f. \<forall>i\<in>A. f i \<in> B i}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5802
  apply (induct set: finite)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5803
  apply simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5804
  apply simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5805
  apply (safe elim!: set_plus_elim)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5806
  apply (rule_tac x="fun_upd f x a" in exI)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5807
  apply simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5808
  apply (rule_tac f="\<lambda>x. a + x" in arg_cong)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  5809
  apply (rule setsum.cong [OF refl])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5810
  apply clarsimp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5811
  apply (fast intro: set_plus_intro)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5812
  done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5813
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5814
lemma box_eq_set_setsum_Basis:
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5815
  shows "{x. \<forall>i\<in>Basis. x\<bullet>i \<in> B i} = (\<Sum>i\<in>Basis. image (\<lambda>x. x *\<^sub>R i) (B i))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5816
  apply (subst set_setsum_eq [OF finite_Basis])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5817
  apply safe
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5818
  apply (fast intro: euclidean_representation [symmetric])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5819
  apply (subst inner_setsum_left)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5820
  apply (subgoal_tac "(\<Sum>x\<in>Basis. f x \<bullet> i) = f i \<bullet> i")
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5821
  apply (drule (1) bspec)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5822
  apply clarsimp
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  5823
  apply (frule setsum.remove [OF finite_Basis])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5824
  apply (erule trans)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5825
  apply simp
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  5826
  apply (rule setsum.neutral)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5827
  apply clarsimp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5828
  apply (frule_tac x=i in bspec, assumption)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5829
  apply (drule_tac x=x in bspec, assumption)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5830
  apply clarsimp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5831
  apply (cut_tac u=x and v=i in inner_Basis, assumption+)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5832
  apply (rule ccontr)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5833
  apply simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5834
  done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5835
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5836
lemma convex_hull_set_setsum:
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5837
  "convex hull (\<Sum>i\<in>A. B i) = (\<Sum>i\<in>A. convex hull (B i))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5838
proof (cases "finite A")
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5839
  assume "finite A" then show ?thesis
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5840
    by (induct set: finite, simp, simp add: convex_hull_set_plus)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5841
qed simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5842
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5843
lemma convex_hull_eq_real_cbox:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5844
  fixes x y :: real assumes "x \<le> y"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5845
  shows "convex hull {x, y} = cbox x y"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5846
proof (rule hull_unique)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5847
  show "{x, y} \<subseteq> cbox x y" using `x \<le> y` by auto
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5848
  show "convex (cbox x y)"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5849
    by (rule convex_box)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5850
next
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5851
  fix s assume "{x, y} \<subseteq> s" and "convex s"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5852
  then show "cbox x y \<subseteq> s"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5853
    unfolding is_interval_convex_1 [symmetric] is_interval_def Basis_real_def
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5854
    by - (clarify, simp (no_asm_use), fast)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5855
qed
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5856
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5857
lemma unit_interval_convex_hull:
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57418
diff changeset
  5858
  "cbox (0::'a::euclidean_space) One = convex hull {x. \<forall>i\<in>Basis. (x\<bullet>i = 0) \<or> (x\<bullet>i = 1)}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5859
  (is "?int = convex hull ?points")
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5860
proof -
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5861
  have One[simp]: "\<And>i. i \<in> Basis \<Longrightarrow> One \<bullet> i = 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  5862
    by (simp add: One_def inner_setsum_left setsum.If_cases inner_Basis)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5863
  have "?int = {x. \<forall>i\<in>Basis. x \<bullet> i \<in> cbox 0 1}"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5864
    by (auto simp: cbox_def)
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5865
  also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` cbox 0 1)"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5866
    by (simp only: box_eq_set_setsum_Basis)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5867
  also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` (convex hull {0, 1}))"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5868
    by (simp only: convex_hull_eq_real_cbox zero_le_one)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5869
  also have "\<dots> = (\<Sum>i\<in>Basis. convex hull ((\<lambda>x. x *\<^sub>R i) ` {0, 1}))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5870
    by (simp only: convex_hull_linear_image linear_scaleR_left)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5871
  also have "\<dots> = convex hull (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` {0, 1})"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5872
    by (simp only: convex_hull_set_setsum)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5873
  also have "\<dots> = convex hull {x. \<forall>i\<in>Basis. x\<bullet>i \<in> {0, 1}}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5874
    by (simp only: box_eq_set_setsum_Basis)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5875
  also have "convex hull {x. \<forall>i\<in>Basis. x\<bullet>i \<in> {0, 1}} = convex hull ?points"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5876
    by simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  5877
  finally show ?thesis .
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5878
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5879
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5880
text {* And this is a finite set of vertices. *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5881
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5882
lemma unit_cube_convex_hull:
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5883
  obtains s :: "'a::euclidean_space set"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5884
    where "finite s" and "cbox 0 (\<Sum>Basis) = convex hull s"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5885
  apply (rule that[of "{x::'a. \<forall>i\<in>Basis. x\<bullet>i=0 \<or> x\<bullet>i=1}"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5886
  apply (rule finite_subset[of _ "(\<lambda>s. (\<Sum>i\<in>Basis. (if i\<in>s then 1 else 0) *\<^sub>R i)::'a) ` Pow Basis"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5887
  prefer 3
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5888
  apply (rule unit_interval_convex_hull)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5889
  apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5890
  unfolding mem_Collect_eq
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5891
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5892
  fix x :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5893
  assume as: "\<forall>i\<in>Basis. x \<bullet> i = 0 \<or> x \<bullet> i = 1"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5894
  show "x \<in> (\<lambda>s. \<Sum>i\<in>Basis. (if i\<in>s then 1 else 0) *\<^sub>R i) ` Pow Basis"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5895
    apply (rule image_eqI[where x="{i. i\<in>Basis \<and> x\<bullet>i = 1}"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5896
    using as
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5897
    apply (subst euclidean_eq_iff)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5898
    apply (auto simp: inner_setsum_left_Basis)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5899
    done
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5900
qed auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5901
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5902
text {* Hence any cube (could do any nonempty interval). *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5903
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5904
lemma cube_convex_hull:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5905
  assumes "d > 0"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5906
  obtains s :: "'a::euclidean_space set" where
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5907
    "finite s" and "cbox (x - (\<Sum>i\<in>Basis. d*\<^sub>Ri)) (x + (\<Sum>i\<in>Basis. d*\<^sub>Ri)) = convex hull s"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5908
proof -
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5909
  let ?d = "(\<Sum>i\<in>Basis. d*\<^sub>Ri)::'a"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5910
  have *: "cbox (x - ?d) (x + ?d) = (\<lambda>y. x - ?d + (2 * d) *\<^sub>R y) ` cbox 0 (\<Sum>Basis)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5911
    apply (rule set_eqI, rule)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5912
    unfolding image_iff
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5913
    defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5914
    apply (erule bexE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5915
  proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5916
    fix y
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5917
    assume as: "y\<in>cbox (x - ?d) (x + ?d)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5918
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5919
      fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5920
      assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5921
      have "x \<bullet> i \<le> d + y \<bullet> i" "y \<bullet> i \<le> d + x \<bullet> i"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5922
        using as[unfolded mem_box, THEN bspec[where x=i]] i
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5923
        by (auto simp: inner_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5924
      then have "1 \<ge> inverse d * (x \<bullet> i - y \<bullet> i)" "1 \<ge> inverse d * (y \<bullet> i - x \<bullet> i)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5925
        apply (rule_tac[!] mult_left_le_imp_le[OF _ assms])
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
  5926
        unfolding mult.assoc[symmetric]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5927
        using assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5928
        by (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5929
      then have "inverse d * (x \<bullet> i * 2) \<le> 2 + inverse d * (y \<bullet> i * 2)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5930
        "inverse d * (y \<bullet> i * 2) \<le> 2 + inverse d * (x \<bullet> i * 2)"
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  5931
        using `0<d` by (auto simp add: field_simps) }
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5932
    then have "inverse (2 * d) *\<^sub>R (y - (x - ?d)) \<in> cbox 0 (\<Sum>Basis)"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5933
      unfolding mem_box using assms
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  5934
      by (auto simp add: field_simps inner_simps simp del: inverse_eq_divide)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5935
    then show "\<exists>z\<in>cbox 0 (\<Sum>Basis). y = x - ?d + (2 * d) *\<^sub>R z"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5936
      apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5937
      apply (rule_tac x="inverse (2 * d) *\<^sub>R (y - (x - ?d))" in bexI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5938
      using assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5939
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5940
      done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5941
  next
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5942
    fix y z
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5943
    assume as: "z\<in>cbox 0 (\<Sum>Basis)" "y = x - ?d + (2*d) *\<^sub>R z"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5944
    have "\<And>i. i\<in>Basis \<Longrightarrow> 0 \<le> d * (z \<bullet> i) \<and> d * (z \<bullet> i) \<le> d"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5945
      using assms as(1)[unfolded mem_box]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5946
      apply (erule_tac x=i in ballE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5947
      apply rule
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  5948
      prefer 2
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5949
      apply (rule mult_right_le_one_le)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5950
      using assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5951
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5952
      done
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5953
    then show "y \<in> cbox (x - ?d) (x + ?d)"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5954
      unfolding as(2) mem_box
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5955
      apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5956
      apply rule
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5957
      using as(1)[unfolded mem_box]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5958
      apply (erule_tac x=i in ballE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5959
      using assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5960
      apply (auto simp: inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5961
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5962
  qed
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  5963
  obtain s where "finite s" "cbox 0 (\<Sum>Basis::'a) = convex hull s"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5964
    using unit_cube_convex_hull by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5965
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5966
    apply (rule_tac that[of "(\<lambda>y. x - ?d + (2 * d) *\<^sub>R y)` s"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5967
    unfolding * and convex_hull_affinity
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5968
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5969
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5970
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5971
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5972
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  5973
subsection {* Bounded convex function on open set is continuous *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5974
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5975
lemma convex_on_bounded_continuous:
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  5976
  fixes s :: "('a::real_normed_vector) set"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5977
  assumes "open s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5978
    and "convex_on s f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5979
    and "\<forall>x\<in>s. abs(f x) \<le> b"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5980
  shows "continuous_on s f"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5981
  apply (rule continuous_at_imp_continuous_on)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5982
  unfolding continuous_at_real_range
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5983
proof (rule,rule,rule)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5984
  fix x and e :: real
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5985
  assume "x \<in> s" "e > 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5986
  def B \<equiv> "abs b + 1"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5987
  have B: "0 < B" "\<And>x. x\<in>s \<Longrightarrow> abs (f x) \<le> B"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5988
    unfolding B_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5989
    defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5990
    apply (drule assms(3)[rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5991
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5992
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5993
  obtain k where "k > 0" and k: "cball x k \<subseteq> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5994
    using assms(1)[unfolded open_contains_cball, THEN bspec[where x=x]]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5995
    using `x\<in>s` by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5996
  show "\<exists>d>0. \<forall>x'. norm (x' - x) < d \<longrightarrow> \<bar>f x' - f x\<bar> < e"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5997
    apply (rule_tac x="min (k / 2) (e / (2 * B) * k)" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5998
    apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5999
    defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6000
  proof (rule, rule)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6001
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6002
    assume as: "norm (y - x) < min (k / 2) (e / (2 * B) * k)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6003
    show "\<bar>f y - f x\<bar> < e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6004
    proof (cases "y = x")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6005
      case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6006
      def t \<equiv> "k / norm (y - x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6007
      have "2 < t" "0<t"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6008
        unfolding t_def using as False and `k>0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6009
        by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6010
      have "y \<in> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6011
        apply (rule k[unfolded subset_eq,rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6012
        unfolding mem_cball dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6013
        apply (rule order_trans[of _ "2 * norm (x - y)"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6014
        using as
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6015
        by (auto simp add: field_simps norm_minus_commute)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6016
      {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6017
        def w \<equiv> "x + t *\<^sub>R (y - x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6018
        have "w \<in> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6019
          unfolding w_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6020
          apply (rule k[unfolded subset_eq,rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6021
          unfolding mem_cball dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6022
          unfolding t_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6023
          using `k>0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6024
          apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6025
          done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6026
        have "(1 / t) *\<^sub>R x + - x + ((t - 1) / t) *\<^sub>R x = (1 / t - 1 + (t - 1) / t) *\<^sub>R x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6027
          by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6028
        also have "\<dots> = 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6029
          using `t > 0` by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6030
        finally have w: "(1 / t) *\<^sub>R w + ((t - 1) / t) *\<^sub>R x = y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6031
          unfolding w_def using False and `t > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6032
          by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6033
        have  "2 * B < e * t"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6034
          unfolding t_def using `0 < e` `0 < k` `B > 0` and as and False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6035
          by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6036
        then have "(f w - f x) / t < e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6037
          using B(2)[OF `w\<in>s`] and B(2)[OF `x\<in>s`]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6038
          using `t > 0` by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6039
        then have th1: "f y - f x < e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6040
          apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6041
          apply (rule le_less_trans)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6042
          defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6043
          apply assumption
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6044
          using assms(2)[unfolded convex_on_def,rule_format,of w x "1/t" "(t - 1)/t", unfolded w]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6045
          using `0 < t` `2 < t` and `x \<in> s` `w \<in> s`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6046
          by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6047
      }
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  6048
      moreover
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6049
      {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6050
        def w \<equiv> "x - t *\<^sub>R (y - x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6051
        have "w \<in> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6052
          unfolding w_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6053
          apply (rule k[unfolded subset_eq,rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6054
          unfolding mem_cball dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6055
          unfolding t_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6056
          using `k > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6057
          apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6058
          done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6059
        have "(1 / (1 + t)) *\<^sub>R x + (t / (1 + t)) *\<^sub>R x = (1 / (1 + t) + t / (1 + t)) *\<^sub>R x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6060
          by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6061
        also have "\<dots> = x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6062
          using `t > 0` by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6063
        finally have w: "(1 / (1+t)) *\<^sub>R w + (t / (1 + t)) *\<^sub>R y = x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6064
          unfolding w_def using False and `t > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6065
          by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6066
        have "2 * B < e * t"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6067
          unfolding t_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6068
          using `0 < e` `0 < k` `B > 0` and as and False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6069
          by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6070
        then have *: "(f w - f y) / t < e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6071
          using B(2)[OF `w\<in>s`] and B(2)[OF `y\<in>s`]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6072
          using `t > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6073
          by (auto simp add:field_simps)
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  6074
        have "f x \<le> 1 / (1 + t) * f w + (t / (1 + t)) * f y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6075
          using assms(2)[unfolded convex_on_def,rule_format,of w y "1/(1+t)" "t / (1+t)",unfolded w]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6076
          using `0 < t` `2 < t` and `y \<in> s` `w \<in> s`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6077
          by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6078
        also have "\<dots> = (f w + t * f y) / (1 + t)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6079
          using `t > 0` unfolding divide_inverse by (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6080
        also have "\<dots> < e + f y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6081
          using `t > 0` * `e > 0` by (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6082
        finally have "f x - f y < e" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6083
      }
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  6084
      ultimately show ?thesis by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6085
    qed (insert `0<e`, auto)
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  6086
  qed (insert `0<e` `0<k` `0<B`, auto simp: field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6087
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6088
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6089
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  6090
subsection {* Upper bound on a ball implies upper and lower bounds *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6091
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6092
lemma convex_bounds_lemma:
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6093
  fixes x :: "'a::real_normed_vector"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6094
  assumes "convex_on (cball x e) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6095
    and "\<forall>y \<in> cball x e. f y \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6096
  shows "\<forall>y \<in> cball x e. abs (f y) \<le> b + 2 * abs (f x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6097
  apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6098
proof (cases "0 \<le> e")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6099
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6100
  fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6101
  assume y: "y \<in> cball x e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6102
  def z \<equiv> "2 *\<^sub>R x - y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6103
  have *: "x - (2 *\<^sub>R x - y) = y - x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6104
    by (simp add: scaleR_2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6105
  have z: "z \<in> cball x e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6106
    using y unfolding z_def mem_cball dist_norm * by (auto simp add: norm_minus_commute)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6107
  have "(1 / 2) *\<^sub>R y + (1 / 2) *\<^sub>R z = x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6108
    unfolding z_def by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6109
  then show "\<bar>f y\<bar> \<le> b + 2 * \<bar>f x\<bar>"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6110
    using assms(1)[unfolded convex_on_def,rule_format, OF y z, of "1/2" "1/2"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6111
    using assms(2)[rule_format,OF y] assms(2)[rule_format,OF z]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6112
    by (auto simp add:field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6113
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6114
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6115
  fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6116
  assume "y \<in> cball x e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6117
  then have "dist x y < 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6118
    using False unfolding mem_cball not_le by (auto simp del: dist_not_less_zero)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6119
  then show "\<bar>f y\<bar> \<le> b + 2 * \<bar>f x\<bar>"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6120
    using zero_le_dist[of x y] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6121
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6122
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6123
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  6124
subsubsection {* Hence a convex function on an open set is continuous *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6125
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6126
lemma real_of_nat_ge_one_iff: "1 \<le> real (n::nat) \<longleftrightarrow> 1 \<le> n"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6127
  by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6128
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6129
lemma convex_on_continuous:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6130
  assumes "open (s::('a::euclidean_space) set)" "convex_on s f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6131
  shows "continuous_on s f"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6132
  unfolding continuous_on_eq_continuous_at[OF assms(1)]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6133
proof
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  6134
  note dimge1 = DIM_positive[where 'a='a]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6135
  fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6136
  assume "x \<in> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6137
  then obtain e where e: "cball x e \<subseteq> s" "e > 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6138
    using assms(1) unfolding open_contains_cball by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  6139
  def d \<equiv> "e / real DIM('a)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6140
  have "0 < d"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  6141
    unfolding d_def using `e > 0` dimge1 by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6142
  let ?d = "(\<Sum>i\<in>Basis. d *\<^sub>R i)::'a"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6143
  obtain c
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6144
    where c: "finite c"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6145
    and c1: "convex hull c \<subseteq> cball x e"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6146
    and c2: "cball x d \<subseteq> convex hull c"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6147
  proof
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6148
    def c \<equiv> "\<Sum>i\<in>Basis. (\<lambda>a. a *\<^sub>R i) ` {x\<bullet>i - d, x\<bullet>i + d}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6149
    show "finite c"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6150
      unfolding c_def by (simp add: finite_set_setsum)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6151
    have 1: "convex hull c = {a. \<forall>i\<in>Basis. a \<bullet> i \<in> cbox (x \<bullet> i - d) (x \<bullet> i + d)}"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6152
      unfolding box_eq_set_setsum_Basis
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6153
      unfolding c_def convex_hull_set_setsum
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6154
      apply (subst convex_hull_linear_image [symmetric])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6155
      apply (simp add: linear_iff scaleR_add_left)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6156
      apply (rule setsum.cong [OF refl])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6157
      apply (rule image_cong [OF _ refl])
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6158
      apply (rule convex_hull_eq_real_cbox)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6159
      apply (cut_tac `0 < d`, simp)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6160
      done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6161
    then have 2: "convex hull c = {a. \<forall>i\<in>Basis. a \<bullet> i \<in> cball (x \<bullet> i) d}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6162
      by (simp add: dist_norm abs_le_iff algebra_simps)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6163
    show "cball x d \<subseteq> convex hull c"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6164
      unfolding 2
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6165
      apply clarsimp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6166
      apply (simp only: dist_norm)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6167
      apply (subst inner_diff_left [symmetric])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6168
      apply simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6169
      apply (erule (1) order_trans [OF Basis_le_norm])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6170
      done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6171
    have e': "e = (\<Sum>(i::'a)\<in>Basis. d)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6172
      by (simp add: d_def real_of_nat_def DIM_positive)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6173
    show "convex hull c \<subseteq> cball x e"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6174
      unfolding 2
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6175
      apply clarsimp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6176
      apply (subst euclidean_dist_l2)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6177
      apply (rule order_trans [OF setL2_le_setsum])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6178
      apply (rule zero_le_dist)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6179
      unfolding e'
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6180
      apply (rule setsum_mono)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6181
      apply simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6182
      done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6183
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6184
  def k \<equiv> "Max (f ` c)"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6185
  have "convex_on (convex hull c) f"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6186
    apply(rule convex_on_subset[OF assms(2)])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6187
    apply(rule subset_trans[OF _ e(1)])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6188
    apply(rule c1)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6189
    done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6190
  then have k: "\<forall>y\<in>convex hull c. f y \<le> k"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6191
    apply (rule_tac convex_on_convex_hull_bound)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6192
    apply assumption
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6193
    unfolding k_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6194
    apply (rule, rule Max_ge)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6195
    using c(1)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6196
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6197
    done
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6198
  have "d \<le> e"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6199
    unfolding d_def
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6200
    apply (rule mult_imp_div_pos_le)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6201
    using `e > 0`
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6202
    unfolding mult_le_cancel_left1
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6203
    apply (auto simp: real_of_nat_ge_one_iff Suc_le_eq DIM_positive)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6204
    done
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6205
  then have dsube: "cball x d \<subseteq> cball x e"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6206
    by (rule subset_cball)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6207
  have conv: "convex_on (cball x d) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6208
    apply (rule convex_on_subset)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6209
    apply (rule convex_on_subset[OF assms(2)])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6210
    apply (rule e(1))
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6211
    apply (rule dsube)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6212
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6213
  then have "\<forall>y\<in>cball x d. abs (f y) \<le> k + 2 * abs (f x)"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6214
    apply (rule convex_bounds_lemma)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6215
    apply (rule ballI)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6216
    apply (rule k [rule_format])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6217
    apply (erule rev_subsetD)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6218
    apply (rule c2)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6219
    done
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6220
  then have "continuous_on (ball x d) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6221
    apply (rule_tac convex_on_bounded_continuous)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6222
    apply (rule open_ball, rule convex_on_subset[OF conv])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6223
    apply (rule ball_subset_cball)
33270
paulson
parents: 33175
diff changeset
  6224
    apply force
paulson
parents: 33175
diff changeset
  6225
    done
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6226
  then show "continuous (at x) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6227
    unfolding continuous_on_eq_continuous_at[OF open_ball]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6228
    using `d > 0` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6229
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6230
33270
paulson
parents: 33175
diff changeset
  6231
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  6232
subsection {* Line segments, Starlike Sets, etc. *}
33270
paulson
parents: 33175
diff changeset
  6233
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  6234
(* Use the same overloading tricks as for intervals, so that
33270
paulson
parents: 33175
diff changeset
  6235
   segment[a,b] is closed and segment(a,b) is open relative to affine hull. *)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6236
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6237
definition midpoint :: "'a::real_vector \<Rightarrow> 'a \<Rightarrow> 'a"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6238
  where "midpoint a b = (inverse (2::real)) *\<^sub>R (a + b)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6239
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6240
definition open_segment :: "'a::real_vector \<Rightarrow> 'a \<Rightarrow> 'a set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6241
  where "open_segment a b = {(1 - u) *\<^sub>R a + u *\<^sub>R b | u::real.  0 < u \<and> u < 1}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6242
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6243
definition closed_segment :: "'a::real_vector \<Rightarrow> 'a \<Rightarrow> 'a set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6244
  where "closed_segment a b = {(1 - u) *\<^sub>R a + u *\<^sub>R b | u::real. 0 \<le> u \<and> u \<le> 1}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6245
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6246
definition "between = (\<lambda>(a,b) x. x \<in> closed_segment a b)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6247
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6248
lemmas segment = open_segment_def closed_segment_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6249
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56196
diff changeset
  6250
lemma open_closed_segment: "u \<in> open_segment w z \<Longrightarrow> u \<in> closed_segment w z"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56196
diff changeset
  6251
  by (auto simp add: closed_segment_def open_segment_def)
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56196
diff changeset
  6252
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6253
definition "starlike s \<longleftrightarrow> (\<exists>a\<in>s. \<forall>x\<in>s. closed_segment a x \<subseteq> s)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6254
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6255
lemma midpoint_refl: "midpoint x x = x"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6256
  unfolding midpoint_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6257
  unfolding scaleR_right_distrib
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6258
  unfolding scaleR_left_distrib[symmetric]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6259
  by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6260
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6261
lemma midpoint_sym: "midpoint a b = midpoint b a"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6262
  unfolding midpoint_def by (auto simp add: scaleR_right_distrib)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6263
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6264
lemma midpoint_eq_iff: "midpoint a b = c \<longleftrightarrow> a + b = c + c"
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6265
proof -
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6266
  have "midpoint a b = c \<longleftrightarrow> scaleR 2 (midpoint a b) = scaleR 2 c"
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6267
    by simp
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6268
  then show ?thesis
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6269
    unfolding midpoint_def scaleR_2 [symmetric] by simp
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6270
qed
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6271
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6272
lemma dist_midpoint:
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6273
  fixes a b :: "'a::real_normed_vector" shows
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6274
  "dist a (midpoint a b) = (dist a b) / 2" (is ?t1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6275
  "dist b (midpoint a b) = (dist a b) / 2" (is ?t2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6276
  "dist (midpoint a b) a = (dist a b) / 2" (is ?t3)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6277
  "dist (midpoint a b) b = (dist a b) / 2" (is ?t4)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6278
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6279
  have *: "\<And>x y::'a. 2 *\<^sub>R x = - y \<Longrightarrow> norm x = (norm y) / 2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6280
    unfolding equation_minus_iff by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6281
  have **: "\<And>x y::'a. 2 *\<^sub>R x =   y \<Longrightarrow> norm x = (norm y) / 2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6282
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6283
  note scaleR_right_distrib [simp]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6284
  show ?t1
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6285
    unfolding midpoint_def dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6286
    apply (rule **)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6287
    apply (simp add: scaleR_right_diff_distrib)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6288
    apply (simp add: scaleR_2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6289
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6290
  show ?t2
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6291
    unfolding midpoint_def dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6292
    apply (rule *)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6293
    apply (simp add: scaleR_right_diff_distrib)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6294
    apply (simp add: scaleR_2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6295
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6296
  show ?t3
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6297
    unfolding midpoint_def dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6298
    apply (rule *)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6299
    apply (simp add: scaleR_right_diff_distrib)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6300
    apply (simp add: scaleR_2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6301
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6302
  show ?t4
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6303
    unfolding midpoint_def dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6304
    apply (rule **)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6305
    apply (simp add: scaleR_right_diff_distrib)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6306
    apply (simp add: scaleR_2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6307
    done
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6308
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6309
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6310
lemma midpoint_eq_endpoint:
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6311
  "midpoint a b = a \<longleftrightarrow> a = b"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6312
  "midpoint a b = b \<longleftrightarrow> a = b"
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6313
  unfolding midpoint_eq_iff by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6314
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6315
lemma convex_contains_segment:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6316
  "convex s \<longleftrightarrow> (\<forall>a\<in>s. \<forall>b\<in>s. closed_segment a b \<subseteq> s)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6317
  unfolding convex_alt closed_segment_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6318
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6319
lemma convex_imp_starlike:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6320
  "convex s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> starlike s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6321
  unfolding convex_contains_segment starlike_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6322
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6323
lemma segment_convex_hull:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6324
  "closed_segment a b = convex hull {a,b}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6325
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6326
  have *: "\<And>x. {x} \<noteq> {}" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6327
  have **: "\<And>u v. u + v = 1 \<longleftrightarrow> u = 1 - (v::real)" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6328
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6329
    unfolding segment convex_hull_insert[OF *] convex_hull_singleton
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6330
    apply (rule set_eqI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6331
    unfolding mem_Collect_eq
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6332
    apply (rule, erule exE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6333
    apply (rule_tac x="1 - u" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6334
    apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6335
    defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6336
    apply (rule_tac x=u in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6337
    defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6338
    apply (elim exE conjE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6339
    apply (rule_tac x="1 - u" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6340
    unfolding **
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6341
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6342
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6343
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6344
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6345
lemma convex_segment: "convex (closed_segment a b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6346
  unfolding segment_convex_hull by(rule convex_convex_hull)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6347
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6348
lemma ends_in_segment: "a \<in> closed_segment a b" "b \<in> closed_segment a b"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6349
  unfolding segment_convex_hull
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6350
  apply (rule_tac[!] hull_subset[unfolded subset_eq, rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6351
  apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6352
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6353
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6354
lemma segment_furthest_le:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  6355
  fixes a b x y :: "'a::euclidean_space"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6356
  assumes "x \<in> closed_segment a b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6357
  shows "norm (y - x) \<le> norm (y - a) \<or>  norm (y - x) \<le> norm (y - b)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6358
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6359
  obtain z where "z \<in> {a, b}" "norm (x - y) \<le> norm (z - y)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6360
    using simplex_furthest_le[of "{a, b}" y]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6361
    using assms[unfolded segment_convex_hull]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6362
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6363
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6364
    by (auto simp add:norm_minus_commute)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6365
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6366
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6367
lemma segment_bound:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  6368
  fixes x a b :: "'a::euclidean_space"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6369
  assumes "x \<in> closed_segment a b"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6370
  shows "norm (x - a) \<le> norm (b - a)" "norm (x - b) \<le> norm (b - a)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6371
  using segment_furthest_le[OF assms, of a]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6372
  using segment_furthest_le[OF assms, of b]
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  6373
  by (auto simp add:norm_minus_commute)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6374
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6375
lemma segment_refl: "closed_segment a a = {a}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6376
  unfolding segment by (auto simp add: algebra_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6377
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6378
lemma between_mem_segment: "between (a,b) x \<longleftrightarrow> x \<in> closed_segment a b"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  6379
  unfolding between_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6380
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6381
lemma between: "between (a, b) (x::'a::euclidean_space) \<longleftrightarrow> dist a b = (dist a x) + (dist x b)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6382
proof (cases "a = b")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6383
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6384
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6385
    unfolding between_def split_conv
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6386
    by (auto simp add:segment_refl dist_commute)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6387
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6388
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6389
  then have Fal: "norm (a - b) \<noteq> 0" and Fal2: "norm (a - b) > 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6390
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6391
  have *: "\<And>u. a - ((1 - u) *\<^sub>R a + u *\<^sub>R b) = u *\<^sub>R (a - b)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6392
    by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6393
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6394
    unfolding between_def split_conv closed_segment_def mem_Collect_eq
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6395
    apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6396
    apply (elim exE conjE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6397
    apply (subst dist_triangle_eq)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6398
  proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6399
    fix u
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6400
    assume as: "x = (1 - u) *\<^sub>R a + u *\<^sub>R b" "0 \<le> u" "u \<le> 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6401
    then have *: "a - x = u *\<^sub>R (a - b)" "x - b = (1 - u) *\<^sub>R (a - b)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6402
      unfolding as(1) by (auto simp add:algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6403
    show "norm (a - x) *\<^sub>R (x - b) = norm (x - b) *\<^sub>R (a - x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6404
      unfolding norm_minus_commute[of x a] * using as(2,3)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6405
      by (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6406
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6407
    assume as: "dist a b = dist a x + dist x b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6408
    have "norm (a - x) / norm (a - b) \<le> 1"
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  6409
      using Fal2 unfolding as[unfolded dist_norm] norm_ge_zero by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6410
    then show "\<exists>u. x = (1 - u) *\<^sub>R a + u *\<^sub>R b \<and> 0 \<le> u \<and> u \<le> 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6411
      apply (rule_tac x="dist a x / dist a b" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6412
      unfolding dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6413
      apply (subst euclidean_eq_iff)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6414
      apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6415
      defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6416
      apply rule
56571
f4635657d66f added divide_nonneg_nonneg and co; made it a simp rule
hoelzl
parents: 56544
diff changeset
  6417
      prefer 3
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6418
      apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6419
    proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6420
      fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6421
      assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6422
      have "((1 - norm (a - x) / norm (a - b)) *\<^sub>R a + (norm (a - x) / norm (a - b)) *\<^sub>R b) \<bullet> i =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6423
        ((norm (a - b) - norm (a - x)) * (a \<bullet> i) + norm (a - x) * (b \<bullet> i)) / norm (a - b)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6424
        using Fal by (auto simp add: field_simps inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6425
      also have "\<dots> = x\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6426
        apply (rule divide_eq_imp[OF Fal])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6427
        unfolding as[unfolded dist_norm]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6428
        using as[unfolded dist_triangle_eq]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6429
        apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6430
        apply (subst (asm) euclidean_eq_iff)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6431
        using i
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6432
        apply (erule_tac x=i in ballE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6433
        apply (auto simp add:field_simps inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6434
        done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6435
      finally show "x \<bullet> i =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6436
        ((1 - norm (a - x) / norm (a - b)) *\<^sub>R a + (norm (a - x) / norm (a - b)) *\<^sub>R b) \<bullet> i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6437
        by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6438
    qed (insert Fal2, auto)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6439
  qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6440
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6441
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6442
lemma between_midpoint:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6443
  fixes a :: "'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6444
  shows "between (a,b) (midpoint a b)" (is ?t1)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6445
    and "between (b,a) (midpoint a b)" (is ?t2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6446
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6447
  have *: "\<And>x y z. x = (1/2::real) *\<^sub>R z \<Longrightarrow> y = (1/2) *\<^sub>R z \<Longrightarrow> norm z = norm x + norm y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6448
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6449
  show ?t1 ?t2
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6450
    unfolding between midpoint_def dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6451
    apply(rule_tac[!] *)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6452
    unfolding euclidean_eq_iff[where 'a='a]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6453
    apply (auto simp add: field_simps inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6454
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6455
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6456
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6457
lemma between_mem_convex_hull:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6458
  "between (a,b) x \<longleftrightarrow> x \<in> convex hull {a,b}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6459
  unfolding between_mem_segment segment_convex_hull ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6460
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6461
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  6462
subsection {* Shrinking towards the interior of a convex set *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6463
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6464
lemma mem_interior_convex_shrink:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6465
  fixes s :: "'a::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6466
  assumes "convex s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6467
    and "c \<in> interior s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6468
    and "x \<in> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6469
    and "0 < e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6470
    and "e \<le> 1"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6471
  shows "x - e *\<^sub>R (x - c) \<in> interior s"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6472
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6473
  obtain d where "d > 0" and d: "ball c d \<subseteq> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6474
    using assms(2) unfolding mem_interior by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6475
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6476
    unfolding mem_interior
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6477
    apply (rule_tac x="e*d" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6478
    apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6479
    defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6480
    unfolding subset_eq Ball_def mem_ball
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6481
  proof (rule, rule)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6482
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6483
    assume as: "dist (x - e *\<^sub>R (x - c)) y < e * d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6484
    have *: "y = (1 - (1 - e)) *\<^sub>R ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) + (1 - e) *\<^sub>R x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6485
      using `e > 0` by (auto simp add: scaleR_left_diff_distrib scaleR_right_diff_distrib)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6486
    have "dist c ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) = abs(1/e) * norm (e *\<^sub>R c - y + (1 - e) *\<^sub>R x)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6487
      unfolding dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6488
      unfolding norm_scaleR[symmetric]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6489
      apply (rule arg_cong[where f=norm])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6490
      using `e > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6491
      by (auto simp add: euclidean_eq_iff[where 'a='a] field_simps inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6492
    also have "\<dots> = abs (1/e) * norm (x - e *\<^sub>R (x - c) - y)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6493
      by (auto intro!:arg_cong[where f=norm] simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6494
    also have "\<dots> < d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6495
      using as[unfolded dist_norm] and `e > 0`
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
  6496
      by (auto simp add:pos_divide_less_eq[OF `e > 0`] mult.commute)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6497
    finally show "y \<in> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6498
      apply (subst *)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6499
      apply (rule assms(1)[unfolded convex_alt,rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6500
      apply (rule d[unfolded subset_eq,rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6501
      unfolding mem_ball
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6502
      using assms(3-5)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6503
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6504
      done
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  6505
  qed (insert `e>0` `d>0`, auto)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6506
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6507
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6508
lemma mem_interior_closure_convex_shrink:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6509
  fixes s :: "'a::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6510
  assumes "convex s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6511
    and "c \<in> interior s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6512
    and "x \<in> closure s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6513
    and "0 < e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6514
    and "e \<le> 1"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6515
  shows "x - e *\<^sub>R (x - c) \<in> interior s"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6516
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6517
  obtain d where "d > 0" and d: "ball c d \<subseteq> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6518
    using assms(2) unfolding mem_interior by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6519
  have "\<exists>y\<in>s. norm (y - x) * (1 - e) < e * d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6520
  proof (cases "x \<in> s")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6521
    case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6522
    then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6523
      using `e > 0` `d > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6524
      apply (rule_tac bexI[where x=x])
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  6525
      apply (auto)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6526
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6527
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6528
    case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6529
    then have x: "x islimpt s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6530
      using assms(3)[unfolded closure_def] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6531
    show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6532
    proof (cases "e = 1")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6533
      case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6534
      obtain y where "y \<in> s" "y \<noteq> x" "dist y x < 1"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6535
        using x[unfolded islimpt_approachable,THEN spec[where x=1]] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6536
      then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6537
        apply (rule_tac x=y in bexI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6538
        unfolding True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6539
        using `d > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6540
        apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6541
        done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6542
    next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6543
      case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6544
      then have "0 < e * d / (1 - e)" and *: "1 - e > 0"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  6545
        using `e \<le> 1` `e > 0` `d > 0` by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6546
      then obtain y where "y \<in> s" "y \<noteq> x" "dist y x < e * d / (1 - e)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6547
        using x[unfolded islimpt_approachable,THEN spec[where x="e*d / (1 - e)"]] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6548
      then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6549
        apply (rule_tac x=y in bexI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6550
        unfolding dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6551
        using pos_less_divide_eq[OF *]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6552
        apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6553
        done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6554
    qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6555
  qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6556
  then obtain y where "y \<in> s" and y: "norm (y - x) * (1 - e) < e * d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6557
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6558
  def z \<equiv> "c + ((1 - e) / e) *\<^sub>R (x - y)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6559
  have *: "x - e *\<^sub>R (x - c) = y - e *\<^sub>R (y - z)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6560
    unfolding z_def using `e > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6561
    by (auto simp add: scaleR_right_diff_distrib scaleR_right_distrib scaleR_left_diff_distrib)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6562
  have "z \<in> interior s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6563
    apply (rule interior_mono[OF d,unfolded subset_eq,rule_format])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6564
    unfolding interior_open[OF open_ball] mem_ball z_def dist_norm using y and assms(4,5)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6565
    apply (auto simp add:field_simps norm_minus_commute)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6566
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6567
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6568
    unfolding *
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6569
    apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6570
    apply (rule mem_interior_convex_shrink)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6571
    using assms(1,4-5) `y\<in>s`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6572
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6573
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6574
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6575
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6576
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  6577
subsection {* Some obvious but surprisingly hard simplex lemmas *}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6578
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6579
lemma simplex:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6580
  assumes "finite s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6581
    and "0 \<notin> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6582
  shows "convex hull (insert 0 s) =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6583
    {y. (\<exists>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> setsum u s \<le> 1 \<and> setsum (\<lambda>x. u x *\<^sub>R x) s = y)}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6584
  unfolding convex_hull_finite[OF finite.insertI[OF assms(1)]]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6585
  apply (rule set_eqI, rule)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6586
  unfolding mem_Collect_eq
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6587
  apply (erule_tac[!] exE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6588
  apply (erule_tac[!] conjE)+
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6589
  unfolding setsum_clauses(2)[OF assms(1)]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6590
  apply (rule_tac x=u in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6591
  defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6592
  apply (rule_tac x="\<lambda>x. if x = 0 then 1 - setsum u s else u x" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6593
  using assms(2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6594
  unfolding if_smult and setsum_delta_notmem[OF assms(2)]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6595
  apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6596
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6597
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6598
lemma substd_simplex:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6599
  assumes d: "d \<subseteq> Basis"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6600
  shows "convex hull (insert 0 d) =
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6601
    {x. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> (\<Sum>i\<in>d. x\<bullet>i) \<le> 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)}"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  6602
  (is "convex hull (insert 0 ?p) = ?s")
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6603
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6604
  let ?D = d
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6605
  have "0 \<notin> ?p"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6606
    using assms by (auto simp: image_def)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6607
  from d have "finite d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6608
    by (blast intro: finite_subset finite_Basis)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6609
  show ?thesis
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6610
    unfolding simplex[OF `finite d` `0 \<notin> ?p`]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6611
    apply (rule set_eqI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6612
    unfolding mem_Collect_eq
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6613
    apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6614
    apply (elim exE conjE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6615
    apply (erule_tac[2] conjE)+
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6616
  proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6617
    fix x :: "'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6618
    fix u
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6619
    assume as: "\<forall>x\<in>?D. 0 \<le> u x" "setsum u ?D \<le> 1" "(\<Sum>x\<in>?D. u x *\<^sub>R x) = x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6620
    have *: "\<forall>i\<in>Basis. i:d \<longrightarrow> u i = x\<bullet>i"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6621
      and "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6622
      using as(3)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6623
      unfolding substdbasis_expansion_unique[OF assms]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6624
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6625
    then have **: "setsum u ?D = setsum (op \<bullet> x) ?D"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6626
      apply -
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6627
      apply (rule setsum.cong)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6628
      using assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6629
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6630
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6631
    have "(\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (op \<bullet> x) ?D \<le> 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6632
    proof (rule,rule)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6633
      fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6634
      assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6635
      have "i \<in> d \<Longrightarrow> 0 \<le> x\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6636
        unfolding *[rule_format,OF i,symmetric]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6637
         apply (rule_tac as(1)[rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6638
         apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6639
         done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6640
      moreover have "i \<notin> d \<Longrightarrow> 0 \<le> x\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6641
        using `(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)`[rule_format, OF i] by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6642
      ultimately show "0 \<le> x\<bullet>i" by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6643
    qed (insert as(2)[unfolded **], auto)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6644
    then show "(\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (op \<bullet> x) ?D \<le> 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6645
      using `(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6646
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6647
    fix x :: "'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6648
    assume as: "\<forall>i\<in>Basis. 0 \<le> x \<bullet> i" "setsum (op \<bullet> x) ?D \<le> 1" "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6649
    show "\<exists>u. (\<forall>x\<in>?D. 0 \<le> u x) \<and> setsum u ?D \<le> 1 \<and> (\<Sum>x\<in>?D. u x *\<^sub>R x) = x"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6650
      using as d
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6651
      unfolding substdbasis_expansion_unique[OF assms]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6652
      apply (rule_tac x="inner x" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6653
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6654
      done
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6655
  qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6656
qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  6657
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6658
lemma std_simplex:
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6659
  "convex hull (insert 0 Basis) =
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6660
    {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i) \<and> setsum (\<lambda>i. x\<bullet>i) Basis \<le> 1}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6661
  using substd_simplex[of Basis] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6662
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6663
lemma interior_std_simplex:
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6664
  "interior (convex hull (insert 0 Basis)) =
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6665
    {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 < x\<bullet>i) \<and> setsum (\<lambda>i. x\<bullet>i) Basis < 1}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6666
  apply (rule set_eqI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6667
  unfolding mem_interior std_simplex
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6668
  unfolding subset_eq mem_Collect_eq Ball_def mem_ball
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6669
  unfolding Ball_def[symmetric]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6670
  apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6671
  apply (elim exE conjE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6672
  defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6673
  apply (erule conjE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6674
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6675
  fix x :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6676
  fix e
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6677
  assume "e > 0" and as: "\<forall>xa. dist x xa < e \<longrightarrow> (\<forall>x\<in>Basis. 0 \<le> xa \<bullet> x) \<and> setsum (op \<bullet> xa) Basis \<le> 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6678
  show "(\<forall>xa\<in>Basis. 0 < x \<bullet> xa) \<and> setsum (op \<bullet> x) Basis < 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6679
    apply safe
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6680
  proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6681
    fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6682
    assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6683
    then show "0 < x \<bullet> i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6684
      using as[THEN spec[where x="x - (e / 2) *\<^sub>R i"]] and `e > 0`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6685
      unfolding dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6686
      by (auto elim!: ballE[where x=i] simp: inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6687
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6688
    have **: "dist x (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis)) < e" using `e > 0`
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6689
      unfolding dist_norm
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6690
      by (auto intro!: mult_strict_left_mono simp: SOME_Basis)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6691
    have "\<And>i. i \<in> Basis \<Longrightarrow> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis)) \<bullet> i =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6692
      x\<bullet>i + (if i = (SOME i. i\<in>Basis) then e/2 else 0)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6693
      by (auto simp: SOME_Basis inner_Basis inner_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6694
    then have *: "setsum (op \<bullet> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis))) Basis =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6695
      setsum (\<lambda>i. x\<bullet>i + (if (SOME i. i\<in>Basis) = i then e/2 else 0)) Basis"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6696
      apply (rule_tac setsum.cong)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6697
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6698
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6699
    have "setsum (op \<bullet> x) Basis < setsum (op \<bullet> (x + (e / 2) *\<^sub>R (SOME i. i\<in>Basis))) Basis"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6700
      unfolding * setsum.distrib
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6701
      using `e > 0` DIM_positive[where 'a='a]
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6702
      apply (subst setsum.delta')
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6703
      apply (auto simp: SOME_Basis)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6704
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6705
    also have "\<dots> \<le> 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6706
      using **
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6707
      apply (drule_tac as[rule_format])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6708
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6709
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6710
    finally show "setsum (op \<bullet> x) Basis < 1" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6711
  qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6712
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6713
  fix x :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6714
  assume as: "\<forall>i\<in>Basis. 0 < x \<bullet> i" "setsum (op \<bullet> x) Basis < 1"
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  6715
  obtain a :: 'b where "a \<in> UNIV" using UNIV_witness ..
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6716
  let ?d = "(1 - setsum (op \<bullet> x) Basis) / real (DIM('a))"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6717
  have "Min ((op \<bullet> x) ` Basis) > 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6718
    apply (rule Min_grI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6719
    using as(1)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6720
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6721
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6722
  moreover have "?d > 0"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  6723
    using as(2) by (auto simp: Suc_le_eq DIM_positive)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6724
  ultimately show "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> (\<forall>i\<in>Basis. 0 \<le> y \<bullet> i) \<and> setsum (op \<bullet> y) Basis \<le> 1"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6725
    apply (rule_tac x="min (Min ((op \<bullet> x) ` Basis)) ?D" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6726
    apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6727
    defer
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6728
    apply (rule, rule)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6729
  proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6730
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6731
    assume y: "dist x y < min (Min (op \<bullet> x ` Basis)) ?d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6732
    have "setsum (op \<bullet> y) Basis \<le> setsum (\<lambda>i. x\<bullet>i + ?d) Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6733
    proof (rule setsum_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6734
      fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6735
      assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6736
      then have "abs (y\<bullet>i - x\<bullet>i) < ?d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6737
        apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6738
        apply (rule le_less_trans)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6739
        using Basis_le_norm[OF i, of "y - x"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6740
        using y[unfolded min_less_iff_conj dist_norm, THEN conjunct2]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6741
        apply (auto simp add: norm_minus_commute inner_diff_left)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6742
        done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6743
      then show "y \<bullet> i \<le> x \<bullet> i + ?d" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6744
    qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6745
    also have "\<dots> \<le> 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6746
      unfolding setsum.distrib setsum_constant real_eq_of_nat
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6747
      by (auto simp add: Suc_le_eq)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6748
    finally show "(\<forall>i\<in>Basis. 0 \<le> y \<bullet> i) \<and> setsum (op \<bullet> y) Basis \<le> 1"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6749
    proof safe
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6750
      fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6751
      assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6752
      have "norm (x - y) < x\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6753
        apply (rule less_le_trans)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6754
        apply (rule y[unfolded min_less_iff_conj dist_norm, THEN conjunct1])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6755
        using i
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6756
        apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6757
        done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6758
      then show "0 \<le> y\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6759
        using Basis_le_norm[OF i, of "x - y"] and as(1)[rule_format, OF i]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6760
        by (auto simp: inner_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6761
    qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6762
  qed auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6763
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6764
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6765
lemma interior_std_simplex_nonempty:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6766
  obtains a :: "'a::euclidean_space" where
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6767
    "a \<in> interior(convex hull (insert 0 Basis))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6768
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6769
  let ?D = "Basis :: 'a set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6770
  let ?a = "setsum (\<lambda>b::'a. inverse (2 * real DIM('a)) *\<^sub>R b) Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6771
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6772
    fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6773
    assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6774
    have "?a \<bullet> i = inverse (2 * real DIM('a))"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6775
      by (rule trans[of _ "setsum (\<lambda>j. if i = j then inverse (2 * real DIM('a)) else 0) ?D"])
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6776
         (simp_all add: setsum.If_cases i) }
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6777
  note ** = this
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6778
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6779
    apply (rule that[of ?a])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6780
    unfolding interior_std_simplex mem_Collect_eq
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6781
  proof safe
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6782
    fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6783
    assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6784
    show "0 < ?a \<bullet> i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6785
      unfolding **[OF i] by (auto simp add: Suc_le_eq DIM_positive)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6786
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6787
    have "setsum (op \<bullet> ?a) ?D = setsum (\<lambda>i. inverse (2 * real DIM('a))) ?D"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6788
      apply (rule setsum.cong)
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6789
      apply rule
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6790
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6791
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6792
    also have "\<dots> < 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6793
      unfolding setsum_constant real_eq_of_nat divide_inverse[symmetric]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6794
      by (auto simp add: field_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6795
    finally show "setsum (op \<bullet> ?a) ?D < 1" by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  6796
  qed
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6797
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6798
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6799
lemma rel_interior_substd_simplex:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6800
  assumes d: "d \<subseteq> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6801
  shows "rel_interior (convex hull (insert 0 d)) =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6802
    {x::'a::euclidean_space. (\<forall>i\<in>d. 0 < x\<bullet>i) \<and> (\<Sum>i\<in>d. x\<bullet>i) < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6803
  (is "rel_interior (convex hull (insert 0 ?p)) = ?s")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6804
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6805
  have "finite d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6806
    apply (rule finite_subset)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6807
    using assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6808
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6809
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6810
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6811
  proof (cases "d = {}")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6812
    case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6813
    then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6814
      using rel_interior_sing using euclidean_eq_iff[of _ 0] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6815
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6816
    case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6817
    have h0: "affine hull (convex hull (insert 0 ?p)) =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6818
      {x::'a::euclidean_space. (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6819
      using affine_hull_convex_hull affine_hull_substd_basis assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6820
    have aux: "\<And>x::'a. \<forall>i\<in>Basis. (\<forall>i\<in>d. 0 \<le> x\<bullet>i) \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0) \<longrightarrow> 0 \<le> x\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6821
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6822
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6823
      fix x :: "'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6824
      assume x: "x \<in> rel_interior (convex hull (insert 0 ?p))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6825
      then obtain e where e0: "e > 0" and
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6826
        "ball x e \<inter> {xa. (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> xa\<bullet>i = 0)} \<subseteq> convex hull (insert 0 ?p)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6827
        using mem_rel_interior_ball[of x "convex hull (insert 0 ?p)"] h0 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6828
      then have as: "\<forall>xa. dist x xa < e \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> xa\<bullet>i = 0) \<longrightarrow>
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6829
        (\<forall>i\<in>d. 0 \<le> xa \<bullet> i) \<and> setsum (op \<bullet> xa) d \<le> 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6830
        unfolding ball_def unfolding substd_simplex[OF assms] using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6831
      have x0: "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6832
        using x rel_interior_subset  substd_simplex[OF assms] by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6833
      have "(\<forall>i\<in>d. 0 < x \<bullet> i) \<and> setsum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6834
        apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6835
        apply rule
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6836
      proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6837
        fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6838
        assume "i \<in> d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6839
        then have "\<forall>ia\<in>d. 0 \<le> (x - (e / 2) *\<^sub>R i) \<bullet> ia"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6840
          apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6841
          apply (rule as[rule_format,THEN conjunct1])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6842
          unfolding dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6843
          using d `e > 0` x0
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6844
          apply (auto simp: inner_simps inner_Basis)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6845
          done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6846
        then show "0 < x \<bullet> i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6847
          apply (erule_tac x=i in ballE)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6848
          using `e > 0` `i \<in> d` d
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6849
          apply (auto simp: inner_simps inner_Basis)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6850
          done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6851
      next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6852
        obtain a where a: "a \<in> d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6853
          using `d \<noteq> {}` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6854
        then have **: "dist x (x + (e / 2) *\<^sub>R a) < e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6855
          using `e > 0` norm_Basis[of a] d
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6856
          unfolding dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6857
          by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6858
        have "\<And>i. i \<in> Basis \<Longrightarrow> (x + (e / 2) *\<^sub>R a) \<bullet> i = x\<bullet>i + (if i = a then e/2 else 0)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6859
          using a d by (auto simp: inner_simps inner_Basis)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6860
        then have *: "setsum (op \<bullet> (x + (e / 2) *\<^sub>R a)) d =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6861
          setsum (\<lambda>i. x\<bullet>i + (if a = i then e/2 else 0)) d"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6862
          using d by (intro setsum.cong) auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6863
        have "a \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6864
          using `a \<in> d` d by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6865
        then have h1: "(\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> (x + (e / 2) *\<^sub>R a) \<bullet> i = 0)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6866
          using x0 d `a\<in>d` by (auto simp add: inner_add_left inner_Basis)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6867
        have "setsum (op \<bullet> x) d < setsum (op \<bullet> (x + (e / 2) *\<^sub>R a)) d"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6868
          unfolding * setsum.distrib
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6869
          using `e > 0` `a \<in> d`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6870
          using `finite d`
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6871
          by (auto simp add: setsum.delta')
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6872
        also have "\<dots> \<le> 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6873
          using ** h1 as[rule_format, of "x + (e / 2) *\<^sub>R a"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6874
          by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6875
        finally show "setsum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6876
          using x0 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6877
      qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6878
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6879
    moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6880
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6881
      fix x :: "'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6882
      assume as: "x \<in> ?s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6883
      have "\<forall>i. 0 < x\<bullet>i \<or> 0 = x\<bullet>i \<longrightarrow> 0 \<le> x\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6884
        by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6885
      moreover have "\<forall>i. i \<in> d \<or> i \<notin> d" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6886
      ultimately
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6887
      have "\<forall>i. (\<forall>i\<in>d. 0 < x\<bullet>i) \<and> (\<forall>i. i \<notin> d \<longrightarrow> x\<bullet>i = 0) \<longrightarrow> 0 \<le> x\<bullet>i"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6888
        by metis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6889
      then have h2: "x \<in> convex hull (insert 0 ?p)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6890
        using as assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6891
        unfolding substd_simplex[OF assms] by fastforce
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6892
      obtain a where a: "a \<in> d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6893
        using `d \<noteq> {}` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6894
      let ?d = "(1 - setsum (op \<bullet> x) d) / real (card d)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6895
      have "0 < card d" using `d \<noteq> {}` `finite d`
44466
0e5c27f07529 remove unnecessary lemma card_ge1
huffman
parents: 44465
diff changeset
  6896
        by (simp add: card_gt_0_iff)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6897
      have "Min ((op \<bullet> x) ` d) > 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6898
        using as `d \<noteq> {}` `finite d` by (simp add: Min_grI)
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  6899
      moreover have "?d > 0" using as using `0 < card d` by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6900
      ultimately have h3: "min (Min ((op \<bullet> x) ` d)) ?d > 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6901
        by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6902
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6903
      have "x \<in> rel_interior (convex hull (insert 0 ?p))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6904
        unfolding rel_interior_ball mem_Collect_eq h0
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6905
        apply (rule,rule h2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6906
        unfolding substd_simplex[OF assms]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6907
        apply (rule_tac x="min (Min ((op \<bullet> x) ` d)) ?d" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6908
        apply (rule, rule h3)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6909
        apply safe
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6910
        unfolding mem_ball
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6911
      proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6912
        fix y :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6913
        assume y: "dist x y < min (Min (op \<bullet> x ` d)) ?d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6914
        assume y2: "\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> y\<bullet>i = 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6915
        have "setsum (op \<bullet> y) d \<le> setsum (\<lambda>i. x\<bullet>i + ?d) d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6916
        proof (rule setsum_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6917
          fix i
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6918
          assume "i \<in> d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6919
          with d have i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6920
            by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6921
          have "abs (y\<bullet>i - x\<bullet>i) < ?d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6922
            apply (rule le_less_trans)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6923
            using Basis_le_norm[OF i, of "y - x"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6924
            using y[unfolded min_less_iff_conj dist_norm, THEN conjunct2]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6925
            apply (auto simp add: norm_minus_commute inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6926
            done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6927
          then show "y \<bullet> i \<le> x \<bullet> i + ?d" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6928
        qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6929
        also have "\<dots> \<le> 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6930
          unfolding setsum.distrib setsum_constant real_eq_of_nat
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6931
          using `0 < card d`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6932
          by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6933
        finally show "setsum (op \<bullet> y) d \<le> 1" .
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6934
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6935
        fix i :: 'a
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6936
        assume i: "i \<in> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6937
        then show "0 \<le> y\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6938
        proof (cases "i\<in>d")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6939
          case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6940
          have "norm (x - y) < x\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6941
            using y[unfolded min_less_iff_conj dist_norm, THEN conjunct1]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6942
            using Min_gr_iff[of "op \<bullet> x ` d" "norm (x - y)"] `0 < card d` `i:d`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6943
            by (simp add: card_gt_0_iff)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6944
          then show "0 \<le> y\<bullet>i"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6945
            using Basis_le_norm[OF i, of "x - y"] and as(1)[rule_format]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6946
            by (auto simp: inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6947
        qed (insert y2, auto)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6948
      qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6949
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6950
    ultimately have
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6951
      "\<And>x. x \<in> rel_interior (convex hull insert 0 d) \<longleftrightarrow>
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6952
        x \<in> {x. (\<forall>i\<in>d. 0 < x \<bullet> i) \<and> setsum (op \<bullet> x) d < 1 \<and> (\<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0)}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6953
      by blast
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6954
    then show ?thesis by (rule set_eqI)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  6955
  qed
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6956
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6957
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6958
lemma rel_interior_substd_simplex_nonempty:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6959
  assumes "d \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6960
    and "d \<subseteq> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6961
  obtains a :: "'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6962
    where "a \<in> rel_interior (convex hull (insert 0 d))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6963
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6964
  let ?D = d
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6965
  let ?a = "setsum (\<lambda>b::'a::euclidean_space. inverse (2 * real (card d)) *\<^sub>R b) ?D"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6966
  have "finite d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6967
    apply (rule finite_subset)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6968
    using assms(2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6969
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6970
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6971
  then have d1: "0 < real (card d)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6972
    using `d \<noteq> {}` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6973
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6974
    fix i
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6975
    assume "i \<in> d"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6976
    have "?a \<bullet> i = inverse (2 * real (card d))"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6977
      apply (rule trans[of _ "setsum (\<lambda>j. if i = j then inverse (2 * real (card d)) else 0) ?D"])
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6978
      unfolding inner_setsum_left
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6979
      apply (rule setsum.cong)
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6980
      using `i \<in> d` `finite d` setsum.delta'[of d i "(\<lambda>k. inverse (2 * real (card d)))"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6981
        d1 assms(2)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6982
      by (auto simp: inner_Basis set_rev_mp[OF _ assms(2)])
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6983
  }
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  6984
  note ** = this
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6985
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6986
    apply (rule that[of ?a])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6987
    unfolding rel_interior_substd_simplex[OF assms(2)] mem_Collect_eq
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6988
  proof safe
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6989
    fix i
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6990
    assume "i \<in> d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6991
    have "0 < inverse (2 * real (card d))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6992
      using d1 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6993
    also have "\<dots> = ?a \<bullet> i" using **[of i] `i \<in> d`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6994
      by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6995
    finally show "0 < ?a \<bullet> i" by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6996
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6997
    have "setsum (op \<bullet> ?a) ?D = setsum (\<lambda>i. inverse (2 * real (card d))) ?D"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  6998
      by (rule setsum.cong) (rule refl, rule **)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6999
    also have "\<dots> < 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7000
      unfolding setsum_constant real_eq_of_nat divide_real_def[symmetric]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7001
      by (auto simp add: field_simps)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  7002
    finally show "setsum (op \<bullet> ?a) ?D < 1" by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7003
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7004
    fix i
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7005
    assume "i \<in> Basis" and "i \<notin> d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7006
    have "?a \<in> span d"
56196
32b7eafc5a52 remove unnecessary finiteness assumptions from lemmas about setsum
huffman
parents: 56189
diff changeset
  7007
    proof (rule span_setsum[of d "(\<lambda>b. b /\<^sub>R (2 * real (card d)))" d])
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7008
      {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7009
        fix x :: "'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7010
        assume "x \<in> d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7011
        then have "x \<in> span d"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  7012
          using span_superset[of _ "d"] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7013
        then have "x /\<^sub>R (2 * real (card d)) \<in> span d"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  7014
          using span_mul[of x "d" "(inverse (real (card d)) / 2)"] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7015
      }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7016
      then show "\<forall>x\<in>d. x /\<^sub>R (2 * real (card d)) \<in> span d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7017
        by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7018
    qed
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7019
    then show "?a \<bullet> i = 0 "
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7020
      using `i \<notin> d` unfolding span_substd_basis[OF assms(2)] using `i \<in> Basis` by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7021
  qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7022
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7023
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7024
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  7025
subsection {* Relative interior of convex set *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7026
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7027
lemma rel_interior_convex_nonempty_aux:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7028
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7029
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7030
    and "0 \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7031
  shows "rel_interior S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7032
proof (cases "S = {0}")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7033
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7034
  then show ?thesis using rel_interior_sing by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7035
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7036
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7037
  obtain B where B: "independent B \<and> B \<le> S \<and> S \<le> span B \<and> card B = dim S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7038
    using basis_exists[of S] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7039
  then have "B \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7040
    using B assms `S \<noteq> {0}` span_empty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7041
  have "insert 0 B \<le> span B"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7042
    using subspace_span[of B] subspace_0[of "span B"] span_inc by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7043
  then have "span (insert 0 B) \<le> span B"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7044
    using span_span[of B] span_mono[of "insert 0 B" "span B"] by blast
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7045
  then have "convex hull insert 0 B \<le> span B"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7046
    using convex_hull_subset_span[of "insert 0 B"] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7047
  then have "span (convex hull insert 0 B) \<le> span B"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7048
    using span_span[of B] span_mono[of "convex hull insert 0 B" "span B"] by blast
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7049
  then have *: "span (convex hull insert 0 B) = span B"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7050
    using span_mono[of B "convex hull insert 0 B"] hull_subset[of "insert 0 B"] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7051
  then have "span (convex hull insert 0 B) = span S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7052
    using B span_mono[of B S] span_mono[of S "span B"] span_span[of B] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7053
  moreover have "0 \<in> affine hull (convex hull insert 0 B)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7054
    using hull_subset[of "convex hull insert 0 B"] hull_subset[of "insert 0 B"] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7055
  ultimately have **: "affine hull (convex hull insert 0 B) = affine hull S"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7056
    using affine_hull_span_0[of "convex hull insert 0 B"] affine_hull_span_0[of "S"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7057
      assms hull_subset[of S]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7058
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7059
  obtain d and f :: "'n \<Rightarrow> 'n" where
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7060
    fd: "card d = card B" "linear f" "f ` B = d"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7061
      "f ` span B = {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = (0::real)} \<and> inj_on f (span B)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7062
    and d: "d \<subseteq> Basis"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7063
    using basis_to_substdbasis_subspace_isomorphism[of B,OF _ ] B by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7064
  then have "bounded_linear f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7065
    using linear_conv_bounded_linear by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7066
  have "d \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7067
    using fd B `B \<noteq> {}` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7068
  have "insert 0 d = f ` (insert 0 B)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7069
    using fd linear_0 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7070
  then have "(convex hull (insert 0 d)) = f ` (convex hull (insert 0 B))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7071
    using convex_hull_linear_image[of f "(insert 0 d)"]
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  7072
      convex_hull_linear_image[of f "(insert 0 B)"] `linear f`
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7073
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7074
  moreover have "rel_interior (f ` (convex hull insert 0 B)) =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7075
    f ` rel_interior (convex hull insert 0 B)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7076
    apply (rule  rel_interior_injective_on_span_linear_image[of f "(convex hull insert 0 B)"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7077
    using `bounded_linear f` fd *
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7078
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7079
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7080
  ultimately have "rel_interior (convex hull insert 0 B) \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7081
    using rel_interior_substd_simplex_nonempty[OF `d \<noteq> {}` d]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7082
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7083
    apply blast
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7084
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7085
  moreover have "convex hull (insert 0 B) \<subseteq> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7086
    using B assms hull_mono[of "insert 0 B" "S" "convex"] convex_hull_eq
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7087
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7088
  ultimately show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7089
    using subset_rel_interior[of "convex hull insert 0 B" S] ** by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7090
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7091
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7092
lemma rel_interior_convex_nonempty:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7093
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7094
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7095
  shows "rel_interior S = {} \<longleftrightarrow> S = {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7096
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7097
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7098
    assume "S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7099
    then obtain a where "a \<in> S" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7100
    then have "0 \<in> op + (-a) ` S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7101
      using assms exI[of "(\<lambda>x. x \<in> S \<and> - a + x = 0)" a] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7102
    then have "rel_interior (op + (-a) ` S) \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7103
      using rel_interior_convex_nonempty_aux[of "op + (-a) ` S"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7104
        convex_translation[of S "-a"] assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7105
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7106
    then have "rel_interior S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7107
      using rel_interior_translation by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7108
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7109
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7110
    using rel_interior_empty by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7111
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7112
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7113
lemma convex_rel_interior:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7114
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7115
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7116
  shows "convex (rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7117
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7118
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7119
    fix x y and u :: real
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7120
    assume assm: "x \<in> rel_interior S" "y \<in> rel_interior S" "0 \<le> u" "u \<le> 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7121
    then have "x \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7122
      using rel_interior_subset by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7123
    have "x - u *\<^sub>R (x-y) \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7124
    proof (cases "0 = u")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7125
      case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7126
      then have "0 < u" using assm by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7127
      then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7128
        using assm rel_interior_convex_shrink[of S y x u] assms `x \<in> S` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7129
    next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7130
      case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7131
      then show ?thesis using assm by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7132
    qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7133
    then have "(1 - u) *\<^sub>R x + u *\<^sub>R y \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7134
      by (simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7135
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7136
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7137
    unfolding convex_alt by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7138
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7139
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7140
lemma convex_closure_rel_interior:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7141
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7142
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7143
  shows "closure (rel_interior S) = closure S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7144
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7145
  have h1: "closure (rel_interior S) \<le> closure S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7146
    using closure_mono[of "rel_interior S" S] rel_interior_subset[of S] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7147
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7148
  proof (cases "S = {}")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7149
    case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7150
    then obtain a where a: "a \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7151
      using rel_interior_convex_nonempty assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7152
    { fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7153
      assume x: "x \<in> closure S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7154
      {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7155
        assume "x = a"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7156
        then have "x \<in> closure (rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7157
          using a unfolding closure_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7158
      }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7159
      moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7160
      {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7161
        assume "x \<noteq> a"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7162
         {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7163
           fix e :: real
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7164
           assume "e > 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7165
           def e1 \<equiv> "min 1 (e/norm (x - a))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7166
           then have e1: "e1 > 0" "e1 \<le> 1" "e1 * norm (x - a) \<le> e"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  7167
             using `x \<noteq> a` `e > 0` le_divide_eq[of e1 e "norm (x - a)"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7168
             by simp_all
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7169
           then have *: "x - e1 *\<^sub>R (x - a) : rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7170
             using rel_interior_closure_convex_shrink[of S a x e1] assms x a e1_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7171
             by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7172
           have "\<exists>y. y \<in> rel_interior S \<and> y \<noteq> x \<and> dist y x \<le> e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7173
              apply (rule_tac x="x - e1 *\<^sub>R (x - a)" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7174
              using * e1 dist_norm[of "x - e1 *\<^sub>R (x - a)" x] `x \<noteq> a`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7175
              apply simp
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7176
              done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7177
        }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7178
        then have "x islimpt rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7179
          unfolding islimpt_approachable_le by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7180
        then have "x \<in> closure(rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7181
          unfolding closure_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7182
      }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7183
      ultimately have "x \<in> closure(rel_interior S)" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7184
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7185
    then show ?thesis using h1 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7186
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7187
    case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7188
    then have "rel_interior S = {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7189
      using rel_interior_empty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7190
    then have "closure (rel_interior S) = {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7191
      using closure_empty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7192
    with True show ?thesis by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7193
  qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7194
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7195
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7196
lemma rel_interior_same_affine_hull:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7197
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7198
  assumes "convex S"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7199
  shows "affine hull (rel_interior S) = affine hull S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7200
  by (metis assms closure_same_affine_hull convex_closure_rel_interior)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7201
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7202
lemma rel_interior_aff_dim:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7203
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7204
  assumes "convex S"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7205
  shows "aff_dim (rel_interior S) = aff_dim S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7206
  by (metis aff_dim_affine_hull2 assms rel_interior_same_affine_hull)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7207
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7208
lemma rel_interior_rel_interior:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7209
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7210
  assumes "convex S"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7211
  shows "rel_interior (rel_interior S) = rel_interior S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7212
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7213
  have "openin (subtopology euclidean (affine hull (rel_interior S))) (rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7214
    using opein_rel_interior[of S] rel_interior_same_affine_hull[of S] assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7215
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7216
    using rel_interior_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7217
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7218
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7219
lemma rel_interior_rel_open:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7220
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7221
  assumes "convex S"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7222
  shows "rel_open (rel_interior S)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7223
  unfolding rel_open_def using rel_interior_rel_interior assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7224
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7225
lemma convex_rel_interior_closure_aux:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7226
  fixes x y z :: "'n::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7227
  assumes "0 < a" "0 < b" "(a + b) *\<^sub>R z = a *\<^sub>R x + b *\<^sub>R y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7228
  obtains e where "0 < e" "e \<le> 1" "z = y - e *\<^sub>R (y - x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7229
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7230
  def e \<equiv> "a / (a + b)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7231
  have "z = (1 / (a + b)) *\<^sub>R ((a + b) *\<^sub>R z)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7232
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7233
    using assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7234
    apply simp
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7235
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7236
  also have "\<dots> = (1 / (a + b)) *\<^sub>R (a *\<^sub>R x + b *\<^sub>R y)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7237
    using assms scaleR_cancel_left[of "1/(a+b)" "(a + b) *\<^sub>R z" "a *\<^sub>R x + b *\<^sub>R y"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7238
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7239
  also have "\<dots> = y - e *\<^sub>R (y-x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7240
    using e_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7241
    apply (simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7242
    using scaleR_left_distrib[of "a/(a+b)" "b/(a+b)" y] assms add_divide_distrib[of a b "a+b"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7243
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7244
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7245
  finally have "z = y - e *\<^sub>R (y-x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7246
    by auto
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  7247
  moreover have "e > 0" using e_def assms by auto
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  7248
  moreover have "e \<le> 1" using e_def assms by auto
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  7249
  ultimately show ?thesis using that[of e] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7250
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7251
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7252
lemma convex_rel_interior_closure:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7253
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7254
  assumes "convex S"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7255
  shows "rel_interior (closure S) = rel_interior S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7256
proof (cases "S = {}")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7257
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7258
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7259
    using assms rel_interior_convex_nonempty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7260
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7261
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7262
  have "rel_interior (closure S) \<supseteq> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7263
    using subset_rel_interior[of S "closure S"] closure_same_affine_hull closure_subset
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7264
    by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7265
  moreover
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7266
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7267
    fix z
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7268
    assume z: "z \<in> rel_interior (closure S)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7269
    obtain x where x: "x \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7270
      using `S \<noteq> {}` assms rel_interior_convex_nonempty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7271
    have "z \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7272
    proof (cases "x = z")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7273
      case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7274
      then show ?thesis using x by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7275
    next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7276
      case False
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7277
      obtain e where e: "e > 0" "cball z e \<inter> affine hull closure S \<le> closure S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7278
        using z rel_interior_cball[of "closure S"] by auto
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  7279
      hence *: "0 < e/norm(z-x)" using e False by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7280
      def y \<equiv> "z + (e/norm(z-x)) *\<^sub>R (z-x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7281
      have yball: "y \<in> cball z e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7282
        using mem_cball y_def dist_norm[of z y] e by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7283
      have "x \<in> affine hull closure S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7284
        using x rel_interior_subset_closure hull_inc[of x "closure S"] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7285
      moreover have "z \<in> affine hull closure S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7286
        using z rel_interior_subset hull_subset[of "closure S"] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7287
      ultimately have "y \<in> affine hull closure S"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7288
        using y_def affine_affine_hull[of "closure S"]
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7289
          mem_affine_3_minus [of "affine hull closure S" z z x "e/norm(z-x)"] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7290
      then have "y \<in> closure S" using e yball by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7291
      have "(1 + (e/norm(z-x))) *\<^sub>R z = (e/norm(z-x)) *\<^sub>R x + y"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7292
        using y_def by (simp add: algebra_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7293
      then obtain e1 where "0 < e1" "e1 \<le> 1" "z = y - e1 *\<^sub>R (y - x)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7294
        using * convex_rel_interior_closure_aux[of "e / norm (z - x)" 1 z x y]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7295
        by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7296
      then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7297
        using rel_interior_closure_convex_shrink assms x `y \<in> closure S`
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7298
        by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7299
    qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7300
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7301
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7302
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7303
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7304
lemma convex_interior_closure:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7305
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7306
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7307
  shows "interior (closure S) = interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7308
  using closure_aff_dim[of S] interior_rel_interior_gen[of S]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7309
    interior_rel_interior_gen[of "closure S"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7310
    convex_rel_interior_closure[of S] assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7311
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7312
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7313
lemma closure_eq_rel_interior_eq:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7314
  fixes S1 S2 :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7315
  assumes "convex S1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7316
    and "convex S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7317
  shows "closure S1 = closure S2 \<longleftrightarrow> rel_interior S1 = rel_interior S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7318
  by (metis convex_rel_interior_closure convex_closure_rel_interior assms)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7319
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7320
lemma closure_eq_between:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7321
  fixes S1 S2 :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7322
  assumes "convex S1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7323
    and "convex S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7324
  shows "closure S1 = closure S2 \<longleftrightarrow> rel_interior S1 \<le> S2 \<and> S2 \<subseteq> closure S1"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7325
  (is "?A \<longleftrightarrow> ?B")
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7326
proof
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7327
  assume ?A
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7328
  then show ?B
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7329
    by (metis assms closure_subset convex_rel_interior_closure rel_interior_subset)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7330
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7331
  assume ?B
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7332
  then have "closure S1 \<subseteq> closure S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7333
    by (metis assms(1) convex_closure_rel_interior closure_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7334
  moreover from `?B` have "closure S1 \<supseteq> closure S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7335
    by (metis closed_closure closure_minimal)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7336
  ultimately show ?A ..
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7337
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7338
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7339
lemma open_inter_closure_rel_interior:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7340
  fixes S A :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7341
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7342
    and "open A"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7343
  shows "A \<inter> closure S = {} \<longleftrightarrow> A \<inter> rel_interior S = {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7344
  by (metis assms convex_closure_rel_interior open_inter_closure_eq_empty)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7345
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7346
definition "rel_frontier S = closure S - rel_interior S"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7347
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7348
lemma closed_affine_hull:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7349
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7350
  shows "closed (affine hull S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7351
  by (metis affine_affine_hull affine_closed)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7352
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7353
lemma closed_rel_frontier:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7354
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7355
  shows "closed (rel_frontier S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7356
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7357
  have *: "closedin (subtopology euclidean (affine hull S)) (closure S - rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7358
    apply (rule closedin_diff[of "subtopology euclidean (affine hull S)""closure S" "rel_interior S"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7359
    using closed_closedin_trans[of "affine hull S" "closure S"] closed_affine_hull[of S]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7360
      closure_affine_hull[of S] opein_rel_interior[of S]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7361
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7362
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7363
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7364
    apply (rule closedin_closed_trans[of "affine hull S" "rel_frontier S"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7365
    unfolding rel_frontier_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7366
    using * closed_affine_hull
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7367
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7368
    done
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7369
qed
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7370
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7371
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7372
lemma convex_rel_frontier_aff_dim:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7373
  fixes S1 S2 :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7374
  assumes "convex S1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7375
    and "convex S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7376
    and "S2 \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7377
    and "S1 \<le> rel_frontier S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7378
  shows "aff_dim S1 < aff_dim S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7379
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7380
  have "S1 \<subseteq> closure S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7381
    using assms unfolding rel_frontier_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7382
  then have *: "affine hull S1 \<subseteq> affine hull S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7383
    using hull_mono[of "S1" "closure S2"] closure_same_affine_hull[of S2]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7384
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7385
  then have "aff_dim S1 \<le> aff_dim S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7386
    using * aff_dim_affine_hull[of S1] aff_dim_affine_hull[of S2]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7387
      aff_dim_subset[of "affine hull S1" "affine hull S2"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7388
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7389
  moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7390
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7391
    assume eq: "aff_dim S1 = aff_dim S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7392
    then have "S1 \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7393
      using aff_dim_empty[of S1] aff_dim_empty[of S2] `S2 \<noteq> {}` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7394
    have **: "affine hull S1 = affine hull S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7395
       apply (rule affine_dim_equal)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7396
       using * affine_affine_hull
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7397
       apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7398
       using `S1 \<noteq> {}` hull_subset[of S1]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7399
       apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7400
       using eq aff_dim_affine_hull[of S1] aff_dim_affine_hull[of S2]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7401
       apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7402
       done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7403
    obtain a where a: "a \<in> rel_interior S1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7404
      using `S1 \<noteq> {}` rel_interior_convex_nonempty assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7405
    obtain T where T: "open T" "a \<in> T \<inter> S1" "T \<inter> affine hull S1 \<subseteq> S1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7406
       using mem_rel_interior[of a S1] a by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7407
    then have "a \<in> T \<inter> closure S2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7408
      using a assms unfolding rel_frontier_def by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7409
    then obtain b where b: "b \<in> T \<inter> rel_interior S2"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7410
      using open_inter_closure_rel_interior[of S2 T] assms T by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7411
    then have "b \<in> affine hull S1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7412
      using rel_interior_subset hull_subset[of S2] ** by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7413
    then have "b \<in> S1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7414
      using T b by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7415
    then have False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7416
      using b assms unfolding rel_frontier_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7417
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7418
  ultimately show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7419
    using less_le by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7420
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7421
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7422
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7423
lemma convex_rel_interior_if:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7424
  fixes S ::  "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7425
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7426
    and "z \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7427
  shows "\<forall>x\<in>affine hull S. \<exists>m. m > 1 \<and> (\<forall>e. e > 1 \<and> e \<le> m \<longrightarrow> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7428
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7429
  obtain e1 where e1: "e1 > 0 \<and> cball z e1 \<inter> affine hull S \<subseteq> S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7430
    using mem_rel_interior_cball[of z S] assms by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7431
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7432
    fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7433
    assume x: "x \<in> affine hull S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7434
    {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7435
      assume "x \<noteq> z"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7436
      def m \<equiv> "1 + e1/norm(x-z)"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  7437
      hence "m > 1" using e1 `x \<noteq> z` by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7438
      {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7439
        fix e
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7440
        assume e: "e > 1 \<and> e \<le> m"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7441
        have "z \<in> affine hull S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7442
          using assms rel_interior_subset hull_subset[of S] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7443
        then have *: "(1 - e)*\<^sub>R x + e *\<^sub>R z \<in> affine hull S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7444
          using mem_affine[of "affine hull S" x z "(1-e)" e] affine_affine_hull[of S] x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7445
          by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7446
        have "norm (z + e *\<^sub>R x - (x + e *\<^sub>R z)) = norm ((e - 1) *\<^sub>R (x - z))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7447
          by (simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7448
        also have "\<dots> = (e - 1) * norm (x-z)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7449
          using norm_scaleR e by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7450
        also have "\<dots> \<le> (m - 1) * norm (x - z)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7451
          using e mult_right_mono[of _ _ "norm(x-z)"] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7452
        also have "\<dots> = (e1 / norm (x - z)) * norm (x - z)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7453
          using m_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7454
        also have "\<dots> = e1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7455
          using `x \<noteq> z` e1 by simp
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7456
        finally have **: "norm (z + e *\<^sub>R x - (x + e *\<^sub>R z)) \<le> e1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7457
          by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7458
        have "(1 - e)*\<^sub>R x+ e *\<^sub>R z \<in> cball z e1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7459
          using m_def **
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7460
          unfolding cball_def dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7461
          by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7462
        then have "(1 - e) *\<^sub>R x+ e *\<^sub>R z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7463
          using e * e1 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7464
      }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7465
      then have "\<exists>m. m > 1 \<and> (\<forall>e. e > 1 \<and> e \<le> m \<longrightarrow> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S )"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7466
        using `m> 1 ` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7467
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7468
    moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7469
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7470
      assume "x = z"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7471
      def m \<equiv> "1 + e1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7472
      then have "m > 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7473
        using e1 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7474
      {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7475
        fix e
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7476
        assume e: "e > 1 \<and> e \<le> m"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7477
        then have "(1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7478
          using e1 x `x = z` by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7479
        then have "(1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7480
          using e by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7481
      }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7482
      then have "\<exists>m. m > 1 \<and> (\<forall>e. e > 1 \<and> e \<le> m \<longrightarrow> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7483
        using `m > 1` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7484
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7485
    ultimately have "\<exists>m. m > 1 \<and> (\<forall>e. e > 1 \<and> e \<le> m \<longrightarrow> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S )"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7486
      by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7487
  }
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7488
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7489
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7490
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7491
lemma convex_rel_interior_if2:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7492
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7493
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7494
  assumes "z \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7495
  shows "\<forall>x\<in>affine hull S. \<exists>e. e > 1 \<and> (1 - e)*\<^sub>R x + e *\<^sub>R z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7496
  using convex_rel_interior_if[of S z] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7497
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7498
lemma convex_rel_interior_only_if:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7499
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7500
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7501
    and "S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7502
  assumes "\<forall>x\<in>S. \<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7503
  shows "z \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7504
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7505
  obtain x where x: "x \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7506
    using rel_interior_convex_nonempty assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7507
  then have "x \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7508
    using rel_interior_subset by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7509
  then obtain e where e: "e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7510
    using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7511
  def y \<equiv> "(1 - e) *\<^sub>R x + e *\<^sub>R z"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7512
  then have "y \<in> S" using e by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7513
  def e1 \<equiv> "1/e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7514
  then have "0 < e1 \<and> e1 < 1" using e by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7515
  then have "z  =y - (1 - e1) *\<^sub>R (y - x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7516
    using e1_def y_def by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7517
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7518
    using rel_interior_convex_shrink[of S x y "1-e1"] `0 < e1 \<and> e1 < 1` `y \<in> S` x assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7519
    by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7520
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7521
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7522
lemma convex_rel_interior_iff:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7523
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7524
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7525
    and "S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7526
  shows "z \<in> rel_interior S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7527
  using assms hull_subset[of S "affine"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7528
    convex_rel_interior_if[of S z] convex_rel_interior_only_if[of S z]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7529
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7530
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7531
lemma convex_rel_interior_iff2:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7532
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7533
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7534
    and "S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7535
  shows "z \<in> rel_interior S \<longleftrightarrow> (\<forall>x\<in>affine hull S. \<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7536
  using assms hull_subset[of S] convex_rel_interior_if2[of S z] convex_rel_interior_only_if[of S z]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7537
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7538
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7539
lemma convex_interior_iff:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7540
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7541
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7542
  shows "z \<in> interior S \<longleftrightarrow> (\<forall>x. \<exists>e. e > 0 \<and> z + e *\<^sub>R x \<in> S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7543
proof (cases "aff_dim S = int DIM('n)")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7544
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7545
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7546
    assume "z \<in> interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7547
    then have False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7548
      using False interior_rel_interior_gen[of S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7549
  }
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7550
  moreover
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7551
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7552
    assume r: "\<forall>x. \<exists>e. e > 0 \<and> z + e *\<^sub>R x \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7553
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7554
      fix x
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7555
      obtain e1 where e1: "e1 > 0 \<and> z + e1 *\<^sub>R (x - z) \<in> S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7556
        using r by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7557
      obtain e2 where e2: "e2 > 0 \<and> z + e2 *\<^sub>R (z - x) \<in> S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7558
        using r by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7559
      def x1 \<equiv> "z + e1 *\<^sub>R (x - z)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7560
      then have x1: "x1 \<in> affine hull S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7561
        using e1 hull_subset[of S] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7562
      def x2 \<equiv> "z + e2 *\<^sub>R (z - x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7563
      then have x2: "x2 \<in> affine hull S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7564
        using e2 hull_subset[of S] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7565
      have *: "e1/(e1+e2) + e2/(e1+e2) = 1"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7566
        using add_divide_distrib[of e1 e2 "e1+e2"] e1 e2 by simp
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7567
      then have "z = (e2/(e1+e2)) *\<^sub>R x1 + (e1/(e1+e2)) *\<^sub>R x2"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7568
        using x1_def x2_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7569
        apply (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7570
        using scaleR_left_distrib[of "e1/(e1+e2)" "e2/(e1+e2)" z]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7571
        apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7572
        done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7573
      then have z: "z \<in> affine hull S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7574
        using mem_affine[of "affine hull S" x1 x2 "e2/(e1+e2)" "e1/(e1+e2)"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7575
          x1 x2 affine_affine_hull[of S] *
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7576
        by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7577
      have "x1 - x2 = (e1 + e2) *\<^sub>R (x - z)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7578
        using x1_def x2_def by (auto simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7579
      then have "x = z+(1/(e1+e2)) *\<^sub>R (x1-x2)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7580
        using e1 e2 by simp
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7581
      then have "x \<in> affine hull S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7582
        using mem_affine_3_minus[of "affine hull S" z x1 x2 "1/(e1+e2)"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7583
          x1 x2 z affine_affine_hull[of S]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7584
        by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7585
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7586
    then have "affine hull S = UNIV"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7587
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7588
    then have "aff_dim S = int DIM('n)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7589
      using aff_dim_affine_hull[of S] by (simp add: aff_dim_univ)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7590
    then have False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7591
      using False by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7592
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7593
  ultimately show ?thesis by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7594
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7595
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7596
  then have "S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7597
    using aff_dim_empty[of S] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7598
  have *: "affine hull S = UNIV"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7599
    using True affine_hull_univ by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7600
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7601
    assume "z \<in> interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7602
    then have "z \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7603
      using True interior_rel_interior_gen[of S] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7604
    then have **: "\<forall>x. \<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7605
      using convex_rel_interior_iff2[of S z] assms `S \<noteq> {}` * by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7606
    fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7607
    obtain e1 where e1: "e1 > 1" "(1 - e1) *\<^sub>R (z - x) + e1 *\<^sub>R z \<in> S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7608
      using **[rule_format, of "z-x"] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7609
    def e \<equiv> "e1 - 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7610
    then have "(1 - e1) *\<^sub>R (z - x) + e1 *\<^sub>R z = z + e *\<^sub>R x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7611
      by (simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7612
    then have "e > 0" "z + e *\<^sub>R x \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7613
      using e1 e_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7614
    then have "\<exists>e. e > 0 \<and> z + e *\<^sub>R x \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7615
      by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7616
  }
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7617
  moreover
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7618
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7619
    assume r: "\<forall>x. \<exists>e. e > 0 \<and> z + e *\<^sub>R x \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7620
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7621
      fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7622
      obtain e1 where e1: "e1 > 0" "z + e1 *\<^sub>R (z - x) \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7623
        using r[rule_format, of "z-x"] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7624
      def e \<equiv> "e1 + 1"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7625
      then have "z + e1 *\<^sub>R (z - x) = (1 - e) *\<^sub>R x + e *\<^sub>R z"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7626
        by (simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7627
      then have "e > 1" "(1 - e)*\<^sub>R x + e *\<^sub>R z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7628
        using e1 e_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7629
      then have "\<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S" by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7630
    }
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7631
    then have "z \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7632
      using convex_rel_interior_iff2[of S z] assms `S \<noteq> {}` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7633
    then have "z \<in> interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7634
      using True interior_rel_interior_gen[of S] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7635
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7636
  ultimately show ?thesis by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7637
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7638
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7639
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  7640
subsubsection {* Relative interior and closure under common operations *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7641
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7642
lemma rel_interior_inter_aux: "\<Inter>{rel_interior S |S. S : I} \<subseteq> \<Inter>I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7643
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7644
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7645
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7646
    assume "y \<in> \<Inter>{rel_interior S |S. S : I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7647
    then have y: "\<forall>S \<in> I. y \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7648
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7649
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7650
      fix S
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7651
      assume "S \<in> I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7652
      then have "y \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7653
        using rel_interior_subset y by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7654
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7655
    then have "y \<in> \<Inter>I" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7656
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7657
  then show ?thesis by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7658
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7659
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7660
lemma closure_inter: "closure (\<Inter>I) \<le> \<Inter>{closure S |S. S \<in> I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7661
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7662
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7663
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7664
    assume "y \<in> \<Inter>I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7665
    then have y: "\<forall>S \<in> I. y \<in> S" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7666
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7667
      fix S
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7668
      assume "S \<in> I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7669
      then have "y \<in> closure S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7670
        using closure_subset y by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7671
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7672
    then have "y \<in> \<Inter>{closure S |S. S \<in> I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7673
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7674
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7675
  then have "\<Inter>I \<subseteq> \<Inter>{closure S |S. S \<in> I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7676
    by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7677
  moreover have "closed (\<Inter>{closure S |S. S \<in> I})"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7678
    unfolding closed_Inter closed_closure by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7679
  ultimately show ?thesis using closure_hull[of "\<Inter>I"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7680
    hull_minimal[of "\<Inter>I" "\<Inter>{closure S |S. S \<in> I}" "closed"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7681
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7682
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7683
lemma convex_closure_rel_interior_inter:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7684
  assumes "\<forall>S\<in>I. convex (S :: 'n::euclidean_space set)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7685
    and "\<Inter>{rel_interior S |S. S \<in> I} \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7686
  shows "\<Inter>{closure S |S. S \<in> I} \<le> closure (\<Inter>{rel_interior S |S. S \<in> I})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7687
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7688
  obtain x where x: "\<forall>S\<in>I. x \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7689
    using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7690
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7691
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7692
    assume "y \<in> \<Inter>{closure S |S. S \<in> I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7693
    then have y: "\<forall>S \<in> I. y \<in> closure S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7694
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7695
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7696
      assume "y = x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7697
      then have "y \<in> closure (\<Inter>{rel_interior S |S. S \<in> I})"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7698
        using x closure_subset[of "\<Inter>{rel_interior S |S. S \<in> I}"] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7699
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7700
    moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7701
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7702
      assume "y \<noteq> x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7703
      { fix e :: real
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7704
        assume e: "e > 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7705
        def e1 \<equiv> "min 1 (e/norm (y - x))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7706
        then have e1: "e1 > 0" "e1 \<le> 1" "e1 * norm (y - x) \<le> e"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
  7707
          using `y \<noteq> x` `e > 0` le_divide_eq[of e1 e "norm (y - x)"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7708
          by simp_all
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7709
        def z \<equiv> "y - e1 *\<^sub>R (y - x)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7710
        {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7711
          fix S
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7712
          assume "S \<in> I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7713
          then have "z \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7714
            using rel_interior_closure_convex_shrink[of S x y e1] assms x y e1 z_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7715
            by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7716
        }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7717
        then have *: "z \<in> \<Inter>{rel_interior S |S. S \<in> I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7718
          by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7719
        have "\<exists>z. z \<in> \<Inter>{rel_interior S |S. S \<in> I} \<and> z \<noteq> y \<and> dist z y \<le> e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7720
          apply (rule_tac x="z" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7721
          using `y \<noteq> x` z_def * e1 e dist_norm[of z y]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7722
          apply simp
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7723
          done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7724
      }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7725
      then have "y islimpt \<Inter>{rel_interior S |S. S \<in> I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7726
        unfolding islimpt_approachable_le by blast
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7727
      then have "y \<in> closure (\<Inter>{rel_interior S |S. S \<in> I})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7728
        unfolding closure_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7729
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7730
    ultimately have "y \<in> closure (\<Inter>{rel_interior S |S. S \<in> I})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7731
      by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7732
  }
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7733
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7734
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7735
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7736
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7737
lemma convex_closure_inter:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7738
  assumes "\<forall>S\<in>I. convex (S :: 'n::euclidean_space set)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7739
    and "\<Inter>{rel_interior S |S. S \<in> I} \<noteq> {}"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7740
  shows "closure (\<Inter>I) = \<Inter>{closure S |S. S \<in> I}"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7741
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7742
  have "\<Inter>{closure S |S. S \<in> I} \<le> closure (\<Inter>{rel_interior S |S. S \<in> I})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7743
    using convex_closure_rel_interior_inter assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7744
  moreover
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7745
  have "closure (\<Inter>{rel_interior S |S. S \<in> I}) \<le> closure (\<Inter> I)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7746
    using rel_interior_inter_aux closure_mono[of "\<Inter>{rel_interior S |S. S \<in> I}" "\<Inter>I"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7747
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7748
  ultimately show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7749
    using closure_inter[of I] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7750
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7751
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7752
lemma convex_inter_rel_interior_same_closure:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7753
  assumes "\<forall>S\<in>I. convex (S :: 'n::euclidean_space set)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7754
    and "\<Inter>{rel_interior S |S. S \<in> I} \<noteq> {}"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7755
  shows "closure (\<Inter>{rel_interior S |S. S \<in> I}) = closure (\<Inter>I)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7756
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7757
  have "\<Inter>{closure S |S. S \<in> I} \<le> closure (\<Inter>{rel_interior S |S. S \<in> I})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7758
    using convex_closure_rel_interior_inter assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7759
  moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7760
  have "closure (\<Inter>{rel_interior S |S. S \<in> I}) \<le> closure (\<Inter>I)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7761
    using rel_interior_inter_aux closure_mono[of "\<Inter>{rel_interior S |S. S \<in> I}" "\<Inter>I"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7762
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7763
  ultimately show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7764
    using closure_inter[of I] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7765
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7766
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7767
lemma convex_rel_interior_inter:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7768
  assumes "\<forall>S\<in>I. convex (S :: 'n::euclidean_space set)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7769
    and "\<Inter>{rel_interior S |S. S \<in> I} \<noteq> {}"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7770
  shows "rel_interior (\<Inter>I) \<subseteq> \<Inter>{rel_interior S |S. S \<in> I}"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7771
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7772
  have "convex (\<Inter>I)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7773
    using assms convex_Inter by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7774
  moreover
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7775
  have "convex (\<Inter>{rel_interior S |S. S \<in> I})"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7776
    apply (rule convex_Inter)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7777
    using assms convex_rel_interior
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7778
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7779
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7780
  ultimately
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7781
  have "rel_interior (\<Inter>{rel_interior S |S. S \<in> I}) = rel_interior (\<Inter>I)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7782
    using convex_inter_rel_interior_same_closure assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7783
      closure_eq_rel_interior_eq[of "\<Inter>{rel_interior S |S. S \<in> I}" "\<Inter>I"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7784
    by blast
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7785
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7786
    using rel_interior_subset[of "\<Inter>{rel_interior S |S. S \<in> I}"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7787
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7788
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7789
lemma convex_rel_interior_finite_inter:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7790
  assumes "\<forall>S\<in>I. convex (S :: 'n::euclidean_space set)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7791
    and "\<Inter>{rel_interior S |S. S \<in> I} \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7792
    and "finite I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7793
  shows "rel_interior (\<Inter>I) = \<Inter>{rel_interior S |S. S \<in> I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7794
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7795
  have "\<Inter>I \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7796
    using assms rel_interior_inter_aux[of I] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7797
  have "convex (\<Inter>I)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7798
    using convex_Inter assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7799
  show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7800
  proof (cases "I = {}")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7801
    case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7802
    then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7803
      using Inter_empty rel_interior_univ2 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7804
  next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7805
    case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7806
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7807
      fix z
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7808
      assume z: "z \<in> \<Inter>{rel_interior S |S. S \<in> I}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7809
      {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7810
        fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7811
        assume x: "x \<in> Inter I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7812
        {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7813
          fix S
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7814
          assume S: "S \<in> I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7815
          then have "z \<in> rel_interior S" "x \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7816
            using z x by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7817
          then have "\<exists>m. m > 1 \<and> (\<forall>e. e > 1 \<and> e \<le> m \<longrightarrow> (1 - e)*\<^sub>R x + e *\<^sub>R z \<in> S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7818
            using convex_rel_interior_if[of S z] S assms hull_subset[of S] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7819
        }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7820
        then obtain mS where
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7821
          mS: "\<forall>S\<in>I. mS S > 1 \<and> (\<forall>e. e > 1 \<and> e \<le> mS S \<longrightarrow> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S)" by metis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7822
        def e \<equiv> "Min (mS ` I)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7823
        then have "e \<in> mS ` I" using assms `I \<noteq> {}` by simp
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7824
        then have "e > 1" using mS by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7825
        moreover have "\<forall>S\<in>I. e \<le> mS S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7826
          using e_def assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7827
        ultimately have "\<exists>e > 1. (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> \<Inter>I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7828
          using mS by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7829
      }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7830
      then have "z \<in> rel_interior (\<Inter>I)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7831
        using convex_rel_interior_iff[of "\<Inter>I" z] `\<Inter>I \<noteq> {}` `convex (\<Inter>I)` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7832
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7833
    then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7834
      using convex_rel_interior_inter[of I] assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7835
  qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7836
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7837
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7838
lemma convex_closure_inter_two:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7839
  fixes S T :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7840
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7841
    and "convex T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7842
  assumes "rel_interior S \<inter> rel_interior T \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7843
  shows "closure (S \<inter> T) = closure S \<inter> closure T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7844
  using convex_closure_inter[of "{S,T}"] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7845
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7846
lemma convex_rel_interior_inter_two:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7847
  fixes S T :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7848
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7849
    and "convex T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7850
    and "rel_interior S \<inter> rel_interior T \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7851
  shows "rel_interior (S \<inter> T) = rel_interior S \<inter> rel_interior T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7852
  using convex_rel_interior_finite_inter[of "{S,T}"] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7853
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7854
lemma convex_affine_closure_inter:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7855
  fixes S T :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7856
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7857
    and "affine T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7858
    and "rel_interior S \<inter> T \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7859
  shows "closure (S \<inter> T) = closure S \<inter> T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7860
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7861
  have "affine hull T = T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7862
    using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7863
  then have "rel_interior T = T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7864
    using rel_interior_univ[of T] by metis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7865
  moreover have "closure T = T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7866
    using assms affine_closed[of T] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7867
  ultimately show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7868
    using convex_closure_inter_two[of S T] assms affine_imp_convex by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7869
qed
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7870
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  7871
lemma convex_affine_rel_interior_inter:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7872
  fixes S T :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7873
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7874
    and "affine T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7875
    and "rel_interior S \<inter> T \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7876
  shows "rel_interior (S \<inter> T) = rel_interior S \<inter> T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7877
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7878
  have "affine hull T = T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7879
    using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7880
  then have "rel_interior T = T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7881
    using rel_interior_univ[of T] by metis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7882
  moreover have "closure T = T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7883
    using assms affine_closed[of T] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7884
  ultimately show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7885
    using convex_rel_interior_inter_two[of S T] assms affine_imp_convex by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7886
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7887
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7888
lemma subset_rel_interior_convex:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7889
  fixes S T :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7890
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7891
    and "convex T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7892
    and "S \<le> closure T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7893
    and "\<not> S \<subseteq> rel_frontier T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7894
  shows "rel_interior S \<subseteq> rel_interior T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7895
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7896
  have *: "S \<inter> closure T = S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7897
    using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7898
  have "\<not> rel_interior S \<subseteq> rel_frontier T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7899
    using closure_mono[of "rel_interior S" "rel_frontier T"] closed_rel_frontier[of T]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7900
      closure_closed[of S] convex_closure_rel_interior[of S] closure_subset[of S] assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7901
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7902
  then have "rel_interior S \<inter> rel_interior (closure T) \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7903
    using assms rel_frontier_def[of T] rel_interior_subset convex_rel_interior_closure[of T]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7904
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7905
  then have "rel_interior S \<inter> rel_interior T = rel_interior (S \<inter> closure T)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7906
    using assms convex_closure convex_rel_interior_inter_two[of S "closure T"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7907
      convex_rel_interior_closure[of T]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7908
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7909
  also have "\<dots> = rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7910
    using * by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7911
  finally show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7912
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7913
qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7914
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7915
lemma rel_interior_convex_linear_image:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7916
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7917
  assumes "linear f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7918
    and "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7919
  shows "f ` (rel_interior S) = rel_interior (f ` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7920
proof (cases "S = {}")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7921
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7922
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7923
    using assms rel_interior_empty rel_interior_convex_nonempty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7924
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7925
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7926
  have *: "f ` (rel_interior S) \<subseteq> f ` S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7927
    unfolding image_mono using rel_interior_subset by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7928
  have "f ` S \<subseteq> f ` (closure S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7929
    unfolding image_mono using closure_subset by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7930
  also have "\<dots> = f ` (closure (rel_interior S))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7931
    using convex_closure_rel_interior assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7932
  also have "\<dots> \<subseteq> closure (f ` (rel_interior S))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7933
    using closure_linear_image assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7934
  finally have "closure (f ` S) = closure (f ` rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7935
    using closure_mono[of "f ` S" "closure (f ` rel_interior S)"] closure_closure
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7936
      closure_mono[of "f ` rel_interior S" "f ` S"] *
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7937
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7938
  then have "rel_interior (f ` S) = rel_interior (f ` rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7939
    using assms convex_rel_interior
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  7940
      linear_conv_bounded_linear[of f] convex_linear_image[of _ S]
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  7941
      convex_linear_image[of _ "rel_interior S"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7942
      closure_eq_rel_interior_eq[of "f ` S" "f ` rel_interior S"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7943
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7944
  then have "rel_interior (f ` S) \<subseteq> f ` rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7945
    using rel_interior_subset by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7946
  moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7947
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7948
    fix z
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7949
    assume "z \<in> f ` rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7950
    then obtain z1 where z1: "z1 \<in> rel_interior S" "f z1 = z" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7951
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7952
      fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7953
      assume "x \<in> f ` S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7954
      then obtain x1 where x1: "x1 \<in> S" "f x1 = x" by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7955
      then obtain e where e: "e > 1" "(1 - e) *\<^sub>R x1 + e *\<^sub>R z1 : S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7956
        using convex_rel_interior_iff[of S z1] `convex S` x1 z1 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7957
      moreover have "f ((1 - e) *\<^sub>R x1 + e *\<^sub>R z1) = (1 - e) *\<^sub>R x + e *\<^sub>R z"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7958
        using x1 z1 `linear f` by (simp add: linear_add_cmul)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7959
      ultimately have "(1 - e) *\<^sub>R x + e *\<^sub>R z : f ` S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7960
        using imageI[of "(1 - e) *\<^sub>R x1 + e *\<^sub>R z1" S f] by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7961
      then have "\<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z : f ` S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7962
        using e by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7963
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7964
    then have "z \<in> rel_interior (f ` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7965
      using convex_rel_interior_iff[of "f ` S" z] `convex S`
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  7966
        `linear f` `S \<noteq> {}` convex_linear_image[of f S]  linear_conv_bounded_linear[of f]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7967
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7968
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7969
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7970
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7971
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  7972
lemma rel_interior_convex_linear_preimage:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7973
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7974
  assumes "linear f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7975
    and "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7976
    and "f -` (rel_interior S) \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7977
  shows "rel_interior (f -` S) = f -` (rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7978
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7979
  have "S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7980
    using assms rel_interior_empty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7981
  have nonemp: "f -` S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7982
    by (metis assms(3) rel_interior_subset subset_empty vimage_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7983
  then have "S \<inter> (range f) \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7984
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7985
  have conv: "convex (f -` S)"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  7986
    using convex_linear_vimage assms by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7987
  then have "convex (S \<inter> range f)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7988
    by (metis assms(1) assms(2) convex_Int subspace_UNIV subspace_imp_convex subspace_linear_image)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7989
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7990
    fix z
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7991
    assume "z \<in> f -` (rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7992
    then have z: "f z : rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7993
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7994
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7995
      fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7996
      assume "x \<in> f -` S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7997
      then have "f x \<in> S" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7998
      then obtain e where e: "e > 1" "(1 - e) *\<^sub>R f x + e *\<^sub>R f z \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  7999
        using convex_rel_interior_iff[of S "f z"] z assms `S \<noteq> {}` by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8000
      moreover have "(1 - e) *\<^sub>R f x + e *\<^sub>R f z = f ((1 - e) *\<^sub>R x + e *\<^sub>R z)"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
  8001
        using `linear f` by (simp add: linear_iff)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8002
      ultimately have "\<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> f -` S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8003
        using e by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8004
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8005
    then have "z \<in> rel_interior (f -` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8006
      using convex_rel_interior_iff[of "f -` S" z] conv nonemp by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8007
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8008
  moreover
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8009
  {
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8010
    fix z
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8011
    assume z: "z \<in> rel_interior (f -` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8012
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8013
      fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8014
      assume "x \<in> S \<inter> range f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8015
      then obtain y where y: "f y = x" "y \<in> f -` S" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8016
      then obtain e where e: "e > 1" "(1 - e) *\<^sub>R y + e *\<^sub>R z \<in> f -` S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8017
        using convex_rel_interior_iff[of "f -` S" z] z conv by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8018
      moreover have "(1 - e) *\<^sub>R x + e *\<^sub>R f z = f ((1 - e) *\<^sub>R y + e *\<^sub>R z)"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
  8019
        using `linear f` y by (simp add: linear_iff)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8020
      ultimately have "\<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R f z \<in> S \<inter> range f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8021
        using e by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8022
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8023
    then have "f z \<in> rel_interior (S \<inter> range f)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8024
      using `convex (S \<inter> (range f))` `S \<inter> range f \<noteq> {}`
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8025
        convex_rel_interior_iff[of "S \<inter> (range f)" "f z"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8026
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8027
    moreover have "affine (range f)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8028
      by (metis assms(1) subspace_UNIV subspace_imp_affine subspace_linear_image)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8029
    ultimately have "f z \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8030
      using convex_affine_rel_interior_inter[of S "range f"] assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8031
    then have "z \<in> f -` (rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8032
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8033
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8034
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8035
qed
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  8036
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8037
lemma rel_interior_direct_sum:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8038
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8039
    and T :: "'m::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8040
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8041
    and "convex T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8042
  shows "rel_interior (S \<times> T) = rel_interior S \<times> rel_interior T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8043
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8044
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8045
    assume "S = {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8046
    then have ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8047
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8048
      using rel_interior_empty
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8049
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8050
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8051
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8052
  moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8053
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8054
    assume "T = {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8055
    then have ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8056
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8057
      using rel_interior_empty
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8058
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8059
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8060
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8061
  moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8062
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8063
    assume "S \<noteq> {}" "T \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8064
    then have ri: "rel_interior S \<noteq> {}" "rel_interior T \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8065
      using rel_interior_convex_nonempty assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8066
    then have "fst -` rel_interior S \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8067
      using fst_vimage_eq_Times[of "rel_interior S"] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8068
    then have "rel_interior ((fst :: 'n * 'm \<Rightarrow> 'n) -` S) = fst -` rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8069
      using fst_linear `convex S` rel_interior_convex_linear_preimage[of fst S] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8070
    then have s: "rel_interior (S \<times> (UNIV :: 'm set)) = rel_interior S \<times> UNIV"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8071
      by (simp add: fst_vimage_eq_Times)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8072
    from ri have "snd -` rel_interior T \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8073
      using snd_vimage_eq_Times[of "rel_interior T"] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8074
    then have "rel_interior ((snd :: 'n * 'm \<Rightarrow> 'm) -` T) = snd -` rel_interior T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8075
      using snd_linear `convex T` rel_interior_convex_linear_preimage[of snd T] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8076
    then have t: "rel_interior ((UNIV :: 'n set) \<times> T) = UNIV \<times> rel_interior T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8077
      by (simp add: snd_vimage_eq_Times)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8078
    from s t have *: "rel_interior (S \<times> (UNIV :: 'm set)) \<inter> rel_interior ((UNIV :: 'n set) \<times> T) =
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8079
      rel_interior S \<times> rel_interior T" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8080
    have "S \<times> T = S \<times> (UNIV :: 'm set) \<inter> (UNIV :: 'n set) \<times> T"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8081
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8082
    then have "rel_interior (S \<times> T) = rel_interior ((S \<times> (UNIV :: 'm set)) \<inter> ((UNIV :: 'n set) \<times> T))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8083
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8084
    also have "\<dots> = rel_interior (S \<times> (UNIV :: 'm set)) \<inter> rel_interior ((UNIV :: 'n set) \<times> T)"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8085
       apply (subst convex_rel_interior_inter_two[of "S \<times> (UNIV :: 'm set)" "(UNIV :: 'n set) \<times> T"])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  8086
       using * ri assms convex_Times
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8087
       apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8088
       done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8089
    finally have ?thesis using * by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8090
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8091
  ultimately show ?thesis by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8092
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8093
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  8094
lemma rel_interior_scaleR:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8095
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8096
  assumes "c \<noteq> 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8097
  shows "(op *\<^sub>R c) ` (rel_interior S) = rel_interior ((op *\<^sub>R c) ` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8098
  using rel_interior_injective_linear_image[of "(op *\<^sub>R c)" S]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8099
    linear_conv_bounded_linear[of "op *\<^sub>R c"] linear_scaleR injective_scaleR[of c] assms
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8100
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8101
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  8102
lemma rel_interior_convex_scaleR:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8103
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8104
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8105
  shows "(op *\<^sub>R c) ` (rel_interior S) = rel_interior ((op *\<^sub>R c) ` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8106
  by (metis assms linear_scaleR rel_interior_convex_linear_image)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8107
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  8108
lemma convex_rel_open_scaleR:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8109
  fixes S :: "'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8110
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8111
    and "rel_open S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8112
  shows "convex ((op *\<^sub>R c) ` S) \<and> rel_open ((op *\<^sub>R c) ` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8113
  by (metis assms convex_scaling rel_interior_convex_scaleR rel_open_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8114
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  8115
lemma convex_rel_open_finite_inter:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8116
  assumes "\<forall>S\<in>I. convex (S :: 'n::euclidean_space set) \<and> rel_open S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8117
    and "finite I"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8118
  shows "convex (\<Inter>I) \<and> rel_open (\<Inter>I)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8119
proof (cases "\<Inter>{rel_interior S |S. S \<in> I} = {}")
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8120
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8121
  then have "\<Inter>I = {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8122
    using assms unfolding rel_open_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8123
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8124
    unfolding rel_open_def using rel_interior_empty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8125
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8126
  case False
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8127
  then have "rel_open (\<Inter>I)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8128
    using assms unfolding rel_open_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8129
    using convex_rel_interior_finite_inter[of I]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8130
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8131
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8132
    using convex_Inter assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8133
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8134
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8135
lemma convex_rel_open_linear_image:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8136
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8137
  assumes "linear f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8138
    and "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8139
    and "rel_open S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8140
  shows "convex (f ` S) \<and> rel_open (f ` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8141
  by (metis assms convex_linear_image rel_interior_convex_linear_image
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8142
    linear_conv_bounded_linear rel_open_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8143
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8144
lemma convex_rel_open_linear_preimage:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8145
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8146
  assumes "linear f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8147
    and "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8148
    and "rel_open S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8149
  shows "convex (f -` S) \<and> rel_open (f -` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8150
proof (cases "f -` (rel_interior S) = {}")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8151
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8152
  then have "f -` S = {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8153
    using assms unfolding rel_open_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8154
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8155
    unfolding rel_open_def using rel_interior_empty by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8156
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8157
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8158
  then have "rel_open (f -` S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8159
    using assms unfolding rel_open_def
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8160
    using rel_interior_convex_linear_preimage[of f S]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8161
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8162
  then show ?thesis
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  8163
    using convex_linear_vimage assms
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8164
    by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8165
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8166
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8167
lemma rel_interior_projection:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8168
  fixes S :: "('m::euclidean_space \<times> 'n::euclidean_space) set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8169
    and f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8170
  assumes "convex S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8171
    and "f = (\<lambda>y. {z. (y, z) \<in> S})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8172
  shows "(y, z) \<in> rel_interior S \<longleftrightarrow> (y \<in> rel_interior {y. (f y \<noteq> {})} \<and> z \<in> rel_interior (f y))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8173
proof -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8174
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8175
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8176
    assume "y \<in> {y. f y \<noteq> {}}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8177
    then obtain z where "(y, z) \<in> S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8178
      using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8179
    then have "\<exists>x. x \<in> S \<and> y = fst x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8180
      apply (rule_tac x="(y, z)" in exI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8181
      apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8182
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8183
    then obtain x where "x \<in> S" "y = fst x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8184
      by blast
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8185
    then have "y \<in> fst ` S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8186
      unfolding image_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8187
  }
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8188
  then have "fst ` S = {y. f y \<noteq> {}}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8189
    unfolding fst_def using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8190
  then have h1: "fst ` rel_interior S = rel_interior {y. f y \<noteq> {}}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8191
    using rel_interior_convex_linear_image[of fst S] assms fst_linear by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8192
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8193
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8194
    assume "y \<in> rel_interior {y. f y \<noteq> {}}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8195
    then have "y \<in> fst ` rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8196
      using h1 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8197
    then have *: "rel_interior S \<inter> fst -` {y} \<noteq> {}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8198
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8199
    moreover have aff: "affine (fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8200
      unfolding affine_alt by (simp add: algebra_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8201
    ultimately have **: "rel_interior (S \<inter> fst -` {y}) = rel_interior S \<inter> fst -` {y}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8202
      using convex_affine_rel_interior_inter[of S "fst -` {y}"] assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8203
    have conv: "convex (S \<inter> fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8204
      using convex_Int assms aff affine_imp_convex by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8205
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8206
      fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8207
      assume "x \<in> f y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8208
      then have "(y, x) \<in> S \<inter> (fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8209
        using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8210
      moreover have "x = snd (y, x)" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8211
      ultimately have "x \<in> snd ` (S \<inter> fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8212
        by blast
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8213
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8214
    then have "snd ` (S \<inter> fst -` {y}) = f y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8215
      using assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8216
    then have ***: "rel_interior (f y) = snd ` rel_interior (S \<inter> fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8217
      using rel_interior_convex_linear_image[of snd "S \<inter> fst -` {y}"] snd_linear conv
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8218
      by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8219
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8220
      fix z
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8221
      assume "z \<in> rel_interior (f y)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8222
      then have "z \<in> snd ` rel_interior (S \<inter> fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8223
        using *** by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8224
      moreover have "{y} = fst ` rel_interior (S \<inter> fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8225
        using * ** rel_interior_subset by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8226
      ultimately have "(y, z) \<in> rel_interior (S \<inter> fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8227
        by force
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8228
      then have "(y,z) \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8229
        using ** by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8230
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8231
    moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8232
    {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8233
      fix z
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8234
      assume "(y, z) \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8235
      then have "(y, z) \<in> rel_interior (S \<inter> fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8236
        using ** by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8237
      then have "z \<in> snd ` rel_interior (S \<inter> fst -` {y})"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8238
        by (metis Range_iff snd_eq_Range)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8239
      then have "z \<in> rel_interior (f y)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8240
        using *** by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8241
    }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8242
    ultimately have "\<And>z. (y, z) \<in> rel_interior S \<longleftrightarrow> z \<in> rel_interior (f y)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8243
      by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8244
  }
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8245
  then have h2: "\<And>y z. y \<in> rel_interior {t. f t \<noteq> {}} \<Longrightarrow>
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8246
    (y, z) \<in> rel_interior S \<longleftrightarrow> z \<in> rel_interior (f y)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8247
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8248
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8249
    fix y z
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8250
    assume asm: "(y, z) \<in> rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8251
    then have "y \<in> fst ` rel_interior S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8252
      by (metis Domain_iff fst_eq_Domain)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8253
    then have "y \<in> rel_interior {t. f t \<noteq> {}}"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8254
      using h1 by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8255
    then have "y \<in> rel_interior {t. f t \<noteq> {}}" and "(z : rel_interior (f y))"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8256
      using h2 asm by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8257
  }
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8258
  then show ?thesis using h2 by blast
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8259
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8260
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8261
44467
13e72da170fc change some subsection headings to subsubsection
huffman
parents: 44466
diff changeset
  8262
subsubsection {* Relative interior of convex cone *}
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8263
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8264
lemma cone_rel_interior:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8265
  fixes S :: "'m::euclidean_space set"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8266
  assumes "cone S"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8267
  shows "cone ({0} \<union> rel_interior S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8268
proof (cases "S = {}")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8269
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8270
  then show ?thesis
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8271
    by (simp add: rel_interior_empty cone_0)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8272
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8273
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8274
  then have *: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` S = S)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8275
    using cone_iff[of S] assms by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8276
  then have *: "0 \<in> ({0} \<union> rel_interior S)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8277
    and "\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` ({0} \<union> rel_interior S) = ({0} \<union> rel_interior S)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8278
    by (auto simp add: rel_interior_scaleR)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  8279
  then show ?thesis
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8280
    using cone_iff[of "{0} \<union> rel_interior S"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8281
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8282
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8283
lemma rel_interior_convex_cone_aux:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8284
  fixes S :: "'m::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8285
  assumes "convex S"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8286
  shows "(c, x) \<in> rel_interior (cone hull ({(1 :: real)} \<times> S)) \<longleftrightarrow>
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8287
    c > 0 \<and> x \<in> ((op *\<^sub>R c) ` (rel_interior S))"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8288
proof (cases "S = {}")
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8289
  case True
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8290
  then show ?thesis
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8291
    by (simp add: rel_interior_empty cone_hull_empty)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8292
next
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8293
  case False
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8294
  then obtain s where "s \<in> S" by auto
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8295
  have conv: "convex ({(1 :: real)} \<times> S)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8296
    using convex_Times[of "{(1 :: real)}" S] assms convex_singleton[of "1 :: real"]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8297
    by auto
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8298
  def f \<equiv> "\<lambda>y. {z. (y, z) \<in> cone hull ({1 :: real} \<times> S)}"
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8299
  then have *: "(c, x) \<in> rel_interior (cone hull ({(1 :: real)} \<times> S)) =
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8300
    (c \<in> rel_interior {y. f y \<noteq> {}} \<and> x \<in> rel_interior (f c))"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8301
    apply (subst rel_interior_projection[of "cone hull ({(1 :: real)} \<times> S)" f c x])
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8302
    using convex_cone_hull[of "{(1 :: real)} \<times> S"] conv
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8303
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8304
    done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8305
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8306
    fix y :: real
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8307
    assume "y \<ge> 0"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8308
    then have "y *\<^sub>R (1,s) \<in> cone hull ({1 :: real} \<times> S)"
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8309
      using cone_hull_expl[of "{(1 :: real)} \<times> S"] `s \<in> S` by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8310
    then have "f y \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8311
      using f_def by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8312
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8313
  then have "{y. f y \<noteq> {}} = {0..}"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8314
    using f_def cone_hull_expl[of "{1 :: real} \<times> S"] by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8315
  then have **: "rel_interior {y. f y \<noteq> {}} = {0<..}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8316
    using rel_interior_real_semiline by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8317
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8318
    fix c :: real
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8319
    assume "c > 0"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8320
    then have "f c = (op *\<^sub>R c ` S)"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8321
      using f_def cone_hull_expl[of "{1 :: real} \<times> S"] by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8322
    then have "rel_interior (f c) = op *\<^sub>R c ` rel_interior S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8323
      using rel_interior_convex_scaleR[of S c] assms by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8324
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8325
  then show ?thesis using * ** by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8326
qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8327
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8328
lemma rel_interior_convex_cone:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8329
  fixes S :: "'m::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8330
  assumes "convex S"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8331
  shows "rel_interior (cone hull ({1 :: real} \<times> S)) =
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8332
    {(c, c *\<^sub>R x) | c x. c > 0 \<and> x \<in> rel_interior S}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8333
  (is "?lhs = ?rhs")
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8334
proof -
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8335
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8336
    fix z
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8337
    assume "z \<in> ?lhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8338
    have *: "z = (fst z, snd z)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8339
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8340
    have "z \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8341
      using rel_interior_convex_cone_aux[of S "fst z" "snd z"] assms `z \<in> ?lhs`
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8342
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8343
      apply (rule_tac x = "fst z" in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8344
      apply (rule_tac x = x in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8345
      using *
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8346
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8347
      done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8348
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8349
  moreover
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8350
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8351
    fix z
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8352
    assume "z \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8353
    then have "z \<in> ?lhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8354
      using rel_interior_convex_cone_aux[of S "fst z" "snd z"] assms
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8355
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8356
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8357
  ultimately show ?thesis by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8358
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8359
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8360
lemma convex_hull_finite_union:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8361
  assumes "finite I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8362
  assumes "\<forall>i\<in>I. convex (S i) \<and> (S i) \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8363
  shows "convex hull (\<Union>(S ` I)) =
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8364
    {setsum (\<lambda>i. c i *\<^sub>R s i) I | c s. (\<forall>i\<in>I. c i \<ge> 0) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8365
  (is "?lhs = ?rhs")
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8366
proof -
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8367
  have "?lhs \<supseteq> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8368
  proof
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8369
    fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8370
    assume "x : ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8371
    then obtain c s where *: "setsum (\<lambda>i. c i *\<^sub>R s i) I = x" "setsum c I = 1"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8372
      "(\<forall>i\<in>I. c i \<ge> 0) \<and> (\<forall>i\<in>I. s i \<in> S i)" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8373
    then have "\<forall>i\<in>I. s i \<in> convex hull (\<Union>(S ` I))"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8374
      using hull_subset[of "\<Union>(S ` I)" convex] by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8375
    then show "x \<in> ?lhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8376
      unfolding *(1)[symmetric]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8377
      apply (subst convex_setsum[of I "convex hull \<Union>(S ` I)" c s])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8378
      using * assms convex_convex_hull
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8379
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8380
      done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8381
  qed
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8382
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8383
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8384
    fix i
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8385
    assume "i \<in> I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8386
    with assms have "\<exists>p. p \<in> S i" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8387
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8388
  then obtain p where p: "\<forall>i\<in>I. p i \<in> S i" by metis
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8389
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8390
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8391
    fix i
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8392
    assume "i \<in> I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8393
    {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8394
      fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8395
      assume "x \<in> S i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8396
      def c \<equiv> "\<lambda>j. if j = i then 1::real else 0"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8397
      then have *: "setsum c I = 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  8398
        using `finite I` `i \<in> I` setsum.delta[of I i "\<lambda>j::'a. 1::real"]
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8399
        by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8400
      def s \<equiv> "\<lambda>j. if j = i then x else p j"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8401
      then have "\<forall>j. c j *\<^sub>R s j = (if j = i then x else 0)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8402
        using c_def by (auto simp add: algebra_simps)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8403
      then have "x = setsum (\<lambda>i. c i *\<^sub>R s i) I"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  8404
        using s_def c_def `finite I` `i \<in> I` setsum.delta[of I i "\<lambda>j::'a. x"]
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8405
        by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8406
      then have "x \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8407
        apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8408
        apply (rule_tac x = c in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8409
        apply (rule_tac x = s in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8410
        using * c_def s_def p `x \<in> S i`
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8411
        apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8412
        done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8413
    }
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8414
    then have "?rhs \<supseteq> S i" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8415
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8416
  then have *: "?rhs \<supseteq> \<Union>(S ` I)" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8417
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8418
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8419
    fix u v :: real
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8420
    assume uv: "u \<ge> 0 \<and> v \<ge> 0 \<and> u + v = 1"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8421
    fix x y
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8422
    assume xy: "x \<in> ?rhs \<and> y \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8423
    from xy obtain c s where
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8424
      xc: "x = setsum (\<lambda>i. c i *\<^sub>R s i) I \<and> (\<forall>i\<in>I. c i \<ge> 0) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8425
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8426
    from xy obtain d t where
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8427
      yc: "y = setsum (\<lambda>i. d i *\<^sub>R t i) I \<and> (\<forall>i\<in>I. d i \<ge> 0) \<and> setsum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8428
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8429
    def e \<equiv> "\<lambda>i. u * c i + v * d i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8430
    have ge0: "\<forall>i\<in>I. e i \<ge> 0"
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  8431
      using e_def xc yc uv by simp
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8432
    have "setsum (\<lambda>i. u * c i) I = u * setsum c I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8433
      by (simp add: setsum_right_distrib)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8434
    moreover have "setsum (\<lambda>i. v * d i) I = v * setsum d I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8435
      by (simp add: setsum_right_distrib)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8436
    ultimately have sum1: "setsum e I = 1"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  8437
      using e_def xc yc uv by (simp add: setsum.distrib)
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8438
    def q \<equiv> "\<lambda>i. if e i = 0 then p i else (u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8439
    {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8440
      fix i
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8441
      assume i: "i \<in> I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8442
      have "q i \<in> S i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8443
      proof (cases "e i = 0")
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8444
        case True
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8445
        then show ?thesis using i p q_def by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8446
      next
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8447
        case False
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8448
        then show ?thesis
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8449
          using mem_convex_alt[of "S i" "s i" "t i" "u * (c i)" "v * (d i)"]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8450
            mult_nonneg_nonneg[of u "c i"] mult_nonneg_nonneg[of v "d i"]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8451
            assms q_def e_def i False xc yc uv
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  8452
          by (auto simp del: mult_nonneg_nonneg)
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8453
      qed
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8454
    }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8455
    then have qs: "\<forall>i\<in>I. q i \<in> S i" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8456
    {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8457
      fix i
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8458
      assume i: "i \<in> I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8459
      have "(u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8460
      proof (cases "e i = 0")
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8461
        case True
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8462
        have ge: "u * (c i) \<ge> 0 \<and> v * d i \<ge> 0"
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  8463
          using xc yc uv i by simp
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8464
        moreover from ge have "u * c i \<le> 0 \<and> v * d i \<le> 0"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8465
          using True e_def i by simp
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8466
        ultimately have "u * c i = 0 \<and> v * d i = 0" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8467
        with True show ?thesis by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8468
      next
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8469
        case False
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8470
        then have "(u * (c i)/(e i))*\<^sub>R (s i)+(v * (d i)/(e i))*\<^sub>R (t i) = q i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8471
          using q_def by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8472
        then have "e i *\<^sub>R ((u * (c i)/(e i))*\<^sub>R (s i)+(v * (d i)/(e i))*\<^sub>R (t i))
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8473
               = (e i) *\<^sub>R (q i)" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8474
        with False show ?thesis by (simp add: algebra_simps)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8475
      qed
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8476
    }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8477
    then have *: "\<forall>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8478
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8479
    have "u *\<^sub>R x + v *\<^sub>R y = setsum (\<lambda>i. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i) I"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  8480
      using xc yc by (simp add: algebra_simps scaleR_right.setsum setsum.distrib)
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8481
    also have "\<dots> = setsum (\<lambda>i. e i *\<^sub>R q i) I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8482
      using * by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8483
    finally have "u *\<^sub>R x + v *\<^sub>R y = setsum (\<lambda>i. (e i) *\<^sub>R (q i)) I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8484
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8485
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8486
      using ge0 sum1 qs by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8487
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8488
  then have "convex ?rhs" unfolding convex_def by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8489
  then show ?thesis
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8490
    using `?lhs \<supseteq> ?rhs` * hull_minimal[of "\<Union>(S ` I)" ?rhs convex]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8491
    by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8492
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8493
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8494
lemma convex_hull_union_two:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8495
  fixes S T :: "'m::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8496
  assumes "convex S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8497
    and "S \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8498
    and "convex T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8499
    and "T \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8500
  shows "convex hull (S \<union> T) =
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8501
    {u *\<^sub>R s + v *\<^sub>R t | u v s t. u \<ge> 0 \<and> v \<ge> 0 \<and> u + v = 1 \<and> s \<in> S \<and> t \<in> T}"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8502
  (is "?lhs = ?rhs")
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8503
proof
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8504
  def I \<equiv> "{1::nat, 2}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8505
  def s \<equiv> "\<lambda>i. if i = (1::nat) then S else T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8506
  have "\<Union>(s ` I) = S \<union> T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8507
    using s_def I_def by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8508
  then have "convex hull (\<Union>(s ` I)) = convex hull (S \<union> T)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8509
    by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8510
  moreover have "convex hull \<Union>(s ` I) =
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8511
    {\<Sum> i\<in>I. c i *\<^sub>R sa i | c sa. (\<forall>i\<in>I. 0 \<le> c i) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. sa i \<in> s i)}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8512
      apply (subst convex_hull_finite_union[of I s])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8513
      using assms s_def I_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8514
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8515
      done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8516
  moreover have
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8517
    "{\<Sum>i\<in>I. c i *\<^sub>R sa i | c sa. (\<forall>i\<in>I. 0 \<le> c i) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. sa i \<in> s i)} \<le> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8518
    using s_def I_def by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8519
  ultimately show "?lhs \<subseteq> ?rhs" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8520
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8521
    fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8522
    assume "x \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8523
    then obtain u v s t where *: "x = u *\<^sub>R s + v *\<^sub>R t \<and> u \<ge> 0 \<and> v \<ge> 0 \<and> u + v = 1 \<and> s \<in> S \<and> t \<in> T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8524
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8525
    then have "x \<in> convex hull {s, t}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8526
      using convex_hull_2[of s t] by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8527
    then have "x \<in> convex hull (S \<union> T)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8528
      using * hull_mono[of "{s, t}" "S \<union> T"] by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8529
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8530
  then show "?lhs \<supseteq> ?rhs" by blast
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8531
qed
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8532
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  8533
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8534
subsection {* Convexity on direct sums *}
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8535
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8536
lemma closure_sum:
55928
2d7582309d73 generalize lemma closure_sum
huffman
parents: 55787
diff changeset
  8537
  fixes S T :: "'a::real_normed_vector set"
47445
69e96e5500df Set_Algebras: removed syntax \<oplus> and \<otimes>, in favour of plain + and *
krauss
parents: 47444
diff changeset
  8538
  shows "closure S + closure T \<subseteq> closure (S + T)"
55928
2d7582309d73 generalize lemma closure_sum
huffman
parents: 55787
diff changeset
  8539
  unfolding set_plus_image closure_Times [symmetric] split_def
2d7582309d73 generalize lemma closure_sum
huffman
parents: 55787
diff changeset
  8540
  by (intro closure_bounded_linear_image bounded_linear_add
2d7582309d73 generalize lemma closure_sum
huffman
parents: 55787
diff changeset
  8541
    bounded_linear_fst bounded_linear_snd)
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8542
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8543
lemma rel_interior_sum:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8544
  fixes S T :: "'n::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8545
  assumes "convex S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8546
    and "convex T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8547
  shows "rel_interior (S + T) = rel_interior S + rel_interior T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8548
proof -
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8549
  have "rel_interior S + rel_interior T = (\<lambda>(x,y). x + y) ` (rel_interior S \<times> rel_interior T)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8550
    by (simp add: set_plus_image)
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8551
  also have "\<dots> = (\<lambda>(x,y). x + y) ` rel_interior (S \<times> T)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8552
    using rel_interior_direct_sum assms by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8553
  also have "\<dots> = rel_interior (S + T)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8554
    using fst_snd_linear convex_Times assms
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8555
      rel_interior_convex_linear_image[of "(\<lambda>(x,y). x + y)" "S \<times> T"]
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8556
    by (auto simp add: set_plus_image)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8557
  finally show ?thesis ..
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8558
qed
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8559
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8560
lemma rel_interior_sum_gen:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8561
  fixes S :: "'a \<Rightarrow> 'n::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8562
  assumes "\<forall>i\<in>I. convex (S i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8563
  shows "rel_interior (setsum S I) = setsum (\<lambda>i. rel_interior (S i)) I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8564
  apply (subst setsum_set_cond_linear[of convex])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8565
  using rel_interior_sum rel_interior_sing[of "0"] assms
55929
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  8566
  apply (auto simp add: convex_set_plus)
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8567
  done
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8568
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8569
lemma convex_rel_open_direct_sum:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8570
  fixes S T :: "'n::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8571
  assumes "convex S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8572
    and "rel_open S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8573
    and "convex T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8574
    and "rel_open T"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8575
  shows "convex (S \<times> T) \<and> rel_open (S \<times> T)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8576
  by (metis assms convex_Times rel_interior_direct_sum rel_open_def)
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8577
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8578
lemma convex_rel_open_sum:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8579
  fixes S T :: "'n::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8580
  assumes "convex S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8581
    and "rel_open S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8582
    and "convex T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8583
    and "rel_open T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8584
  shows "convex (S + T) \<and> rel_open (S + T)"
55929
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  8585
  by (metis assms convex_set_plus rel_interior_sum rel_open_def)
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8586
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8587
lemma convex_hull_finite_union_cones:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8588
  assumes "finite I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8589
    and "I \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8590
  assumes "\<forall>i\<in>I. convex (S i) \<and> cone (S i) \<and> S i \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8591
  shows "convex hull (\<Union>(S ` I)) = setsum S I"
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8592
  (is "?lhs = ?rhs")
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8593
proof -
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8594
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8595
    fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8596
    assume "x \<in> ?lhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8597
    then obtain c xs where
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8598
      x: "x = setsum (\<lambda>i. c i *\<^sub>R xs i) I \<and> (\<forall>i\<in>I. c i \<ge> 0) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. xs i \<in> S i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8599
      using convex_hull_finite_union[of I S] assms by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8600
    def s \<equiv> "\<lambda>i. c i *\<^sub>R xs i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8601
    {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8602
      fix i
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8603
      assume "i \<in> I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8604
      then have "s i \<in> S i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8605
        using s_def x assms mem_cone[of "S i" "xs i" "c i"] by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8606
    }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8607
    then have "\<forall>i\<in>I. s i \<in> S i" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8608
    moreover have "x = setsum s I" using x s_def by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8609
    ultimately have "x \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8610
      using set_setsum_alt[of I S] assms by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8611
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8612
  moreover
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8613
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8614
    fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8615
    assume "x \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8616
    then obtain s where x: "x = setsum s I \<and> (\<forall>i\<in>I. s i \<in> S i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8617
      using set_setsum_alt[of I S] assms by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8618
    def xs \<equiv> "\<lambda>i. of_nat(card I) *\<^sub>R s i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8619
    then have "x = setsum (\<lambda>i. ((1 :: real) / of_nat(card I)) *\<^sub>R xs i) I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8620
      using x assms by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8621
    moreover have "\<forall>i\<in>I. xs i \<in> S i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8622
      using x xs_def assms by (simp add: cone_def)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8623
    moreover have "\<forall>i\<in>I. (1 :: real) / of_nat (card I) \<ge> 0"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8624
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8625
    moreover have "setsum (\<lambda>i. (1 :: real) / of_nat (card I)) I = 1"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8626
      using assms by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8627
    ultimately have "x \<in> ?lhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8628
      apply (subst convex_hull_finite_union[of I S])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8629
      using assms
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8630
      apply blast
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8631
      using assms
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8632
      apply blast
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8633
      apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8634
      apply (rule_tac x = "(\<lambda>i. (1 :: real) / of_nat (card I))" in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8635
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8636
      done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8637
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8638
  ultimately show ?thesis by auto
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8639
qed
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8640
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8641
lemma convex_hull_union_cones_two:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8642
  fixes S T :: "'m::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8643
  assumes "convex S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8644
    and "cone S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8645
    and "S \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8646
  assumes "convex T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8647
    and "cone T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8648
    and "T \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8649
  shows "convex hull (S \<union> T) = S + T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8650
proof -
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8651
  def I \<equiv> "{1::nat, 2}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8652
  def A \<equiv> "(\<lambda>i. if i = (1::nat) then S else T)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8653
  have "\<Union>(A ` I) = S \<union> T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8654
    using A_def I_def by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8655
  then have "convex hull (\<Union>(A ` I)) = convex hull (S \<union> T)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8656
    by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8657
  moreover have "convex hull \<Union>(A ` I) = setsum A I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8658
    apply (subst convex_hull_finite_union_cones[of I A])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8659
    using assms A_def I_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8660
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8661
    done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8662
  moreover have "setsum A I = S + T"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8663
    using A_def I_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8664
    unfolding set_plus_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8665
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8666
    unfolding set_plus_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8667
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8668
    done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8669
  ultimately show ?thesis by auto
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8670
qed
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8671
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8672
lemma rel_interior_convex_hull_union:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8673
  fixes S :: "'a \<Rightarrow> 'n::euclidean_space set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8674
  assumes "finite I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8675
    and "\<forall>i\<in>I. convex (S i) \<and> S i \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8676
  shows "rel_interior (convex hull (\<Union>(S ` I))) =
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8677
    {setsum (\<lambda>i. c i *\<^sub>R s i) I | c s. (\<forall>i\<in>I. c i > 0) \<and> setsum c I = 1 \<and>
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8678
      (\<forall>i\<in>I. s i \<in> rel_interior(S i))}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8679
  (is "?lhs = ?rhs")
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8680
proof (cases "I = {}")
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8681
  case True
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8682
  then show ?thesis
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8683
    using convex_hull_empty rel_interior_empty by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8684
next
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8685
  case False
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8686
  def C0 \<equiv> "convex hull (\<Union>(S ` I))"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8687
  have "\<forall>i\<in>I. C0 \<ge> S i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8688
    unfolding C0_def using hull_subset[of "\<Union>(S ` I)"] by auto
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8689
  def K0 \<equiv> "cone hull ({1 :: real} \<times> C0)"
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8690
  def K \<equiv> "\<lambda>i. cone hull ({1 :: real} \<times> S i)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8691
  have "\<forall>i\<in>I. K i \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8692
    unfolding K_def using assms
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8693
    by (simp add: cone_hull_empty_iff[symmetric])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8694
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8695
    fix i
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8696
    assume "i \<in> I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8697
    then have "convex (K i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8698
      unfolding K_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8699
      apply (subst convex_cone_hull)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8700
      apply (subst convex_Times)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8701
      using assms
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8702
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8703
      done
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8704
  }
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8705
  then have convK: "\<forall>i\<in>I. convex (K i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8706
    by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8707
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8708
    fix i
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8709
    assume "i \<in> I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8710
    then have "K0 \<supseteq> K i"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8711
      unfolding K0_def K_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8712
      apply (subst hull_mono)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8713
      using `\<forall>i\<in>I. C0 \<ge> S i`
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8714
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8715
      done
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8716
  }
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8717
  then have "K0 \<supseteq> \<Union>(K ` I)" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8718
  moreover have "convex K0"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8719
    unfolding K0_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8720
    apply (subst convex_cone_hull)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8721
    apply (subst convex_Times)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8722
    unfolding C0_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8723
    using convex_convex_hull
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8724
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8725
    done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8726
  ultimately have geq: "K0 \<supseteq> convex hull (\<Union>(K ` I))"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8727
    using hull_minimal[of _ "K0" "convex"] by blast
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8728
  have "\<forall>i\<in>I. K i \<supseteq> {1 :: real} \<times> S i"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8729
    using K_def by (simp add: hull_subset)
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8730
  then have "\<Union>(K ` I) \<supseteq> {1 :: real} \<times> \<Union>(S ` I)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8731
    by auto
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8732
  then have "convex hull \<Union>(K ` I) \<supseteq> convex hull ({1 :: real} \<times> \<Union>(S ` I))"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8733
    by (simp add: hull_mono)
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8734
  then have "convex hull \<Union>(K ` I) \<supseteq> {1 :: real} \<times> C0"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8735
    unfolding C0_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8736
    using convex_hull_Times[of "{(1 :: real)}" "\<Union>(S ` I)"] convex_hull_singleton
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8737
    by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8738
  moreover have "cone (convex hull (\<Union>(K ` I)))"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8739
    apply (subst cone_convex_hull)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8740
    using cone_Union[of "K ` I"]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8741
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8742
    unfolding K_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8743
    using cone_cone_hull
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8744
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8745
    done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8746
  ultimately have "convex hull (\<Union>(K ` I)) \<supseteq> K0"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8747
    unfolding K0_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8748
    using hull_minimal[of _ "convex hull (\<Union> (K ` I))" "cone"]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8749
    by blast
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8750
  then have "K0 = convex hull (\<Union>(K ` I))"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8751
    using geq by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8752
  also have "\<dots> = setsum K I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8753
    apply (subst convex_hull_finite_union_cones[of I K])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8754
    using assms
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8755
    apply blast
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8756
    using False
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8757
    apply blast
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8758
    unfolding K_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8759
    apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8760
    apply (subst convex_cone_hull)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8761
    apply (subst convex_Times)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8762
    using assms cone_cone_hull `\<forall>i\<in>I. K i \<noteq> {}` K_def
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8763
    apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8764
    done
47444
d21c95af2df7 removed "setsum_set", now subsumed by generic setsum
krauss
parents: 47108
diff changeset
  8765
  finally have "K0 = setsum K I" by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8766
  then have *: "rel_interior K0 = setsum (\<lambda>i. (rel_interior (K i))) I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8767
    using rel_interior_sum_gen[of I K] convK by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8768
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8769
    fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8770
    assume "x \<in> ?lhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8771
    then have "(1::real, x) \<in> rel_interior K0"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8772
      using K0_def C0_def rel_interior_convex_cone_aux[of C0 "1::real" x] convex_convex_hull
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8773
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8774
    then obtain k where k: "(1::real, x) = setsum k I \<and> (\<forall>i\<in>I. k i \<in> rel_interior (K i))"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8775
      using `finite I` * set_setsum_alt[of I "\<lambda>i. rel_interior (K i)"] by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8776
    {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8777
      fix i
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8778
      assume "i \<in> I"
55787
41a73a41f6c8 more symbols;
wenzelm
parents: 55697
diff changeset
  8779
      then have "convex (S i) \<and> k i \<in> rel_interior (cone hull {1} \<times> S i)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8780
        using k K_def assms by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8781
      then have "\<exists>ci si. k i = (ci, ci *\<^sub>R si) \<and> 0 < ci \<and> si \<in> rel_interior (S i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8782
        using rel_interior_convex_cone[of "S i"] by auto
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8783
    }
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8784
    then obtain c s where
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8785
      cs: "\<forall>i\<in>I. k i = (c i, c i *\<^sub>R s i) \<and> 0 < c i \<and> s i \<in> rel_interior (S i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8786
      by metis
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8787
    then have "x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> setsum c I = 1"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8788
      using k by (simp add: setsum_prod)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8789
    then have "x \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8790
      using k
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8791
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8792
      apply (rule_tac x = c in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8793
      apply (rule_tac x = s in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8794
      using cs
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8795
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8796
      done
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8797
  }
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8798
  moreover
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8799
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8800
    fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8801
    assume "x \<in> ?rhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8802
    then obtain c s where cs: "x = setsum (\<lambda>i. c i *\<^sub>R s i) I \<and>
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8803
        (\<forall>i\<in>I. c i > 0) \<and> setsum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> rel_interior (S i))"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8804
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8805
    def k \<equiv> "\<lambda>i. (c i, c i *\<^sub>R s i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8806
    {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8807
      fix i assume "i:I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8808
      then have "k i \<in> rel_interior (K i)"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8809
        using k_def K_def assms cs rel_interior_convex_cone[of "S i"]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8810
        by auto
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8811
    }
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8812
    then have "(1::real, x) \<in> rel_interior K0"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8813
      using K0_def * set_setsum_alt[of I "(\<lambda>i. rel_interior (K i))"] assms k_def cs
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8814
      apply auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8815
      apply (rule_tac x = k in exI)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8816
      apply (simp add: setsum_prod)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8817
      done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8818
    then have "x \<in> ?lhs"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8819
      using K0_def C0_def rel_interior_convex_cone_aux[of C0 1 x]
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8820
      by (auto simp add: convex_convex_hull)
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8821
  }
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8822
  ultimately show ?thesis by blast
40887
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8823
qed
ee8d0548c148 Prove rel_interior_convex_hull_union (by Grechuck Bogdan).
hoelzl
parents: 40719
diff changeset
  8824
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8825
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8826
lemma convex_le_Inf_differential:
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8827
  fixes f :: "real \<Rightarrow> real"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8828
  assumes "convex_on I f"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8829
    and "x \<in> interior I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8830
    and "y \<in> I"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8831
  shows "f y \<ge> f x + Inf ((\<lambda>t. (f x - f t) / (x - t)) ` ({x<..} \<inter> I)) * (y - x)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8832
  (is "_ \<ge> _ + Inf (?F x) * (y - x)")
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8833
proof (cases rule: linorder_cases)
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8834
  assume "x < y"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8835
  moreover
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8836
  have "open (interior I)" by auto
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  8837
  from openE[OF this `x \<in> interior I`]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  8838
  obtain e where e: "0 < e" "ball x e \<subseteq> interior I" .
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8839
  moreover def t \<equiv> "min (x + e / 2) ((x + y) / 2)"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8840
  ultimately have "x < t" "t < y" "t \<in> ball x e"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8841
    by (auto simp: dist_real_def field_simps split: split_min)
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8842
  with `x \<in> interior I` e interior_subset[of I] have "t \<in> I" "x \<in> I" by auto
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8843
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8844
  have "open (interior I)" by auto
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  8845
  from openE[OF this `x \<in> interior I`]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  8846
  obtain e where "0 < e" "ball x e \<subseteq> interior I" .
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8847
  moreover def K \<equiv> "x - e / 2"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8848
  with `0 < e` have "K \<in> ball x e" "K < x"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8849
    by (auto simp: dist_real_def)
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8850
  ultimately have "K \<in> I" "K < x" "x \<in> I"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8851
    using interior_subset[of I] `x \<in> interior I` by auto
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8852
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8853
  have "Inf (?F x) \<le> (f x - f y) / (x - y)"
54258
adfc759263ab use bdd_above and bdd_below for conditionally complete lattices
hoelzl
parents: 54230
diff changeset
  8854
  proof (intro bdd_belowI cInf_lower2)
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8855
    show "(f x - f t) / (x - t) \<in> ?F x"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8856
      using `t \<in> I` `x < t` by auto
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8857
    show "(f x - f t) / (x - t) \<le> (f x - f y) / (x - y)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8858
      using `convex_on I f` `x \<in> I` `y \<in> I` `x < t` `t < y`
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8859
      by (rule convex_on_diff)
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8860
  next
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8861
    fix y
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8862
    assume "y \<in> ?F x"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8863
    with order_trans[OF convex_on_diff[OF `convex_on I f` `K \<in> I` _ `K < x` _]]
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8864
    show "(f K - f x) / (K - x) \<le> y" by auto
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8865
  qed
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8866
  then show ?thesis
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8867
    using `x < y` by (simp add: field_simps)
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8868
next
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8869
  assume "y < x"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8870
  moreover
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8871
  have "open (interior I)" by auto
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  8872
  from openE[OF this `x \<in> interior I`]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  8873
  obtain e where e: "0 < e" "ball x e \<subseteq> interior I" .
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8874
  moreover def t \<equiv> "x + e / 2"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8875
  ultimately have "x < t" "t \<in> ball x e"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8876
    by (auto simp: dist_real_def field_simps)
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8877
  with `x \<in> interior I` e interior_subset[of I] have "t \<in> I" "x \<in> I" by auto
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8878
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8879
  have "(f x - f y) / (x - y) \<le> Inf (?F x)"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50979
diff changeset
  8880
  proof (rule cInf_greatest)
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8881
    have "(f x - f y) / (x - y) = (f y - f x) / (y - x)"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8882
      using `y < x` by (auto simp: field_simps)
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8883
    also
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8884
    fix z
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8885
    assume "z \<in> ?F x"
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8886
    with order_trans[OF convex_on_diff[OF `convex_on I f` `y \<in> I` _ `y < x`]]
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8887
    have "(f y - f x) / (y - x) \<le> z"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8888
      by auto
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8889
    finally show "(f x - f y) / (x - y) \<le> z" .
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8890
  next
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8891
    have "open (interior I)" by auto
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  8892
    from openE[OF this `x \<in> interior I`]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  8893
    obtain e where e: "0 < e" "ball x e \<subseteq> interior I" .
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8894
    then have "x + e / 2 \<in> ball x e"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8895
      by (auto simp: dist_real_def)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8896
    with e interior_subset[of I] have "x + e / 2 \<in> {x<..} \<inter> I"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8897
      by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8898
    then show "?F x \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  8899
      by blast
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8900
  qed
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8901
  then show ?thesis
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8902
    using `y < x` by (simp add: field_simps)
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8903
qed simp
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49962
diff changeset
  8904
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  8905
end