src/HOL/Analysis/Convex.thy
author nipkow
Fri, 29 Nov 2019 15:06:04 +0100
changeset 71174 7fac205dd737
parent 71136 f636d31f3616
child 71240 67880e7ee08d
permissions -rw-r--r--
tuned
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
70086
72c52a897de2 First tranche of the Homology development: Simplices
paulson <lp15@cam.ac.uk>
parents: 69802
diff changeset
     1
(* Title:      HOL/Analysis/Convex.thy
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
     2
   Author:     L C Paulson, University of Cambridge
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
     3
   Author:     Robert Himmelmann, TU Muenchen
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
     4
   Author:     Bogdan Grechuk, University of Edinburgh
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
     5
   Author:     Armin Heller, TU Muenchen
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
     6
   Author:     Johannes Hoelzl, TU Muenchen
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
     7
*)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
     8
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
     9
section \<open>Convex Sets and Functions\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    10
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    11
theory Convex
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    12
imports
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    13
  Linear_Algebra
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    14
  "HOL-Library.Set_Algebras"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    15
begin
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    16
71044
nipkow
parents: 71040
diff changeset
    17
subsection \<open>Convex Sets\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    18
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
    19
definition\<^marker>\<open>tag important\<close> convex :: "'a::real_vector set \<Rightarrow> bool"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    20
  where "convex s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    21
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    22
lemma convexI:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    23
  assumes "\<And>x y u v. x \<in> s \<Longrightarrow> y \<in> s \<Longrightarrow> 0 \<le> u \<Longrightarrow> 0 \<le> v \<Longrightarrow> u + v = 1 \<Longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    24
  shows "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    25
  using assms unfolding convex_def by fast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    26
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    27
lemma convexD:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    28
  assumes "convex s" and "x \<in> s" and "y \<in> s" and "0 \<le> u" and "0 \<le> v" and "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    29
  shows "u *\<^sub>R x + v *\<^sub>R y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    30
  using assms unfolding convex_def by fast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    31
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    32
lemma convex_alt: "convex s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u. 0 \<le> u \<and> u \<le> 1 \<longrightarrow> ((1 - u) *\<^sub>R x + u *\<^sub>R y) \<in> s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    33
  (is "_ \<longleftrightarrow> ?alt")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    34
proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    35
  show "convex s" if alt: ?alt
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    36
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    37
    {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    38
      fix x y and u v :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    39
      assume mem: "x \<in> s" "y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    40
      assume "0 \<le> u" "0 \<le> v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    41
      moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    42
      assume "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    43
      then have "u = 1 - v" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    44
      ultimately have "u *\<^sub>R x + v *\<^sub>R y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    45
        using alt [rule_format, OF mem] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    46
    }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    47
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    48
      unfolding convex_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    49
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    50
  show ?alt if "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    51
    using that by (auto simp: convex_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    52
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    53
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    54
lemma convexD_alt:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    55
  assumes "convex s" "a \<in> s" "b \<in> s" "0 \<le> u" "u \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    56
  shows "((1 - u) *\<^sub>R a + u *\<^sub>R b) \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    57
  using assms unfolding convex_alt by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    58
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    59
lemma mem_convex_alt:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    60
  assumes "convex S" "x \<in> S" "y \<in> S" "u \<ge> 0" "v \<ge> 0" "u + v > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    61
  shows "((u/(u+v)) *\<^sub>R x + (v/(u+v)) *\<^sub>R y) \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    62
  apply (rule convexD)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    63
  using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    64
       apply (simp_all add: zero_le_divide_iff add_divide_distrib [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    65
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    66
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    67
lemma convex_empty[intro,simp]: "convex {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    68
  unfolding convex_def by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    69
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    70
lemma convex_singleton[intro,simp]: "convex {a}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    71
  unfolding convex_def by (auto simp: scaleR_left_distrib[symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    72
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    73
lemma convex_UNIV[intro,simp]: "convex UNIV"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    74
  unfolding convex_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    75
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    76
lemma convex_Inter: "(\<And>s. s\<in>f \<Longrightarrow> convex s) \<Longrightarrow> convex(\<Inter>f)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    77
  unfolding convex_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    78
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    79
lemma convex_Int: "convex s \<Longrightarrow> convex t \<Longrightarrow> convex (s \<inter> t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    80
  unfolding convex_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    81
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    82
lemma convex_INT: "(\<And>i. i \<in> A \<Longrightarrow> convex (B i)) \<Longrightarrow> convex (\<Inter>i\<in>A. B i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    83
  unfolding convex_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    84
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    85
lemma convex_Times: "convex s \<Longrightarrow> convex t \<Longrightarrow> convex (s \<times> t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    86
  unfolding convex_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    87
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    88
lemma convex_halfspace_le: "convex {x. inner a x \<le> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    89
  unfolding convex_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    90
  by (auto simp: inner_add intro!: convex_bound_le)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    91
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    92
lemma convex_halfspace_ge: "convex {x. inner a x \<ge> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    93
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    94
  have *: "{x. inner a x \<ge> b} = {x. inner (-a) x \<le> -b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    95
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    96
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    97
    unfolding * using convex_halfspace_le[of "-a" "-b"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    98
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
    99
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   100
lemma convex_halfspace_abs_le: "convex {x. \<bar>inner a x\<bar> \<le> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   101
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   102
  have *: "{x. \<bar>inner a x\<bar> \<le> b} = {x. inner a x \<le> b} \<inter> {x. -b \<le> inner a x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   103
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   104
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   105
    unfolding * by (simp add: convex_Int convex_halfspace_ge convex_halfspace_le)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   106
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   107
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   108
lemma convex_hyperplane: "convex {x. inner a x = b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   109
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   110
  have *: "{x. inner a x = b} = {x. inner a x \<le> b} \<inter> {x. inner a x \<ge> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   111
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   112
  show ?thesis using convex_halfspace_le convex_halfspace_ge
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   113
    by (auto intro!: convex_Int simp: *)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   114
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   115
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   116
lemma convex_halfspace_lt: "convex {x. inner a x < b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   117
  unfolding convex_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   118
  by (auto simp: convex_bound_lt inner_add)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   119
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   120
lemma convex_halfspace_gt: "convex {x. inner a x > b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   121
  using convex_halfspace_lt[of "-a" "-b"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   122
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   123
lemma convex_halfspace_Re_ge: "convex {x. Re x \<ge> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   124
  using convex_halfspace_ge[of b "1::complex"] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   125
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   126
lemma convex_halfspace_Re_le: "convex {x. Re x \<le> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   127
  using convex_halfspace_le[of "1::complex" b] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   128
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   129
lemma convex_halfspace_Im_ge: "convex {x. Im x \<ge> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   130
  using convex_halfspace_ge[of b \<i>] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   131
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   132
lemma convex_halfspace_Im_le: "convex {x. Im x \<le> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   133
  using convex_halfspace_le[of \<i> b] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   134
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   135
lemma convex_halfspace_Re_gt: "convex {x. Re x > b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   136
  using convex_halfspace_gt[of b "1::complex"] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   137
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   138
lemma convex_halfspace_Re_lt: "convex {x. Re x < b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   139
  using convex_halfspace_lt[of "1::complex" b] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   140
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   141
lemma convex_halfspace_Im_gt: "convex {x. Im x > b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   142
  using convex_halfspace_gt[of b \<i>] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   143
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   144
lemma convex_halfspace_Im_lt: "convex {x. Im x < b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   145
  using convex_halfspace_lt[of \<i> b] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   146
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   147
lemma convex_real_interval [iff]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   148
  fixes a b :: "real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   149
  shows "convex {a..}" and "convex {..b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   150
    and "convex {a<..}" and "convex {..<b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   151
    and "convex {a..b}" and "convex {a<..b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   152
    and "convex {a..<b}" and "convex {a<..<b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   153
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   154
  have "{a..} = {x. a \<le> inner 1 x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   155
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   156
  then show 1: "convex {a..}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   157
    by (simp only: convex_halfspace_ge)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   158
  have "{..b} = {x. inner 1 x \<le> b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   159
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   160
  then show 2: "convex {..b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   161
    by (simp only: convex_halfspace_le)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   162
  have "{a<..} = {x. a < inner 1 x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   163
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   164
  then show 3: "convex {a<..}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   165
    by (simp only: convex_halfspace_gt)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   166
  have "{..<b} = {x. inner 1 x < b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   167
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   168
  then show 4: "convex {..<b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   169
    by (simp only: convex_halfspace_lt)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   170
  have "{a..b} = {a..} \<inter> {..b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   171
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   172
  then show "convex {a..b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   173
    by (simp only: convex_Int 1 2)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   174
  have "{a<..b} = {a<..} \<inter> {..b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   175
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   176
  then show "convex {a<..b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   177
    by (simp only: convex_Int 3 2)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   178
  have "{a..<b} = {a..} \<inter> {..<b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   179
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   180
  then show "convex {a..<b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   181
    by (simp only: convex_Int 1 4)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   182
  have "{a<..<b} = {a<..} \<inter> {..<b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   183
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   184
  then show "convex {a<..<b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   185
    by (simp only: convex_Int 3 4)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   186
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   187
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   188
lemma convex_Reals: "convex \<real>"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   189
  by (simp add: convex_def scaleR_conv_of_real)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   190
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   191
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
   192
subsection\<^marker>\<open>tag unimportant\<close> \<open>Explicit expressions for convexity in terms of arbitrary sums\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   193
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   194
lemma convex_sum:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   195
  fixes C :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   196
  assumes "finite s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   197
    and "convex C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   198
    and "(\<Sum> i \<in> s. a i) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   199
  assumes "\<And>i. i \<in> s \<Longrightarrow> a i \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   200
    and "\<And>i. i \<in> s \<Longrightarrow> y i \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   201
  shows "(\<Sum> j \<in> s. a j *\<^sub>R y j) \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   202
  using assms(1,3,4,5)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   203
proof (induct arbitrary: a set: finite)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   204
  case empty
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   205
  then show ?case by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   206
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   207
  case (insert i s) note IH = this(3)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   208
  have "a i + sum a s = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   209
    and "0 \<le> a i"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   210
    and "\<forall>j\<in>s. 0 \<le> a j"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   211
    and "y i \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   212
    and "\<forall>j\<in>s. y j \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   213
    using insert.hyps(1,2) insert.prems by simp_all
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   214
  then have "0 \<le> sum a s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   215
    by (simp add: sum_nonneg)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   216
  have "a i *\<^sub>R y i + (\<Sum>j\<in>s. a j *\<^sub>R y j) \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   217
  proof (cases "sum a s = 0")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   218
    case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   219
    with \<open>a i + sum a s = 1\<close> have "a i = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   220
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   221
    from sum_nonneg_0 [OF \<open>finite s\<close> _ True] \<open>\<forall>j\<in>s. 0 \<le> a j\<close> have "\<forall>j\<in>s. a j = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   222
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   223
    show ?thesis using \<open>a i = 1\<close> and \<open>\<forall>j\<in>s. a j = 0\<close> and \<open>y i \<in> C\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   224
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   225
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   226
    case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   227
    with \<open>0 \<le> sum a s\<close> have "0 < sum a s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   228
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   229
    then have "(\<Sum>j\<in>s. (a j / sum a s) *\<^sub>R y j) \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   230
      using \<open>\<forall>j\<in>s. 0 \<le> a j\<close> and \<open>\<forall>j\<in>s. y j \<in> C\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   231
      by (simp add: IH sum_divide_distrib [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   232
    from \<open>convex C\<close> and \<open>y i \<in> C\<close> and this and \<open>0 \<le> a i\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   233
      and \<open>0 \<le> sum a s\<close> and \<open>a i + sum a s = 1\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   234
    have "a i *\<^sub>R y i + sum a s *\<^sub>R (\<Sum>j\<in>s. (a j / sum a s) *\<^sub>R y j) \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   235
      by (rule convexD)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   236
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   237
      by (simp add: scaleR_sum_right False)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   238
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   239
  then show ?case using \<open>finite s\<close> and \<open>i \<notin> s\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   240
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   241
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   242
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   243
lemma convex:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   244
  "convex s \<longleftrightarrow> (\<forall>(k::nat) u x. (\<forall>i. 1\<le>i \<and> i\<le>k \<longrightarrow> 0 \<le> u i \<and> x i \<in>s) \<and> (sum u {1..k} = 1)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   245
      \<longrightarrow> sum (\<lambda>i. u i *\<^sub>R x i) {1..k} \<in> s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   246
proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   247
  fix k :: nat
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   248
  fix u :: "nat \<Rightarrow> real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   249
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   250
  assume "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   251
    "\<forall>i. 1 \<le> i \<and> i \<le> k \<longrightarrow> 0 \<le> u i \<and> x i \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   252
    "sum u {1..k} = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   253
  with convex_sum[of "{1 .. k}" s] show "(\<Sum>j\<in>{1 .. k}. u j *\<^sub>R x j) \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   254
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   255
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   256
  assume *: "\<forall>k u x. (\<forall> i :: nat. 1 \<le> i \<and> i \<le> k \<longrightarrow> 0 \<le> u i \<and> x i \<in> s) \<and> sum u {1..k} = 1
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   257
    \<longrightarrow> (\<Sum>i = 1..k. u i *\<^sub>R (x i :: 'a)) \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   258
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   259
    fix \<mu> :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   260
    fix x y :: 'a
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   261
    assume xy: "x \<in> s" "y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   262
    assume mu: "\<mu> \<ge> 0" "\<mu> \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   263
    let ?u = "\<lambda>i. if (i :: nat) = 1 then \<mu> else 1 - \<mu>"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   264
    let ?x = "\<lambda>i. if (i :: nat) = 1 then x else y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   265
    have "{1 :: nat .. 2} \<inter> - {x. x = 1} = {2}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   266
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   267
    then have card: "card ({1 :: nat .. 2} \<inter> - {x. x = 1}) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   268
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   269
    then have "sum ?u {1 .. 2} = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   270
      using sum.If_cases[of "{(1 :: nat) .. 2}" "\<lambda> x. x = 1" "\<lambda> x. \<mu>" "\<lambda> x. 1 - \<mu>"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   271
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   272
    with *[rule_format, of "2" ?u ?x] have s: "(\<Sum>j \<in> {1..2}. ?u j *\<^sub>R ?x j) \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   273
      using mu xy by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   274
    have grarr: "(\<Sum>j \<in> {Suc (Suc 0)..2}. ?u j *\<^sub>R ?x j) = (1 - \<mu>) *\<^sub>R y"
70097
4005298550a6 The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
paulson <lp15@cam.ac.uk>
parents: 70086
diff changeset
   275
      using sum.atLeast_Suc_atMost[of "Suc (Suc 0)" 2 "\<lambda> j. (1 - \<mu>) *\<^sub>R y"] by auto
4005298550a6 The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
paulson <lp15@cam.ac.uk>
parents: 70086
diff changeset
   276
    from sum.atLeast_Suc_atMost[of "Suc 0" 2 "\<lambda> j. ?u j *\<^sub>R ?x j", simplified this]
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   277
    have "(\<Sum>j \<in> {1..2}. ?u j *\<^sub>R ?x j) = \<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   278
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   279
    then have "(1 - \<mu>) *\<^sub>R y + \<mu> *\<^sub>R x \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   280
      using s by (auto simp: add.commute)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   281
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   282
  then show "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   283
    unfolding convex_alt by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   284
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   285
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   286
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   287
lemma convex_explicit:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   288
  fixes s :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   289
  shows "convex s \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   290
    (\<forall>t u. finite t \<and> t \<subseteq> s \<and> (\<forall>x\<in>t. 0 \<le> u x) \<and> sum u t = 1 \<longrightarrow> sum (\<lambda>x. u x *\<^sub>R x) t \<in> s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   291
proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   292
  fix t
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   293
  fix u :: "'a \<Rightarrow> real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   294
  assume "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   295
    and "finite t"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   296
    and "t \<subseteq> s" "\<forall>x\<in>t. 0 \<le> u x" "sum u t = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   297
  then show "(\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   298
    using convex_sum[of t s u "\<lambda> x. x"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   299
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   300
  assume *: "\<forall>t. \<forall> u. finite t \<and> t \<subseteq> s \<and> (\<forall>x\<in>t. 0 \<le> u x) \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   301
    sum u t = 1 \<longrightarrow> (\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   302
  show "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   303
    unfolding convex_alt
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   304
  proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   305
    fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   306
    fix \<mu> :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   307
    assume **: "x \<in> s" "y \<in> s" "0 \<le> \<mu>" "\<mu> \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   308
    show "(1 - \<mu>) *\<^sub>R x + \<mu> *\<^sub>R y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   309
    proof (cases "x = y")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   310
      case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   311
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   312
        using *[rule_format, of "{x, y}" "\<lambda> z. if z = x then 1 - \<mu> else \<mu>"] **
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   313
        by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   314
    next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   315
      case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   316
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   317
        using *[rule_format, of "{x, y}" "\<lambda> z. 1"] **
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   318
        by (auto simp: field_simps real_vector.scale_left_diff_distrib)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   319
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   320
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   321
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   322
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   323
lemma convex_finite:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   324
  assumes "finite s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   325
  shows "convex s \<longleftrightarrow> (\<forall>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<longrightarrow> sum (\<lambda>x. u x *\<^sub>R x) s \<in> s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   326
  unfolding convex_explicit
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   327
  apply safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   328
  subgoal for u by (erule allE [where x=s], erule allE [where x=u]) auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   329
  subgoal for t u
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   330
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   331
    have if_distrib_arg: "\<And>P f g x. (if P then f else g) x = (if P then f x else g x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   332
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   333
    assume sum: "\<forall>u. (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<longrightarrow> (\<Sum>x\<in>s. u x *\<^sub>R x) \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   334
    assume *: "\<forall>x\<in>t. 0 \<le> u x" "sum u t = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   335
    assume "t \<subseteq> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   336
    then have "s \<inter> t = t" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   337
    with sum[THEN spec[where x="\<lambda>x. if x\<in>t then u x else 0"]] * show "(\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   338
      by (auto simp: assms sum.If_cases if_distrib if_distrib_arg)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   339
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   340
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   341
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   342
71044
nipkow
parents: 71040
diff changeset
   343
subsection \<open>Convex Functions on a Set\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   344
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
   345
definition\<^marker>\<open>tag important\<close> convex_on :: "'a::real_vector set \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> bool"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   346
  where "convex_on s f \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   347
    (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> f (u *\<^sub>R x + v *\<^sub>R y) \<le> u * f x + v * f y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   348
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   349
lemma convex_onI [intro?]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   350
  assumes "\<And>t x y. t > 0 \<Longrightarrow> t < 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   351
    f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   352
  shows "convex_on A f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   353
  unfolding convex_on_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   354
proof clarify
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   355
  fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   356
  fix u v :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   357
  assume A: "x \<in> A" "y \<in> A" "u \<ge> 0" "v \<ge> 0" "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   358
  from A(5) have [simp]: "v = 1 - u"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   359
    by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   360
  from A(1-4) show "f (u *\<^sub>R x + v *\<^sub>R y) \<le> u * f x + v * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   361
    using assms[of u y x]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   362
    by (cases "u = 0 \<or> u = 1") (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   363
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   364
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   365
lemma convex_on_linorderI [intro?]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   366
  fixes A :: "('a::{linorder,real_vector}) set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   367
  assumes "\<And>t x y. t > 0 \<Longrightarrow> t < 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x < y \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   368
    f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   369
  shows "convex_on A f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   370
proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   371
  fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   372
  fix t :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   373
  assume A: "x \<in> A" "y \<in> A" "t > 0" "t < 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   374
  with assms [of t x y] assms [of "1 - t" y x]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   375
  show "f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   376
    by (cases x y rule: linorder_cases) (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   377
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   378
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   379
lemma convex_onD:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   380
  assumes "convex_on A f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   381
  shows "\<And>t x y. t \<ge> 0 \<Longrightarrow> t \<le> 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   382
    f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   383
  using assms by (auto simp: convex_on_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   384
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   385
lemma convex_onD_Icc:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   386
  assumes "convex_on {x..y} f" "x \<le> (y :: _ :: {real_vector,preorder})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   387
  shows "\<And>t. t \<ge> 0 \<Longrightarrow> t \<le> 1 \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   388
    f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   389
  using assms(2) by (intro convex_onD [OF assms(1)]) simp_all
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   390
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   391
lemma convex_on_subset: "convex_on t f \<Longrightarrow> s \<subseteq> t \<Longrightarrow> convex_on s f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   392
  unfolding convex_on_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   393
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   394
lemma convex_on_add [intro]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   395
  assumes "convex_on s f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   396
    and "convex_on s g"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   397
  shows "convex_on s (\<lambda>x. f x + g x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   398
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   399
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   400
    fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   401
    assume "x \<in> s" "y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   402
    moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   403
    fix u v :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   404
    assume "0 \<le> u" "0 \<le> v" "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   405
    ultimately
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   406
    have "f (u *\<^sub>R x + v *\<^sub>R y) + g (u *\<^sub>R x + v *\<^sub>R y) \<le> (u * f x + v * f y) + (u * g x + v * g y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   407
      using assms unfolding convex_on_def by (auto simp: add_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   408
    then have "f (u *\<^sub>R x + v *\<^sub>R y) + g (u *\<^sub>R x + v *\<^sub>R y) \<le> u * (f x + g x) + v * (f y + g y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   409
      by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   410
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   411
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   412
    unfolding convex_on_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   413
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   414
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   415
lemma convex_on_cmul [intro]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   416
  fixes c :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   417
  assumes "0 \<le> c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   418
    and "convex_on s f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   419
  shows "convex_on s (\<lambda>x. c * f x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   420
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   421
  have *: "u * (c * fx) + v * (c * fy) = c * (u * fx + v * fy)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   422
    for u c fx v fy :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   423
    by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   424
  show ?thesis using assms(2) and mult_left_mono [OF _ assms(1)]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   425
    unfolding convex_on_def and * by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   426
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   427
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   428
lemma convex_lower:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   429
  assumes "convex_on s f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   430
    and "x \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   431
    and "y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   432
    and "0 \<le> u"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   433
    and "0 \<le> v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   434
    and "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   435
  shows "f (u *\<^sub>R x + v *\<^sub>R y) \<le> max (f x) (f y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   436
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   437
  let ?m = "max (f x) (f y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   438
  have "u * f x + v * f y \<le> u * max (f x) (f y) + v * max (f x) (f y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   439
    using assms(4,5) by (auto simp: mult_left_mono add_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   440
  also have "\<dots> = max (f x) (f y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   441
    using assms(6) by (simp add: distrib_right [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   442
  finally show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   443
    using assms unfolding convex_on_def by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   444
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   445
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   446
lemma convex_on_dist [intro]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   447
  fixes s :: "'a::real_normed_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   448
  shows "convex_on s (\<lambda>x. dist a x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   449
proof (auto simp: convex_on_def dist_norm)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   450
  fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   451
  assume "x \<in> s" "y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   452
  fix u v :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   453
  assume "0 \<le> u"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   454
  assume "0 \<le> v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   455
  assume "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   456
  have "a = u *\<^sub>R a + v *\<^sub>R a"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   457
    unfolding scaleR_left_distrib[symmetric] and \<open>u + v = 1\<close> by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   458
  then have *: "a - (u *\<^sub>R x + v *\<^sub>R y) = (u *\<^sub>R (a - x)) + (v *\<^sub>R (a - y))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   459
    by (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   460
  show "norm (a - (u *\<^sub>R x + v *\<^sub>R y)) \<le> u * norm (a - x) + v * norm (a - y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   461
    unfolding * using norm_triangle_ineq[of "u *\<^sub>R (a - x)" "v *\<^sub>R (a - y)"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   462
    using \<open>0 \<le> u\<close> \<open>0 \<le> v\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   463
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   464
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   465
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
   466
subsection\<^marker>\<open>tag unimportant\<close> \<open>Arithmetic operations on sets preserve convexity\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   467
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   468
lemma convex_linear_image:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   469
  assumes "linear f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   470
    and "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   471
  shows "convex (f ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   472
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   473
  interpret f: linear f by fact
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   474
  from \<open>convex s\<close> show "convex (f ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   475
    by (simp add: convex_def f.scaleR [symmetric] f.add [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   476
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   477
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   478
lemma convex_linear_vimage:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   479
  assumes "linear f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   480
    and "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   481
  shows "convex (f -` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   482
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   483
  interpret f: linear f by fact
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   484
  from \<open>convex s\<close> show "convex (f -` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   485
    by (simp add: convex_def f.add f.scaleR)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   486
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   487
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   488
lemma convex_scaling:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   489
  assumes "convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   490
  shows "convex ((\<lambda>x. c *\<^sub>R x) ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   491
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   492
  have "linear (\<lambda>x. c *\<^sub>R x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   493
    by (simp add: linearI scaleR_add_right)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   494
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   495
    using \<open>convex s\<close> by (rule convex_linear_image)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   496
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   497
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   498
lemma convex_scaled:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   499
  assumes "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   500
  shows "convex ((\<lambda>x. x *\<^sub>R c) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   501
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   502
  have "linear (\<lambda>x. x *\<^sub>R c)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   503
    by (simp add: linearI scaleR_add_left)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   504
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   505
    using \<open>convex S\<close> by (rule convex_linear_image)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   506
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   507
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   508
lemma convex_negations:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   509
  assumes "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   510
  shows "convex ((\<lambda>x. - x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   511
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   512
  have "linear (\<lambda>x. - x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   513
    by (simp add: linearI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   514
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   515
    using \<open>convex S\<close> by (rule convex_linear_image)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   516
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   517
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   518
lemma convex_sums:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   519
  assumes "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   520
    and "convex T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   521
  shows "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   522
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   523
  have "linear (\<lambda>(x, y). x + y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   524
    by (auto intro: linearI simp: scaleR_add_right)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   525
  with assms have "convex ((\<lambda>(x, y). x + y) ` (S \<times> T))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   526
    by (intro convex_linear_image convex_Times)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   527
  also have "((\<lambda>(x, y). x + y) ` (S \<times> T)) = (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   528
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   529
  finally show ?thesis .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   530
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   531
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   532
lemma convex_differences:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   533
  assumes "convex S" "convex T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   534
  shows "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   535
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   536
  have "{x - y| x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   537
    by (auto simp: diff_conv_add_uminus simp del: add_uminus_conv_diff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   538
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   539
    using convex_sums[OF assms(1) convex_negations[OF assms(2)]] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   540
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   541
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   542
lemma convex_translation:
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
   543
  "convex ((+) a ` S)" if "convex S"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   544
proof -
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
   545
  have "(\<Union> x\<in> {a}. \<Union>y \<in> S. {x + y}) = (+) a ` S"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   546
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   547
  then show ?thesis
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
   548
    using convex_sums [OF convex_singleton [of a] that] by auto
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   549
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   550
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
   551
lemma convex_translation_subtract:
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
   552
  "convex ((\<lambda>b. b - a) ` S)" if "convex S"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
   553
  using convex_translation [of S "- a"] that by (simp cong: image_cong_simp)
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
   554
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   555
lemma convex_affinity:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   556
  assumes "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   557
  shows "convex ((\<lambda>x. a + c *\<^sub>R x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   558
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   559
  have "(\<lambda>x. a + c *\<^sub>R x) ` S = (+) a ` (*\<^sub>R) c ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   560
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   561
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   562
    using convex_translation[OF convex_scaling[OF assms], of a c] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   563
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   564
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   565
lemma pos_is_convex: "convex {0 :: real <..}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   566
  unfolding convex_alt
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   567
proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   568
  fix y x \<mu> :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   569
  assume *: "y > 0" "x > 0" "\<mu> \<ge> 0" "\<mu> \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   570
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   571
    assume "\<mu> = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   572
    then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   573
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   574
    then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   575
      using * by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   576
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   577
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   578
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   579
    assume "\<mu> = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   580
    then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   581
      using * by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   582
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   583
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   584
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   585
    assume "\<mu> \<noteq> 1" "\<mu> \<noteq> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   586
    then have "\<mu> > 0" "(1 - \<mu>) > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   587
      using * by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   588
    then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   589
      using * by (auto simp: add_pos_pos)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   590
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   591
  ultimately show "(1 - \<mu>) *\<^sub>R y + \<mu> *\<^sub>R x > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   592
    by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   593
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   594
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   595
lemma convex_on_sum:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   596
  fixes a :: "'a \<Rightarrow> real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   597
    and y :: "'a \<Rightarrow> 'b::real_vector"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   598
    and f :: "'b \<Rightarrow> real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   599
  assumes "finite s" "s \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   600
    and "convex_on C f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   601
    and "convex C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   602
    and "(\<Sum> i \<in> s. a i) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   603
    and "\<And>i. i \<in> s \<Longrightarrow> a i \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   604
    and "\<And>i. i \<in> s \<Longrightarrow> y i \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   605
  shows "f (\<Sum> i \<in> s. a i *\<^sub>R y i) \<le> (\<Sum> i \<in> s. a i * f (y i))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   606
  using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   607
proof (induct s arbitrary: a rule: finite_ne_induct)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   608
  case (singleton i)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   609
  then have ai: "a i = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   610
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   611
  then show ?case
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   612
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   613
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   614
  case (insert i s)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   615
  then have "convex_on C f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   616
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   617
  from this[unfolded convex_on_def, rule_format]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   618
  have conv: "\<And>x y \<mu>. x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> 0 \<le> \<mu> \<Longrightarrow> \<mu> \<le> 1 \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   619
      f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   620
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   621
  show ?case
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   622
  proof (cases "a i = 1")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   623
    case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   624
    then have "(\<Sum> j \<in> s. a j) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   625
      using insert by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   626
    then have "\<And>j. j \<in> s \<Longrightarrow> a j = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   627
      using insert by (fastforce simp: sum_nonneg_eq_0_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   628
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   629
      using insert by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   630
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   631
    case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   632
    from insert have yai: "y i \<in> C" "a i \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   633
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   634
    have fis: "finite (insert i s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   635
      using insert by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   636
    then have ai1: "a i \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   637
      using sum_nonneg_leq_bound[of "insert i s" a] insert by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   638
    then have "a i < 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   639
      using False by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   640
    then have i0: "1 - a i > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   641
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   642
    let ?a = "\<lambda>j. a j / (1 - a i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   643
    have a_nonneg: "?a j \<ge> 0" if "j \<in> s" for j
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   644
      using i0 insert that by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   645
    have "(\<Sum> j \<in> insert i s. a j) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   646
      using insert by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   647
    then have "(\<Sum> j \<in> s. a j) = 1 - a i"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   648
      using sum.insert insert by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   649
    then have "(\<Sum> j \<in> s. a j) / (1 - a i) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   650
      using i0 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   651
    then have a1: "(\<Sum> j \<in> s. ?a j) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   652
      unfolding sum_divide_distrib by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   653
    have "convex C" using insert by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   654
    then have asum: "(\<Sum> j \<in> s. ?a j *\<^sub>R y j) \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   655
      using insert convex_sum [OF \<open>finite s\<close> \<open>convex C\<close> a1 a_nonneg] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   656
    have asum_le: "f (\<Sum> j \<in> s. ?a j *\<^sub>R y j) \<le> (\<Sum> j \<in> s. ?a j * f (y j))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   657
      using a_nonneg a1 insert by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   658
    have "f (\<Sum> j \<in> insert i s. a j *\<^sub>R y j) = f ((\<Sum> j \<in> s. a j *\<^sub>R y j) + a i *\<^sub>R y i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   659
      using sum.insert[of s i "\<lambda> j. a j *\<^sub>R y j", OF \<open>finite s\<close> \<open>i \<notin> s\<close>] insert
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   660
      by (auto simp only: add.commute)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   661
    also have "\<dots> = f (((1 - a i) * inverse (1 - a i)) *\<^sub>R (\<Sum> j \<in> s. a j *\<^sub>R y j) + a i *\<^sub>R y i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   662
      using i0 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   663
    also have "\<dots> = f ((1 - a i) *\<^sub>R (\<Sum> j \<in> s. (a j * inverse (1 - a i)) *\<^sub>R y j) + a i *\<^sub>R y i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   664
      using scaleR_right.sum[of "inverse (1 - a i)" "\<lambda> j. a j *\<^sub>R y j" s, symmetric]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   665
      by (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   666
    also have "\<dots> = f ((1 - a i) *\<^sub>R (\<Sum> j \<in> s. ?a j *\<^sub>R y j) + a i *\<^sub>R y i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   667
      by (auto simp: divide_inverse)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   668
    also have "\<dots> \<le> (1 - a i) *\<^sub>R f ((\<Sum> j \<in> s. ?a j *\<^sub>R y j)) + a i * f (y i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   669
      using conv[of "y i" "(\<Sum> j \<in> s. ?a j *\<^sub>R y j)" "a i", OF yai(1) asum yai(2) ai1]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   670
      by (auto simp: add.commute)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   671
    also have "\<dots> \<le> (1 - a i) * (\<Sum> j \<in> s. ?a j * f (y j)) + a i * f (y i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   672
      using add_right_mono [OF mult_left_mono [of _ _ "1 - a i",
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   673
            OF asum_le less_imp_le[OF i0]], of "a i * f (y i)"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   674
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   675
    also have "\<dots> = (\<Sum> j \<in> s. (1 - a i) * ?a j * f (y j)) + a i * f (y i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   676
      unfolding sum_distrib_left[of "1 - a i" "\<lambda> j. ?a j * f (y j)"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   677
      using i0 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   678
    also have "\<dots> = (\<Sum> j \<in> s. a j * f (y j)) + a i * f (y i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   679
      using i0 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   680
    also have "\<dots> = (\<Sum> j \<in> insert i s. a j * f (y j))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   681
      using insert by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   682
    finally show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   683
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   684
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   685
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   686
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   687
lemma convex_on_alt:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   688
  fixes C :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   689
  assumes "convex C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   690
  shows "convex_on C f \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   691
    (\<forall>x \<in> C. \<forall> y \<in> C. \<forall> \<mu> :: real. \<mu> \<ge> 0 \<and> \<mu> \<le> 1 \<longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   692
      f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   693
proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   694
  fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   695
  fix \<mu> :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   696
  assume *: "convex_on C f" "x \<in> C" "y \<in> C" "0 \<le> \<mu>" "\<mu> \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   697
  from this[unfolded convex_on_def, rule_format]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   698
  have "0 \<le> u \<Longrightarrow> 0 \<le> v \<Longrightarrow> u + v = 1 \<Longrightarrow> f (u *\<^sub>R x + v *\<^sub>R y) \<le> u * f x + v * f y" for u v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   699
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   700
  from this [of "\<mu>" "1 - \<mu>", simplified] *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   701
  show "f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   702
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   703
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   704
  assume *: "\<forall>x\<in>C. \<forall>y\<in>C. \<forall>\<mu>. 0 \<le> \<mu> \<and> \<mu> \<le> 1 \<longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   705
    f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   706
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   707
    fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   708
    fix u v :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   709
    assume **: "x \<in> C" "y \<in> C" "u \<ge> 0" "v \<ge> 0" "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   710
    then have[simp]: "1 - u = v" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   711
    from *[rule_format, of x y u]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   712
    have "f (u *\<^sub>R x + v *\<^sub>R y) \<le> u * f x + v * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   713
      using ** by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   714
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   715
  then show "convex_on C f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   716
    unfolding convex_on_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   717
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   718
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   719
lemma convex_on_diff:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   720
  fixes f :: "real \<Rightarrow> real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   721
  assumes f: "convex_on I f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   722
    and I: "x \<in> I" "y \<in> I"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   723
    and t: "x < t" "t < y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   724
  shows "(f x - f t) / (x - t) \<le> (f x - f y) / (x - y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   725
    and "(f x - f y) / (x - y) \<le> (f t - f y) / (t - y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   726
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   727
  define a where "a \<equiv> (t - y) / (x - y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   728
  with t have "0 \<le> a" "0 \<le> 1 - a"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   729
    by (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   730
  with f \<open>x \<in> I\<close> \<open>y \<in> I\<close> have cvx: "f (a * x + (1 - a) * y) \<le> a * f x + (1 - a) * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   731
    by (auto simp: convex_on_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   732
  have "a * x + (1 - a) * y = a * (x - y) + y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   733
    by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   734
  also have "\<dots> = t"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   735
    unfolding a_def using \<open>x < t\<close> \<open>t < y\<close> by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   736
  finally have "f t \<le> a * f x + (1 - a) * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   737
    using cvx by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   738
  also have "\<dots> = a * (f x - f y) + f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   739
    by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   740
  finally have "f t - f y \<le> a * (f x - f y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   741
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   742
  with t show "(f x - f t) / (x - t) \<le> (f x - f y) / (x - y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   743
    by (simp add: le_divide_eq divide_le_eq field_simps a_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   744
  with t show "(f x - f y) / (x - y) \<le> (f t - f y) / (t - y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   745
    by (simp add: le_divide_eq divide_le_eq field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   746
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   747
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   748
lemma pos_convex_function:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   749
  fixes f :: "real \<Rightarrow> real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   750
  assumes "convex C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   751
    and leq: "\<And>x y. x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> f' x * (y - x) \<le> f y - f x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   752
  shows "convex_on C f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   753
  unfolding convex_on_alt[OF assms(1)]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   754
  using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   755
proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   756
  fix x y \<mu> :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   757
  let ?x = "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   758
  assume *: "convex C" "x \<in> C" "y \<in> C" "\<mu> \<ge> 0" "\<mu> \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   759
  then have "1 - \<mu> \<ge> 0" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   760
  then have xpos: "?x \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   761
    using * unfolding convex_alt by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   762
  have geq: "\<mu> * (f x - f ?x) + (1 - \<mu>) * (f y - f ?x) \<ge>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   763
      \<mu> * f' ?x * (x - ?x) + (1 - \<mu>) * f' ?x * (y - ?x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   764
    using add_mono [OF mult_left_mono [OF leq [OF xpos *(2)] \<open>\<mu> \<ge> 0\<close>]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   765
        mult_left_mono [OF leq [OF xpos *(3)] \<open>1 - \<mu> \<ge> 0\<close>]]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   766
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   767
  then have "\<mu> * f x + (1 - \<mu>) * f y - f ?x \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   768
    by (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   769
  then show "f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   770
    using convex_on_alt by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   771
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   772
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   773
lemma atMostAtLeast_subset_convex:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   774
  fixes C :: "real set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   775
  assumes "convex C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   776
    and "x \<in> C" "y \<in> C" "x < y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   777
  shows "{x .. y} \<subseteq> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   778
proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   779
  fix z assume z: "z \<in> {x .. y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   780
  have less: "z \<in> C" if *: "x < z" "z < y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   781
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   782
    let ?\<mu> = "(y - z) / (y - x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   783
    have "0 \<le> ?\<mu>" "?\<mu> \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   784
      using assms * by (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   785
    then have comb: "?\<mu> * x + (1 - ?\<mu>) * y \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   786
      using assms iffD1[OF convex_alt, rule_format, of C y x ?\<mu>]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   787
      by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   788
    have "?\<mu> * x + (1 - ?\<mu>) * y = (y - z) * x / (y - x) + (1 - (y - z) / (y - x)) * y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   789
      by (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   790
    also have "\<dots> = ((y - z) * x + (y - x - (y - z)) * y) / (y - x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   791
      using assms by (simp only: add_divide_distrib) (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   792
    also have "\<dots> = z"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   793
      using assms by (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   794
    finally show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   795
      using comb by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   796
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   797
  show "z \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   798
    using z less assms by (auto simp: le_less)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   799
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   800
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   801
lemma f''_imp_f':
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   802
  fixes f :: "real \<Rightarrow> real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   803
  assumes "convex C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   804
    and f': "\<And>x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   805
    and f'': "\<And>x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   806
    and pos: "\<And>x. x \<in> C \<Longrightarrow> f'' x \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   807
    and x: "x \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   808
    and y: "y \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   809
  shows "f' x * (y - x) \<le> f y - f x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   810
  using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   811
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   812
  have less_imp: "f y - f x \<ge> f' x * (y - x)" "f' y * (x - y) \<le> f x - f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   813
    if *: "x \<in> C" "y \<in> C" "y > x" for x y :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   814
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   815
    from * have ge: "y - x > 0" "y - x \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   816
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   817
    from * have le: "x - y < 0" "x - y \<le> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   818
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   819
    then obtain z1 where z1: "z1 > x" "z1 < y" "f y - f x = (y - x) * f' z1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   820
      using subsetD[OF atMostAtLeast_subset_convex[OF \<open>convex C\<close> \<open>x \<in> C\<close> \<open>y \<in> C\<close> \<open>x < y\<close>],
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   821
          THEN f', THEN MVT2[OF \<open>x < y\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   822
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   823
    then have "z1 \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   824
      using atMostAtLeast_subset_convex \<open>convex C\<close> \<open>x \<in> C\<close> \<open>y \<in> C\<close> \<open>x < y\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   825
      by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   826
    from z1 have z1': "f x - f y = (x - y) * f' z1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   827
      by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   828
    obtain z2 where z2: "z2 > x" "z2 < z1" "f' z1 - f' x = (z1 - x) * f'' z2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   829
      using subsetD[OF atMostAtLeast_subset_convex[OF \<open>convex C\<close> \<open>x \<in> C\<close> \<open>z1 \<in> C\<close> \<open>x < z1\<close>],
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   830
          THEN f'', THEN MVT2[OF \<open>x < z1\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]] z1
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   831
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   832
    obtain z3 where z3: "z3 > z1" "z3 < y" "f' y - f' z1 = (y - z1) * f'' z3"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   833
      using subsetD[OF atMostAtLeast_subset_convex[OF \<open>convex C\<close> \<open>z1 \<in> C\<close> \<open>y \<in> C\<close> \<open>z1 < y\<close>],
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   834
          THEN f'', THEN MVT2[OF \<open>z1 < y\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]] z1
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   835
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   836
    have "f' y - (f x - f y) / (x - y) = f' y - f' z1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   837
      using * z1' by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   838
    also have "\<dots> = (y - z1) * f'' z3"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   839
      using z3 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   840
    finally have cool': "f' y - (f x - f y) / (x - y) = (y - z1) * f'' z3"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   841
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   842
    have A': "y - z1 \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   843
      using z1 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   844
    have "z3 \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   845
      using z3 * atMostAtLeast_subset_convex \<open>convex C\<close> \<open>x \<in> C\<close> \<open>z1 \<in> C\<close> \<open>x < z1\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   846
      by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   847
    then have B': "f'' z3 \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   848
      using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   849
    from A' B' have "(y - z1) * f'' z3 \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   850
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   851
    from cool' this have "f' y - (f x - f y) / (x - y) \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   852
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   853
    from mult_right_mono_neg[OF this le(2)]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   854
    have "f' y * (x - y) - (f x - f y) / (x - y) * (x - y) \<le> 0 * (x - y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   855
      by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   856
    then have "f' y * (x - y) - (f x - f y) \<le> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   857
      using le by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   858
    then have res: "f' y * (x - y) \<le> f x - f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   859
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   860
    have "(f y - f x) / (y - x) - f' x = f' z1 - f' x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   861
      using * z1 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   862
    also have "\<dots> = (z1 - x) * f'' z2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   863
      using z2 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   864
    finally have cool: "(f y - f x) / (y - x) - f' x = (z1 - x) * f'' z2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   865
      by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   866
    have A: "z1 - x \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   867
      using z1 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   868
    have "z2 \<in> C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   869
      using z2 z1 * atMostAtLeast_subset_convex \<open>convex C\<close> \<open>z1 \<in> C\<close> \<open>y \<in> C\<close> \<open>z1 < y\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   870
      by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   871
    then have B: "f'' z2 \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   872
      using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   873
    from A B have "(z1 - x) * f'' z2 \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   874
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   875
    with cool have "(f y - f x) / (y - x) - f' x \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   876
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   877
    from mult_right_mono[OF this ge(2)]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   878
    have "(f y - f x) / (y - x) * (y - x) - f' x * (y - x) \<ge> 0 * (y - x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   879
      by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   880
    then have "f y - f x - f' x * (y - x) \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   881
      using ge by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   882
    then show "f y - f x \<ge> f' x * (y - x)" "f' y * (x - y) \<le> f x - f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   883
      using res by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   884
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   885
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   886
  proof (cases "x = y")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   887
    case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   888
    with x y show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   889
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   890
    case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   891
    with less_imp x y show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   892
      by (auto simp: neq_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   893
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   894
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   895
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   896
lemma f''_ge0_imp_convex:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   897
  fixes f :: "real \<Rightarrow> real"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   898
  assumes conv: "convex C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   899
    and f': "\<And>x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   900
    and f'': "\<And>x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   901
    and pos: "\<And>x. x \<in> C \<Longrightarrow> f'' x \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   902
  shows "convex_on C f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   903
  using f''_imp_f'[OF conv f' f'' pos] assms pos_convex_function
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   904
  by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   905
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   906
lemma minus_log_convex:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   907
  fixes b :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   908
  assumes "b > 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   909
  shows "convex_on {0 <..} (\<lambda> x. - log b x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   910
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   911
  have "\<And>z. z > 0 \<Longrightarrow> DERIV (log b) z :> 1 / (ln b * z)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   912
    using DERIV_log by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   913
  then have f': "\<And>z. z > 0 \<Longrightarrow> DERIV (\<lambda> z. - log b z) z :> - 1 / (ln b * z)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   914
    by (auto simp: DERIV_minus)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   915
  have "\<And>z::real. z > 0 \<Longrightarrow> DERIV inverse z :> - (inverse z ^ Suc (Suc 0))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   916
    using less_imp_neq[THEN not_sym, THEN DERIV_inverse] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   917
  from this[THEN DERIV_cmult, of _ "- 1 / ln b"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   918
  have "\<And>z::real. z > 0 \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   919
    DERIV (\<lambda> z. (- 1 / ln b) * inverse z) z :> (- 1 / ln b) * (- (inverse z ^ Suc (Suc 0)))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   920
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   921
  then have f''0: "\<And>z::real. z > 0 \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   922
    DERIV (\<lambda> z. - 1 / (ln b * z)) z :> 1 / (ln b * z * z)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   923
    unfolding inverse_eq_divide by (auto simp: mult.assoc)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   924
  have f''_ge0: "\<And>z::real. z > 0 \<Longrightarrow> 1 / (ln b * z * z) \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   925
    using \<open>b > 1\<close> by (auto intro!: less_imp_le)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   926
  from f''_ge0_imp_convex[OF pos_is_convex, unfolded greaterThan_iff, OF f' f''0 f''_ge0]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   927
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   928
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   929
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   930
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   931
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
   932
subsection\<^marker>\<open>tag unimportant\<close> \<open>Convexity of real functions\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   933
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   934
lemma convex_on_realI:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   935
  assumes "connected A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   936
    and "\<And>x. x \<in> A \<Longrightarrow> (f has_real_derivative f' x) (at x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   937
    and "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x \<le> y \<Longrightarrow> f' x \<le> f' y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   938
  shows "convex_on A f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   939
proof (rule convex_on_linorderI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   940
  fix t x y :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   941
  assume t: "t > 0" "t < 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   942
  assume xy: "x \<in> A" "y \<in> A" "x < y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   943
  define z where "z = (1 - t) * x + t * y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   944
  with \<open>connected A\<close> and xy have ivl: "{x..y} \<subseteq> A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   945
    using connected_contains_Icc by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   946
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   947
  from xy t have xz: "z > x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   948
    by (simp add: z_def algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   949
  have "y - z = (1 - t) * (y - x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   950
    by (simp add: z_def algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   951
  also from xy t have "\<dots> > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   952
    by (intro mult_pos_pos) simp_all
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   953
  finally have yz: "z < y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   954
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   955
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   956
  from assms xz yz ivl t have "\<exists>\<xi>. \<xi> > x \<and> \<xi> < z \<and> f z - f x = (z - x) * f' \<xi>"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   957
    by (intro MVT2) (auto intro!: assms(2))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   958
  then obtain \<xi> where \<xi>: "\<xi> > x" "\<xi> < z" "f' \<xi> = (f z - f x) / (z - x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   959
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   960
  from assms xz yz ivl t have "\<exists>\<eta>. \<eta> > z \<and> \<eta> < y \<and> f y - f z = (y - z) * f' \<eta>"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   961
    by (intro MVT2) (auto intro!: assms(2))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   962
  then obtain \<eta> where \<eta>: "\<eta> > z" "\<eta> < y" "f' \<eta> = (f y - f z) / (y - z)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   963
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   964
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   965
  from \<eta>(3) have "(f y - f z) / (y - z) = f' \<eta>" ..
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   966
  also from \<xi> \<eta> ivl have "\<xi> \<in> A" "\<eta> \<in> A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   967
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   968
  with \<xi> \<eta> have "f' \<eta> \<ge> f' \<xi>"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   969
    by (intro assms(3)) auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   970
  also from \<xi>(3) have "f' \<xi> = (f z - f x) / (z - x)" .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   971
  finally have "(f y - f z) * (z - x) \<ge> (f z - f x) * (y - z)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   972
    using xz yz by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   973
  also have "z - x = t * (y - x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   974
    by (simp add: z_def algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   975
  also have "y - z = (1 - t) * (y - x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   976
    by (simp add: z_def algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   977
  finally have "(f y - f z) * t \<ge> (f z - f x) * (1 - t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   978
    using xy by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   979
  then show "(1 - t) * f x + t * f y \<ge> f ((1 - t) *\<^sub>R x + t *\<^sub>R y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   980
    by (simp add: z_def algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   981
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   982
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   983
lemma convex_on_inverse:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   984
  assumes "A \<subseteq> {0<..}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   985
  shows "convex_on A (inverse :: real \<Rightarrow> real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   986
proof (rule convex_on_subset[OF _ assms], intro convex_on_realI[of _ _ "\<lambda>x. -inverse (x^2)"])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   987
  fix u v :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   988
  assume "u \<in> {0<..}" "v \<in> {0<..}" "u \<le> v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   989
  with assms show "-inverse (u^2) \<le> -inverse (v^2)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   990
    by (intro le_imp_neg_le le_imp_inverse_le power_mono) (simp_all)
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70136
diff changeset
   991
qed (insert assms, auto intro!: derivative_eq_intros simp: field_split_simps power2_eq_square)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   992
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   993
lemma convex_onD_Icc':
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   994
  assumes "convex_on {x..y} f" "c \<in> {x..y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   995
  defines "d \<equiv> y - x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   996
  shows "f c \<le> (f y - f x) / d * (c - x) + f x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   997
proof (cases x y rule: linorder_cases)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   998
  case less
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
   999
  then have d: "d > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1000
    by (simp add: d_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1001
  from assms(2) less have A: "0 \<le> (c - x) / d" "(c - x) / d \<le> 1"
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70136
diff changeset
  1002
    by (simp_all add: d_def field_split_simps)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1003
  have "f c = f (x + (c - x) * 1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1004
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1005
  also from less have "1 = ((y - x) / d)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1006
    by (simp add: d_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1007
  also from d have "x + (c - x) * \<dots> = (1 - (c - x) / d) *\<^sub>R x + ((c - x) / d) *\<^sub>R y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1008
    by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1009
  also have "f \<dots> \<le> (1 - (c - x) / d) * f x + (c - x) / d * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1010
    using assms less by (intro convex_onD_Icc) simp_all
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1011
  also from d have "\<dots> = (f y - f x) / d * (c - x) + f x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1012
    by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1013
  finally show ?thesis .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1014
qed (insert assms(2), simp_all)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1015
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1016
lemma convex_onD_Icc'':
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1017
  assumes "convex_on {x..y} f" "c \<in> {x..y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1018
  defines "d \<equiv> y - x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1019
  shows "f c \<le> (f x - f y) / d * (y - c) + f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1020
proof (cases x y rule: linorder_cases)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1021
  case less
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1022
  then have d: "d > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1023
    by (simp add: d_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1024
  from assms(2) less have A: "0 \<le> (y - c) / d" "(y - c) / d \<le> 1"
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70136
diff changeset
  1025
    by (simp_all add: d_def field_split_simps)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1026
  have "f c = f (y - (y - c) * 1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1027
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1028
  also from less have "1 = ((y - x) / d)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1029
    by (simp add: d_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1030
  also from d have "y - (y - c) * \<dots> = (1 - (1 - (y - c) / d)) *\<^sub>R x + (1 - (y - c) / d) *\<^sub>R y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1031
    by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1032
  also have "f \<dots> \<le> (1 - (1 - (y - c) / d)) * f x + (1 - (y - c) / d) * f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1033
    using assms less by (intro convex_onD_Icc) (simp_all add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1034
  also from d have "\<dots> = (f x - f y) / d * (y - c) + f y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1035
    by (simp add: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1036
  finally show ?thesis .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1037
qed (insert assms(2), simp_all)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1038
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1039
lemma convex_translation_eq [simp]:
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1040
  "convex ((+) a ` s) \<longleftrightarrow> convex s"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1041
  by (metis convex_translation translation_galois)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1042
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1043
lemma convex_translation_subtract_eq [simp]:
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1044
  "convex ((\<lambda>b. b - a) ` s) \<longleftrightarrow> convex s"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1045
  using convex_translation_eq [of "- a"] by (simp cong: image_cong_simp)
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1046
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1047
lemma convex_linear_image_eq [simp]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1048
    fixes f :: "'a::real_vector \<Rightarrow> 'b::real_vector"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1049
    shows "\<lbrakk>linear f; inj f\<rbrakk> \<Longrightarrow> convex (f ` s) \<longleftrightarrow> convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1050
    by (metis (no_types) convex_linear_image convex_linear_vimage inj_vimage_image_eq)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1051
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1052
lemma fst_linear: "linear fst"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1053
  unfolding linear_iff by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1054
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1055
lemma snd_linear: "linear snd"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1056
  unfolding linear_iff by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1057
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1058
lemma fst_snd_linear: "linear (\<lambda>(x,y). x + y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1059
  unfolding linear_iff by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1060
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1061
lemma vector_choose_size:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1062
  assumes "0 \<le> c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1063
  obtains x :: "'a::{real_normed_vector, perfect_space}" where "norm x = c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1064
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1065
  obtain a::'a where "a \<noteq> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1066
    using UNIV_not_singleton UNIV_eq_I set_zero singletonI by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1067
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1068
    by (rule_tac x="scaleR (c / norm a) a" in that) (simp add: assms)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1069
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1070
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1071
lemma vector_choose_dist:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1072
  assumes "0 \<le> c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1073
  obtains y :: "'a::{real_normed_vector, perfect_space}" where "dist x y = c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1074
by (metis add_diff_cancel_left' assms dist_commute dist_norm vector_choose_size)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1075
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1076
lemma sum_delta_notmem:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1077
  assumes "x \<notin> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1078
  shows "sum (\<lambda>y. if (y = x) then P x else Q y) s = sum Q s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1079
    and "sum (\<lambda>y. if (x = y) then P x else Q y) s = sum Q s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1080
    and "sum (\<lambda>y. if (y = x) then P y else Q y) s = sum Q s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1081
    and "sum (\<lambda>y. if (x = y) then P y else Q y) s = sum Q s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1082
  apply (rule_tac [!] sum.cong)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1083
  using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1084
  apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1085
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1086
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1087
lemma sum_delta'':
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1088
  fixes s::"'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1089
  assumes "finite s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1090
  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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1091
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1092
  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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1093
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1094
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1095
    unfolding * using sum.delta[OF assms, of y "\<lambda>x. f x *\<^sub>R x"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1096
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1097
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1098
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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1099
  by (fact if_distrib)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1100
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1101
lemma dist_triangle_eq:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1102
  fixes x y z :: "'a::real_inner"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1103
  shows "dist x z = dist x y + dist y z \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1104
    norm (x - y) *\<^sub>R (y - z) = norm (y - z) *\<^sub>R (x - y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1105
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1106
  have *: "x - y + (y - z) = x - z" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1107
  show ?thesis unfolding dist_norm norm_triangle_eq[of "x - y" "y - z", unfolded *]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1108
    by (auto simp:norm_minus_commute)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1109
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1110
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1111
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1112
subsection \<open>Affine set and affine hull\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1113
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1114
definition\<^marker>\<open>tag important\<close> affine :: "'a::real_vector set \<Rightarrow> bool"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1115
  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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1116
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1117
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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1118
  unfolding affine_def by (metis eq_diff_eq')
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1119
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1120
lemma affine_empty [iff]: "affine {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1121
  unfolding affine_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1122
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1123
lemma affine_sing [iff]: "affine {x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1124
  unfolding affine_alt by (auto simp: scaleR_left_distrib [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1125
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1126
lemma affine_UNIV [iff]: "affine UNIV"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1127
  unfolding affine_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1128
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1129
lemma affine_Inter [intro]: "(\<And>s. s\<in>f \<Longrightarrow> affine s) \<Longrightarrow> affine (\<Inter>f)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1130
  unfolding affine_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1131
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1132
lemma affine_Int[intro]: "affine s \<Longrightarrow> affine t \<Longrightarrow> affine (s \<inter> t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1133
  unfolding affine_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1134
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1135
lemma affine_scaling: "affine s \<Longrightarrow> affine (image (\<lambda>x. c *\<^sub>R x) s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1136
  apply (clarsimp simp add: affine_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1137
  apply (rule_tac x="u *\<^sub>R x + v *\<^sub>R y" in image_eqI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1138
  apply (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1139
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1140
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1141
lemma affine_affine_hull [simp]: "affine(affine hull s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1142
  unfolding hull_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1143
  using affine_Inter[of "{t. affine t \<and> s \<subseteq> t}"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1144
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1145
lemma affine_hull_eq[simp]: "(affine hull s = s) \<longleftrightarrow> affine s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1146
  by (metis affine_affine_hull hull_same)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1147
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1148
lemma affine_hyperplane: "affine {x. a \<bullet> x = b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1149
  by (simp add: affine_def algebra_simps) (metis distrib_right mult.left_neutral)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1150
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1151
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1152
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Some explicit formulations\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1153
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1154
text "Formalized by Lars Schewe."
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1155
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1156
lemma affine:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1157
  fixes V::"'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1158
  shows "affine V \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1159
         (\<forall>S u. finite S \<and> S \<noteq> {} \<and> S \<subseteq> V \<and> sum u S = 1 \<longrightarrow> (\<Sum>x\<in>S. u x *\<^sub>R x) \<in> V)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1160
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1161
  have "u *\<^sub>R x + v *\<^sub>R y \<in> V" if "x \<in> V" "y \<in> V" "u + v = (1::real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1162
    and *: "\<And>S u. \<lbrakk>finite S; S \<noteq> {}; S \<subseteq> V; sum u S = 1\<rbrakk> \<Longrightarrow> (\<Sum>x\<in>S. u x *\<^sub>R x) \<in> V" for x y u v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1163
  proof (cases "x = y")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1164
    case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1165
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1166
      using that by (metis scaleR_add_left scaleR_one)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1167
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1168
    case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1169
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1170
      using that *[of "{x,y}" "\<lambda>w. if w = x then u else v"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1171
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1172
  moreover have "(\<Sum>x\<in>S. u x *\<^sub>R x) \<in> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1173
                if *: "\<And>x y u v. \<lbrakk>x\<in>V; y\<in>V; u + v = 1\<rbrakk> \<Longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1174
                  and "finite S" "S \<noteq> {}" "S \<subseteq> V" "sum u S = 1" for S u
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1175
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1176
    define n where "n = card S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1177
    consider "card S = 0" | "card S = 1" | "card S = 2" | "card S > 2" by linarith
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1178
    then show "(\<Sum>x\<in>S. u x *\<^sub>R x) \<in> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1179
    proof cases
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1180
      assume "card S = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1181
      then obtain a where "S={a}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1182
        by (auto simp: card_Suc_eq)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1183
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1184
        using that by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1185
    next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1186
      assume "card S = 2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1187
      then obtain a b where "S = {a, b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1188
        by (metis Suc_1 card_1_singletonE card_Suc_eq)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1189
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1190
        using *[of a b] that
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1191
        by (auto simp: sum_clauses(2))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1192
    next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1193
      assume "card S > 2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1194
      then show ?thesis using that n_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1195
      proof (induct n arbitrary: u S)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1196
        case 0
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1197
        then show ?case by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1198
      next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1199
        case (Suc n u S)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1200
        have "sum u S = card S" if "\<not> (\<exists>x\<in>S. u x \<noteq> 1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1201
          using that unfolding card_eq_sum by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1202
        with Suc.prems obtain x where "x \<in> S" and x: "u x \<noteq> 1" by force
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1203
        have c: "card (S - {x}) = card S - 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1204
          by (simp add: Suc.prems(3) \<open>x \<in> S\<close>)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1205
        have "sum u (S - {x}) = 1 - u x"
69802
6ec272e153f0 removed subsumed lemma
nipkow
parents: 69768
diff changeset
  1206
          by (simp add: Suc.prems sum_diff1 \<open>x \<in> S\<close>)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1207
        with x have eq1: "inverse (1 - u x) * sum u (S - {x}) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1208
          by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1209
        have inV: "(\<Sum>y\<in>S - {x}. (inverse (1 - u x) * u y) *\<^sub>R y) \<in> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1210
        proof (cases "card (S - {x}) > 2")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1211
          case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1212
          then have S: "S - {x} \<noteq> {}" "card (S - {x}) = n"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1213
            using Suc.prems c by force+
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1214
          show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1215
          proof (rule Suc.hyps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1216
            show "(\<Sum>a\<in>S - {x}. inverse (1 - u x) * u a) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1217
              by (auto simp: eq1 sum_distrib_left[symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1218
          qed (use S Suc.prems True in auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1219
        next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1220
          case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1221
          then have "card (S - {x}) = Suc (Suc 0)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1222
            using Suc.prems c by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1223
          then obtain a b where ab: "(S - {x}) = {a, b}" "a\<noteq>b"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1224
            unfolding card_Suc_eq by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1225
          then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1226
            using eq1 \<open>S \<subseteq> V\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1227
            by (auto simp: sum_distrib_left distrib_left intro!: Suc.prems(2)[of a b])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1228
        qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1229
        have "u x + (1 - u x) = 1 \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1230
          u x *\<^sub>R x + (1 - u x) *\<^sub>R ((\<Sum>y\<in>S - {x}. u y *\<^sub>R y) /\<^sub>R (1 - u x)) \<in> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1231
          by (rule Suc.prems) (use \<open>x \<in> S\<close> Suc.prems inV in \<open>auto simp: scaleR_right.sum\<close>)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1232
        moreover have "(\<Sum>a\<in>S. u a *\<^sub>R a) = u x *\<^sub>R x + (\<Sum>a\<in>S - {x}. u a *\<^sub>R a)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1233
          by (meson Suc.prems(3) sum.remove \<open>x \<in> S\<close>)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1234
        ultimately show "(\<Sum>x\<in>S. u x *\<^sub>R x) \<in> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1235
          by (simp add: x)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1236
      qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1237
    qed (use \<open>S\<noteq>{}\<close> \<open>finite S\<close> in auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1238
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1239
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1240
    unfolding affine_def by meson
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1241
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1242
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1243
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1244
lemma affine_hull_explicit:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1245
  "affine hull p = {y. \<exists>S u. finite S \<and> S \<noteq> {} \<and> S \<subseteq> p \<and> sum u S = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) S = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1246
  (is "_ = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1247
proof (rule hull_unique)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1248
  show "p \<subseteq> ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1249
  proof (intro subsetI CollectI exI conjI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1250
    show "\<And>x. sum (\<lambda>z. 1) {x} = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1251
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1252
  qed auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1253
  show "?rhs \<subseteq> T" if "p \<subseteq> T" "affine T" for T
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1254
    using that unfolding affine by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1255
  show "affine ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1256
    unfolding affine_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1257
  proof clarify
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1258
    fix u v :: real and sx ux sy uy
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1259
    assume uv: "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1260
      and x: "finite sx" "sx \<noteq> {}" "sx \<subseteq> p" "sum ux sx = (1::real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1261
      and y: "finite sy" "sy \<noteq> {}" "sy \<subseteq> p" "sum uy sy = (1::real)" 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1262
    have **: "(sx \<union> sy) \<inter> sx = sx" "(sx \<union> sy) \<inter> sy = sy"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1263
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1264
    show "\<exists>S w. finite S \<and> S \<noteq> {} \<and> S \<subseteq> p \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1265
        sum w S = 1 \<and> (\<Sum>v\<in>S. w v *\<^sub>R v) = u *\<^sub>R (\<Sum>v\<in>sx. ux v *\<^sub>R v) + v *\<^sub>R (\<Sum>v\<in>sy. uy v *\<^sub>R v)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1266
    proof (intro exI conjI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1267
      show "finite (sx \<union> sy)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1268
        using x y by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1269
      show "sum (\<lambda>i. (if i\<in>sx then u * ux i else 0) + (if i\<in>sy then v * uy i else 0)) (sx \<union> sy) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1270
        using x y uv
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1271
        by (simp add: sum_Un sum.distrib sum.inter_restrict[symmetric] sum_distrib_left [symmetric] **)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1272
      have "(\<Sum>i\<in>sx \<union> sy. ((if i \<in> sx then u * ux i else 0) + (if i \<in> sy then v * uy i else 0)) *\<^sub>R i)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1273
          = (\<Sum>i\<in>sx. (u * ux i) *\<^sub>R i) + (\<Sum>i\<in>sy. (v * uy i) *\<^sub>R i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1274
        using x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1275
        unfolding scaleR_left_distrib scaleR_zero_left if_smult
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1276
        by (simp add: sum_Un sum.distrib sum.inter_restrict[symmetric]  **)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1277
      also have "\<dots> = u *\<^sub>R (\<Sum>v\<in>sx. ux v *\<^sub>R v) + v *\<^sub>R (\<Sum>v\<in>sy. uy v *\<^sub>R v)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1278
        unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1279
      finally show "(\<Sum>i\<in>sx \<union> sy. ((if i \<in> sx then u * ux i else 0) + (if i \<in> sy then v * uy i else 0)) *\<^sub>R i) 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1280
                  = u *\<^sub>R (\<Sum>v\<in>sx. ux v *\<^sub>R v) + v *\<^sub>R (\<Sum>v\<in>sy. uy v *\<^sub>R v)" .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1281
    qed (use x y in auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1282
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1283
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1284
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1285
lemma affine_hull_finite:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1286
  assumes "finite S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1287
  shows "affine hull S = {y. \<exists>u. sum u S = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) S = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1288
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1289
  have *: "\<exists>h. sum h S = 1 \<and> (\<Sum>v\<in>S. h v *\<^sub>R v) = x" 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1290
    if "F \<subseteq> S" "finite F" "F \<noteq> {}" and sum: "sum u F = 1" and x: "(\<Sum>v\<in>F. u v *\<^sub>R v) = x" for x F u
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1291
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1292
    have "S \<inter> F = F"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1293
      using that by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1294
    show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1295
    proof (intro exI conjI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1296
      show "(\<Sum>x\<in>S. if x \<in> F then u x else 0) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1297
        by (metis (mono_tags, lifting) \<open>S \<inter> F = F\<close> assms sum.inter_restrict sum)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1298
      show "(\<Sum>v\<in>S. (if v \<in> F then u v else 0) *\<^sub>R v) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1299
        by (simp add: if_smult cong: if_cong) (metis (no_types) \<open>S \<inter> F = F\<close> assms sum.inter_restrict x)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1300
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1301
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1302
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1303
    unfolding affine_hull_explicit using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1304
    by (fastforce dest: *)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1305
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1306
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1307
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1308
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Stepping theorems and hence small special cases\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1309
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1310
lemma affine_hull_empty[simp]: "affine hull {} = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1311
  by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1312
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1313
lemma affine_hull_finite_step:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1314
  fixes y :: "'a::real_vector"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1315
  shows "finite S \<Longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1316
      (\<exists>u. sum u (insert a S) = w \<and> sum (\<lambda>x. u x *\<^sub>R x) (insert a S) = y) \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1317
      (\<exists>v u. sum u S = w - v \<and> sum (\<lambda>x. u x *\<^sub>R x) S = y - v *\<^sub>R a)" (is "_ \<Longrightarrow> ?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1318
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1319
  assume fin: "finite S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1320
  show "?lhs = ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1321
  proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1322
    assume ?lhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1323
    then obtain u where u: "sum u (insert a S) = w \<and> (\<Sum>x\<in>insert a S. u x *\<^sub>R x) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1324
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1325
    show ?rhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1326
    proof (cases "a \<in> S")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1327
      case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1328
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1329
        using u by (simp add: insert_absorb) (metis diff_zero real_vector.scale_zero_left)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1330
    next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1331
      case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1332
      show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1333
        by (rule exI [where x="u a"]) (use u fin False in auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1334
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1335
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1336
    assume ?rhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1337
    then obtain v u where vu: "sum u S = w - v"  "(\<Sum>x\<in>S. u x *\<^sub>R x) = y - v *\<^sub>R a"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1338
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1339
    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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1340
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1341
    show ?lhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1342
    proof (cases "a \<in> S")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1343
      case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1344
      show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1345
        by (rule exI [where x="\<lambda>x. (if x=a then v else 0) + u x"])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1346
           (simp add: True scaleR_left_distrib sum.distrib sum_clauses fin vu * cong: if_cong)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1347
    next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1348
      case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1349
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1350
        apply (rule_tac x="\<lambda>x. if x=a then v else u x" in exI) 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1351
        apply (simp add: vu sum_clauses(2)[OF fin] *)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1352
        by (simp add: sum_delta_notmem(3) vu)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1353
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1354
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1355
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1356
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1357
lemma affine_hull_2:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1358
  fixes a b :: "'a::real_vector"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1359
  shows "affine hull {a,b} = {u *\<^sub>R a + v *\<^sub>R b| u v. (u + v = 1)}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1360
  (is "?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1361
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1362
  have *:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1363
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1364
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::'a)" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1365
  have "?lhs = {y. \<exists>u. sum u {a, b} = 1 \<and> (\<Sum>v\<in>{a, b}. u v *\<^sub>R v) = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1366
    using affine_hull_finite[of "{a,b}"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1367
  also have "\<dots> = {y. \<exists>v u. u b = 1 - v \<and> u b *\<^sub>R b = y - v *\<^sub>R a}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1368
    by (simp add: affine_hull_finite_step[of "{b}" a])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1369
  also have "\<dots> = ?rhs" unfolding * by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1370
  finally show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1371
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1372
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1373
lemma affine_hull_3:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1374
  fixes a b c :: "'a::real_vector"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1375
  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}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1376
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1377
  have *:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1378
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1379
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::'a)" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1380
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1381
    apply (simp add: affine_hull_finite affine_hull_finite_step)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1382
    unfolding *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1383
    apply safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1384
     apply (metis add.assoc)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1385
    apply (rule_tac x=u in exI, force)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1386
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1387
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1388
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1389
lemma mem_affine:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1390
  assumes "affine S" "x \<in> S" "y \<in> S" "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1391
  shows "u *\<^sub>R x + v *\<^sub>R y \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1392
  using assms affine_def[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1393
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1394
lemma mem_affine_3:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1395
  assumes "affine S" "x \<in> S" "y \<in> S" "z \<in> S" "u + v + w = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1396
  shows "u *\<^sub>R x + v *\<^sub>R y + w *\<^sub>R z \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1397
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1398
  have "u *\<^sub>R x + v *\<^sub>R y + w *\<^sub>R z \<in> affine hull {x, y, z}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1399
    using affine_hull_3[of x y z] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1400
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1401
  have "affine hull {x, y, z} \<subseteq> affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1402
    using hull_mono[of "{x, y, z}" "S"] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1403
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1404
  have "affine hull S = S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1405
    using assms affine_hull_eq[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1406
  ultimately show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1407
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1408
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1409
lemma mem_affine_3_minus:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1410
  assumes "affine S" "x \<in> S" "y \<in> S" "z \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1411
  shows "x + v *\<^sub>R (y-z) \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1412
  using mem_affine_3[of S x y z 1 v "-v"] assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1413
  by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1414
71136
nipkow
parents: 71044
diff changeset
  1415
corollary%unimportant mem_affine_3_minus2:
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1416
    "\<lbrakk>affine S; x \<in> S; y \<in> S; z \<in> S\<rbrakk> \<Longrightarrow> x - v *\<^sub>R (y-z) \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1417
  by (metis add_uminus_conv_diff mem_affine_3_minus real_vector.scale_minus_left)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1418
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1419
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1420
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Some relations between affine hull and subspaces\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1421
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1422
lemma affine_hull_insert_subset_span:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1423
  "affine hull (insert a S) \<subseteq> {a + v| v . v \<in> span {x - a | x . x \<in> S}}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1424
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1425
  have "\<exists>v T u. x = a + v \<and> (finite T \<and> T \<subseteq> {x - a |x. x \<in> S} \<and> (\<Sum>v\<in>T. u v *\<^sub>R v) = v)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1426
    if "finite F" "F \<noteq> {}" "F \<subseteq> insert a S" "sum u F = 1" "(\<Sum>v\<in>F. u v *\<^sub>R v) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1427
    for x F u
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1428
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1429
    have *: "(\<lambda>x. x - a) ` (F - {a}) \<subseteq> {x - a |x. x \<in> S}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1430
      using that by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1431
    show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1432
    proof (intro exI conjI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1433
      show "finite ((\<lambda>x. x - a) ` (F - {a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1434
        by (simp add: that(1))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1435
      show "(\<Sum>v\<in>(\<lambda>x. x - a) ` (F - {a}). u(v+a) *\<^sub>R v) = x-a"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1436
        by (simp add: sum.reindex[unfolded inj_on_def] algebra_simps
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1437
            sum_subtractf scaleR_left.sum[symmetric] sum_diff1 that)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1438
    qed (use \<open>F \<subseteq> insert a S\<close> in auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1439
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1440
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1441
    unfolding affine_hull_explicit span_explicit by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1442
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1443
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1444
lemma affine_hull_insert_span:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1445
  assumes "a \<notin> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1446
  shows "affine hull (insert a S) = {a + v | v . v \<in> span {x - a | x.  x \<in> S}}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1447
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1448
  have *: "\<exists>G u. finite G \<and> G \<noteq> {} \<and> G \<subseteq> insert a S \<and> sum u G = 1 \<and> (\<Sum>v\<in>G. u v *\<^sub>R v) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1449
    if "v \<in> span {x - a |x. x \<in> S}" "y = a + v" for y v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1450
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1451
    from that
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1452
    obtain T u where u: "finite T" "T \<subseteq> {x - a |x. x \<in> S}" "a + (\<Sum>v\<in>T. u v *\<^sub>R v) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1453
      unfolding span_explicit by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1454
    define F where "F = (\<lambda>x. x + a) ` T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1455
    have F: "finite F" "F \<subseteq> S" "(\<Sum>v\<in>F. u (v - a) *\<^sub>R (v - a)) = y - a"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1456
      unfolding F_def using u by (auto simp: sum.reindex[unfolded inj_on_def])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1457
    have *: "F \<inter> {a} = {}" "F \<inter> - {a} = F"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1458
      using F assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1459
    show "\<exists>G u. finite G \<and> G \<noteq> {} \<and> G \<subseteq> insert a S \<and> sum u G = 1 \<and> (\<Sum>v\<in>G. u v *\<^sub>R v) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1460
      apply (rule_tac x = "insert a F" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1461
      apply (rule_tac x = "\<lambda>x. if x=a then 1 - sum (\<lambda>x. u (x - a)) F else u (x - a)" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1462
      using assms F
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1463
      apply (auto simp:  sum_clauses sum.If_cases if_smult sum_subtractf scaleR_left.sum algebra_simps *)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1464
      done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1465
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1466
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1467
    by (intro subset_antisym affine_hull_insert_subset_span) (auto simp: affine_hull_explicit dest!: *)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1468
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1469
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1470
lemma affine_hull_span:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1471
  assumes "a \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1472
  shows "affine hull S = {a + v | v. v \<in> span {x - a | x. x \<in> S - {a}}}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1473
  using affine_hull_insert_span[of a "S - {a}", unfolded insert_Diff[OF assms]] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1474
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1475
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1476
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Parallel affine sets\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1477
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1478
definition affine_parallel :: "'a::real_vector set \<Rightarrow> 'a::real_vector set \<Rightarrow> bool"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1479
  where "affine_parallel S T \<longleftrightarrow> (\<exists>a. T = (\<lambda>x. a + x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1480
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1481
lemma affine_parallel_expl_aux:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1482
  fixes S T :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1483
  assumes "\<And>x. x \<in> S \<longleftrightarrow> a + x \<in> T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1484
  shows "T = (\<lambda>x. a + x) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1485
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1486
  have "x \<in> ((\<lambda>x. a + x) ` S)" if "x \<in> T" for x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1487
    using that
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1488
    by (simp add: image_iff) (metis add.commute diff_add_cancel assms)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1489
  moreover have "T \<ge> (\<lambda>x. a + x) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1490
    using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1491
  ultimately show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1492
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1493
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1494
lemma affine_parallel_expl: "affine_parallel S T \<longleftrightarrow> (\<exists>a. \<forall>x. x \<in> S \<longleftrightarrow> a + x \<in> T)"
69768
7e4966eaf781 proper congruence rule for image operator
haftmann
parents: 69675
diff changeset
  1495
  by (auto simp add: affine_parallel_def)
7e4966eaf781 proper congruence rule for image operator
haftmann
parents: 69675
diff changeset
  1496
    (use affine_parallel_expl_aux [of S _ T] in blast)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1497
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1498
lemma affine_parallel_reflex: "affine_parallel S S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1499
  unfolding affine_parallel_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1500
  using image_add_0 by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1501
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1502
lemma affine_parallel_commut:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1503
  assumes "affine_parallel A B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1504
  shows "affine_parallel B A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1505
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1506
  from assms obtain a where B: "B = (\<lambda>x. a + x) ` A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1507
    unfolding affine_parallel_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1508
  have [simp]: "(\<lambda>x. x - a) = plus (- a)" by (simp add: fun_eq_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1509
  from B show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1510
    using translation_galois [of B a A]
69768
7e4966eaf781 proper congruence rule for image operator
haftmann
parents: 69675
diff changeset
  1511
    unfolding affine_parallel_def by blast
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1512
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1513
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1514
lemma affine_parallel_assoc:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1515
  assumes "affine_parallel A B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1516
    and "affine_parallel B C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1517
  shows "affine_parallel A C"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1518
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1519
  from assms obtain ab where "B = (\<lambda>x. ab + x) ` A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1520
    unfolding affine_parallel_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1521
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1522
  from assms obtain bc where "C = (\<lambda>x. bc + x) ` B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1523
    unfolding affine_parallel_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1524
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1525
    using translation_assoc[of bc ab A] unfolding affine_parallel_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1526
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1527
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1528
lemma affine_translation_aux:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1529
  fixes a :: "'a::real_vector"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1530
  assumes "affine ((\<lambda>x. a + x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1531
  shows "affine S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1532
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1533
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1534
    fix x y u v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1535
    assume xy: "x \<in> S" "y \<in> S" "(u :: real) + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1536
    then have "(a + x) \<in> ((\<lambda>x. a + x) ` S)" "(a + y) \<in> ((\<lambda>x. a + x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1537
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1538
    then have h1: "u *\<^sub>R  (a + x) + v *\<^sub>R (a + y) \<in> (\<lambda>x. a + x) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1539
      using xy assms unfolding affine_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1540
    have "u *\<^sub>R (a + x) + v *\<^sub>R (a + y) = (u + v) *\<^sub>R a + (u *\<^sub>R x + v *\<^sub>R y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1541
      by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1542
    also have "\<dots> = a + (u *\<^sub>R x + v *\<^sub>R y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1543
      using \<open>u + v = 1\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1544
    ultimately have "a + (u *\<^sub>R x + v *\<^sub>R y) \<in> (\<lambda>x. a + x) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1545
      using h1 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1546
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1547
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1548
  then show ?thesis unfolding affine_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1549
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1550
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1551
lemma affine_translation:
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1552
  "affine S \<longleftrightarrow> affine ((+) a ` S)" for a :: "'a::real_vector"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1553
proof
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1554
  show "affine ((+) a ` S)" if "affine S"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1555
    using that translation_assoc [of "- a" a S]
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1556
    by (auto intro: affine_translation_aux [of "- a" "((+) a ` S)"])
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1557
  show "affine S" if "affine ((+) a ` S)"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1558
    using that by (rule affine_translation_aux)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1559
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1560
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1561
lemma parallel_is_affine:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1562
  fixes S T :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1563
  assumes "affine S" "affine_parallel S T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1564
  shows "affine T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1565
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1566
  from assms obtain a where "T = (\<lambda>x. a + x) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1567
    unfolding affine_parallel_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1568
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1569
    using affine_translation assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1570
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1571
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1572
lemma subspace_imp_affine: "subspace s \<Longrightarrow> affine s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1573
  unfolding subspace_def affine_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1574
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1575
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1576
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Subspace parallel to an affine set\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1577
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1578
lemma subspace_affine: "subspace S \<longleftrightarrow> affine S \<and> 0 \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1579
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1580
  have h0: "subspace S \<Longrightarrow> affine S \<and> 0 \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1581
    using subspace_imp_affine[of S] subspace_0 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1582
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1583
    assume assm: "affine S \<and> 0 \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1584
    {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1585
      fix c :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1586
      fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1587
      assume x: "x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1588
      have "c *\<^sub>R x = (1-c) *\<^sub>R 0 + c *\<^sub>R x" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1589
      moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1590
      have "(1 - c) *\<^sub>R 0 + c *\<^sub>R x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1591
        using affine_alt[of S] assm x by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1592
      ultimately have "c *\<^sub>R x \<in> S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1593
    }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1594
    then have h1: "\<forall>c. \<forall>x \<in> S. c *\<^sub>R x \<in> S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1595
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1596
    {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1597
      fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1598
      assume xy: "x \<in> S" "y \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1599
      define u where "u = (1 :: real)/2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1600
      have "(1/2) *\<^sub>R (x+y) = (1/2) *\<^sub>R (x+y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1601
        by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1602
      moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1603
      have "(1/2) *\<^sub>R (x+y)=(1/2) *\<^sub>R x + (1-(1/2)) *\<^sub>R y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1604
        by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1605
      moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1606
      have "(1 - u) *\<^sub>R x + u *\<^sub>R y \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1607
        using affine_alt[of S] assm xy by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1608
      ultimately
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1609
      have "(1/2) *\<^sub>R (x+y) \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1610
        using u_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1611
      moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1612
      have "x + y = 2 *\<^sub>R ((1/2) *\<^sub>R (x+y))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1613
        by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1614
      ultimately
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1615
      have "x + y \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1616
        using h1[rule_format, of "(1/2) *\<^sub>R (x+y)" "2"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1617
    }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1618
    then have "\<forall>x \<in> S. \<forall>y \<in> S. x + y \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1619
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1620
    then have "subspace S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1621
      using h1 assm unfolding subspace_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1622
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1623
  then show ?thesis using h0 by metis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1624
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1625
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1626
lemma affine_diffs_subspace:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1627
  assumes "affine S" "a \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1628
  shows "subspace ((\<lambda>x. (-a)+x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1629
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1630
  have [simp]: "(\<lambda>x. x - a) = plus (- a)" by (simp add: fun_eq_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1631
  have "affine ((\<lambda>x. (-a)+x) ` S)"
69768
7e4966eaf781 proper congruence rule for image operator
haftmann
parents: 69675
diff changeset
  1632
    using affine_translation assms by blast
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1633
  moreover have "0 \<in> ((\<lambda>x. (-a)+x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1634
    using assms exI[of "(\<lambda>x. x\<in>S \<and> -a+x = 0)" a] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1635
  ultimately show ?thesis using subspace_affine by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1636
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1637
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1638
lemma affine_diffs_subspace_subtract:
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1639
  "subspace ((\<lambda>x. x - a) ` S)" if "affine S" "a \<in> S"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1640
  using that affine_diffs_subspace [of _ a] by simp
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  1641
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1642
lemma parallel_subspace_explicit:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1643
  assumes "affine S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1644
    and "a \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1645
  assumes "L \<equiv> {y. \<exists>x \<in> S. (-a) + x = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1646
  shows "subspace L \<and> affine_parallel S L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1647
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1648
  from assms have "L = plus (- a) ` S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1649
  then have par: "affine_parallel S L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1650
    unfolding affine_parallel_def ..
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1651
  then have "affine L" using assms parallel_is_affine by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1652
  moreover have "0 \<in> L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1653
    using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1654
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1655
    using subspace_affine par by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1656
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1657
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1658
lemma parallel_subspace_aux:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1659
  assumes "subspace A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1660
    and "subspace B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1661
    and "affine_parallel A B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1662
  shows "A \<supseteq> B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1663
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1664
  from assms obtain a where a: "\<forall>x. x \<in> A \<longleftrightarrow> a + x \<in> B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1665
    using affine_parallel_expl[of A B] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1666
  then have "-a \<in> A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1667
    using assms subspace_0[of B] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1668
  then have "a \<in> A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1669
    using assms subspace_neg[of A "-a"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1670
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1671
    using assms a unfolding subspace_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1672
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1673
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1674
lemma parallel_subspace:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1675
  assumes "subspace A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1676
    and "subspace B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1677
    and "affine_parallel A B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1678
  shows "A = B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1679
proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1680
  show "A \<supseteq> B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1681
    using assms parallel_subspace_aux by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1682
  show "A \<subseteq> B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1683
    using assms parallel_subspace_aux[of B A] affine_parallel_commut by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1684
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1685
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1686
lemma affine_parallel_subspace:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1687
  assumes "affine S" "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1688
  shows "\<exists>!L. subspace L \<and> affine_parallel S L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1689
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1690
  have ex: "\<exists>L. subspace L \<and> affine_parallel S L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1691
    using assms parallel_subspace_explicit by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1692
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1693
    fix L1 L2
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1694
    assume ass: "subspace L1 \<and> affine_parallel S L1" "subspace L2 \<and> affine_parallel S L2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1695
    then have "affine_parallel L1 L2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1696
      using affine_parallel_commut[of S L1] affine_parallel_assoc[of L1 S L2] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1697
    then have "L1 = L2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1698
      using ass parallel_subspace by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1699
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1700
  then show ?thesis using ex by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1701
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1702
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1703
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1704
subsection \<open>Cones\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1705
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1706
definition\<^marker>\<open>tag important\<close> cone :: "'a::real_vector set \<Rightarrow> bool"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1707
  where "cone s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>c\<ge>0. c *\<^sub>R x \<in> s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1708
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1709
lemma cone_empty[intro, simp]: "cone {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1710
  unfolding cone_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1711
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1712
lemma cone_univ[intro, simp]: "cone UNIV"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1713
  unfolding cone_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1714
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1715
lemma cone_Inter[intro]: "\<forall>s\<in>f. cone s \<Longrightarrow> cone (\<Inter>f)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1716
  unfolding cone_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1717
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1718
lemma subspace_imp_cone: "subspace S \<Longrightarrow> cone S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1719
  by (simp add: cone_def subspace_scale)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1720
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1721
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1722
subsubsection \<open>Conic hull\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1723
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1724
lemma cone_cone_hull: "cone (cone hull s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1725
  unfolding hull_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1726
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1727
lemma cone_hull_eq: "cone hull s = s \<longleftrightarrow> cone s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1728
  apply (rule hull_eq)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1729
  using cone_Inter
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1730
  unfolding subset_eq
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1731
  apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1732
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1733
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1734
lemma mem_cone:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1735
  assumes "cone S" "x \<in> S" "c \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1736
  shows "c *\<^sub>R x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1737
  using assms cone_def[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1738
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1739
lemma cone_contains_0:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1740
  assumes "cone S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1741
  shows "S \<noteq> {} \<longleftrightarrow> 0 \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1742
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1743
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1744
    assume "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1745
    then obtain a where "a \<in> S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1746
    then have "0 \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1747
      using assms mem_cone[of S a 0] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1748
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1749
  then show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1750
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1751
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1752
lemma cone_0: "cone {0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1753
  unfolding cone_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1754
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1755
lemma cone_Union[intro]: "(\<forall>s\<in>f. cone s) \<longrightarrow> cone (\<Union>f)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1756
  unfolding cone_def by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1757
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1758
lemma cone_iff:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1759
  assumes "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1760
  shows "cone S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ((*\<^sub>R) c) ` S = S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1761
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1762
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1763
    assume "cone S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1764
    {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1765
      fix c :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1766
      assume "c > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1767
      {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1768
        fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1769
        assume "x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1770
        then have "x \<in> ((*\<^sub>R) c) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1771
          unfolding image_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1772
          using \<open>cone S\<close> \<open>c>0\<close> mem_cone[of S x "1/c"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1773
            exI[of "(\<lambda>t. t \<in> S \<and> x = c *\<^sub>R t)" "(1 / c) *\<^sub>R x"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1774
          by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1775
      }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1776
      moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1777
      {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1778
        fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1779
        assume "x \<in> ((*\<^sub>R) c) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1780
        then have "x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1781
          using \<open>cone S\<close> \<open>c > 0\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1782
          unfolding cone_def image_def \<open>c > 0\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1783
      }
69768
7e4966eaf781 proper congruence rule for image operator
haftmann
parents: 69675
diff changeset
  1784
      ultimately have "((*\<^sub>R) c) ` S = S" by blast
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1785
    }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1786
    then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ((*\<^sub>R) c) ` S = S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1787
      using \<open>cone S\<close> cone_contains_0[of S] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1788
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1789
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1790
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1791
    assume a: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ((*\<^sub>R) c) ` S = S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1792
    {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1793
      fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1794
      assume "x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1795
      fix c1 :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1796
      assume "c1 \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1797
      then have "c1 = 0 \<or> c1 > 0" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1798
      then have "c1 *\<^sub>R x \<in> S" using a \<open>x \<in> S\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1799
    }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1800
    then have "cone S" unfolding cone_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1801
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1802
  ultimately show ?thesis by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1803
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1804
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1805
lemma cone_hull_empty: "cone hull {} = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1806
  by (metis cone_empty cone_hull_eq)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1807
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1808
lemma cone_hull_empty_iff: "S = {} \<longleftrightarrow> cone hull S = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1809
  by (metis bot_least cone_hull_empty hull_subset xtrans(5))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1810
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1811
lemma cone_hull_contains_0: "S \<noteq> {} \<longleftrightarrow> 0 \<in> cone hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1812
  using cone_cone_hull[of S] cone_contains_0[of "cone hull S"] cone_hull_empty_iff[of S]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1813
  by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1814
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1815
lemma mem_cone_hull:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1816
  assumes "x \<in> S" "c \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1817
  shows "c *\<^sub>R x \<in> cone hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1818
  by (metis assms cone_cone_hull hull_inc mem_cone)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1819
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1820
proposition cone_hull_expl: "cone hull S = {c *\<^sub>R x | c x. c \<ge> 0 \<and> x \<in> S}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1821
  (is "?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1822
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1823
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1824
    fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1825
    assume "x \<in> ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1826
    then obtain cx :: real and xx where x: "x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1827
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1828
    fix c :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1829
    assume c: "c \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1830
    then have "c *\<^sub>R x = (c * cx) *\<^sub>R xx"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1831
      using x by (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1832
    moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1833
    have "c * cx \<ge> 0" using c x by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1834
    ultimately
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1835
    have "c *\<^sub>R x \<in> ?rhs" using x by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1836
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1837
  then have "cone ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1838
    unfolding cone_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1839
  then have "?rhs \<in> Collect cone"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1840
    unfolding mem_Collect_eq by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1841
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1842
    fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1843
    assume "x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1844
    then have "1 *\<^sub>R x \<in> ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1845
      apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1846
      apply (rule_tac x = 1 in exI, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1847
      done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1848
    then have "x \<in> ?rhs" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1849
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1850
  then have "S \<subseteq> ?rhs" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1851
  then have "?lhs \<subseteq> ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1852
    using \<open>?rhs \<in> Collect cone\<close> hull_minimal[of S "?rhs" "cone"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1853
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1854
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1855
    fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1856
    assume "x \<in> ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1857
    then obtain cx :: real and xx where x: "x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1858
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1859
    then have "xx \<in> cone hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1860
      using hull_subset[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1861
    then have "x \<in> ?lhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1862
      using x cone_cone_hull[of S] cone_def[of "cone hull S"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1863
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1864
  ultimately show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1865
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1866
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1867
71044
nipkow
parents: 71040
diff changeset
  1868
subsection \<open>Affine Dependence\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1869
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1870
text "Formalized by Lars Schewe."
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1871
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1872
definition\<^marker>\<open>tag important\<close> affine_dependent :: "'a::real_vector set \<Rightarrow> bool"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1873
  where "affine_dependent s \<longleftrightarrow> (\<exists>x\<in>s. x \<in> affine hull (s - {x}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1874
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1875
lemma affine_dependent_subset:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1876
   "\<lbrakk>affine_dependent s; s \<subseteq> t\<rbrakk> \<Longrightarrow> affine_dependent t"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1877
apply (simp add: affine_dependent_def Bex_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1878
apply (blast dest: hull_mono [OF Diff_mono [OF _ subset_refl]])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1879
done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1880
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1881
lemma affine_independent_subset:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1882
  shows "\<lbrakk>\<not> affine_dependent t; s \<subseteq> t\<rbrakk> \<Longrightarrow> \<not> affine_dependent s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1883
by (metis affine_dependent_subset)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1884
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1885
lemma affine_independent_Diff:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1886
   "\<not> affine_dependent s \<Longrightarrow> \<not> affine_dependent(s - t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1887
by (meson Diff_subset affine_dependent_subset)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1888
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1889
proposition affine_dependent_explicit:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1890
  "affine_dependent p \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1891
    (\<exists>S u. finite S \<and> S \<subseteq> p \<and> sum u S = 0 \<and> (\<exists>v\<in>S. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) S = 0)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1892
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1893
  have "\<exists>S u. finite S \<and> S \<subseteq> p \<and> sum u S = 0 \<and> (\<exists>v\<in>S. u v \<noteq> 0) \<and> (\<Sum>w\<in>S. u w *\<^sub>R w) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1894
    if "(\<Sum>w\<in>S. u w *\<^sub>R w) = x" "x \<in> p" "finite S" "S \<noteq> {}" "S \<subseteq> p - {x}" "sum u S = 1" for x S u
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1895
  proof (intro exI conjI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1896
    have "x \<notin> S" 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1897
      using that by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1898
    then show "(\<Sum>v \<in> insert x S. if v = x then - 1 else u v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1899
      using that by (simp add: sum_delta_notmem)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1900
    show "(\<Sum>w \<in> insert x S. (if w = x then - 1 else u w) *\<^sub>R w) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1901
      using that \<open>x \<notin> S\<close> by (simp add: if_smult sum_delta_notmem cong: if_cong)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1902
  qed (use that in auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1903
  moreover have "\<exists>x\<in>p. \<exists>S u. finite S \<and> S \<noteq> {} \<and> S \<subseteq> p - {x} \<and> sum u S = 1 \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1904
    if "(\<Sum>v\<in>S. u v *\<^sub>R v) = 0" "finite S" "S \<subseteq> p" "sum u S = 0" "v \<in> S" "u v \<noteq> 0" for S u v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1905
  proof (intro bexI exI conjI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1906
    have "S \<noteq> {v}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1907
      using that by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1908
    then show "S - {v} \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1909
      using that by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1910
    show "(\<Sum>x \<in> S - {v}. - (1 / u v) * u x) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1911
      unfolding sum_distrib_left[symmetric] sum_diff1[OF \<open>finite S\<close>] by (simp add: that)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1912
    show "(\<Sum>x\<in>S - {v}. (- (1 / u v) * u x) *\<^sub>R x) = v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1913
      unfolding sum_distrib_left [symmetric] scaleR_scaleR[symmetric]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1914
                scaleR_right.sum [symmetric] sum_diff1[OF \<open>finite S\<close>] 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1915
      using that by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1916
    show "S - {v} \<subseteq> p - {v}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1917
      using that by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1918
  qed (use that in auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1919
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1920
    unfolding affine_dependent_def affine_hull_explicit by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1921
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1922
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1923
lemma affine_dependent_explicit_finite:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1924
  fixes S :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1925
  assumes "finite S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1926
  shows "affine_dependent S \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1927
    (\<exists>u. sum u S = 0 \<and> (\<exists>v\<in>S. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) S = 0)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1928
  (is "?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1929
proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1930
  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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1931
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1932
  assume ?lhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1933
  then obtain t u v where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1934
    "finite t" "t \<subseteq> S" "sum u t = 0" "v\<in>t" "u v \<noteq> 0"  "(\<Sum>v\<in>t. u v *\<^sub>R v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1935
    unfolding affine_dependent_explicit by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1936
  then show ?rhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1937
    apply (rule_tac x="\<lambda>x. if x\<in>t then u x else 0" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1938
    apply (auto simp: * sum.inter_restrict[OF assms, symmetric] Int_absorb1[OF \<open>t\<subseteq>S\<close>])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1939
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1940
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1941
  assume ?rhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1942
  then obtain u v where "sum u S = 0"  "v\<in>S" "u v \<noteq> 0" "(\<Sum>v\<in>S. u v *\<^sub>R v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1943
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1944
  then show ?lhs unfolding affine_dependent_explicit
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1945
    using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1946
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1947
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1948
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  1949
subsection\<^marker>\<open>tag unimportant\<close> \<open>Connectedness of convex sets\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1950
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1951
lemma connectedD:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1952
  "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 = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1953
  by (rule Topological_Spaces.topological_space_class.connectedD)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1954
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1955
lemma convex_connected:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1956
  fixes S :: "'a::real_normed_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1957
  assumes "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1958
  shows "connected S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1959
proof (rule connectedI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1960
  fix A B
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1961
  assume "open A" "open B" "A \<inter> B \<inter> S = {}" "S \<subseteq> A \<union> B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1962
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1963
  assume "A \<inter> S \<noteq> {}" "B \<inter> S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1964
  then obtain a b where a: "a \<in> A" "a \<in> S" and b: "b \<in> B" "b \<in> S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1965
  define f where [abs_def]: "f u = u *\<^sub>R a + (1 - u) *\<^sub>R b" for u
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1966
  then have "continuous_on {0 .. 1} f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1967
    by (auto intro!: continuous_intros)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1968
  then have "connected (f ` {0 .. 1})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1969
    by (auto intro!: connected_continuous_image)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1970
  note connectedD[OF this, of A B]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1971
  moreover have "a \<in> A \<inter> f ` {0 .. 1}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1972
    using a by (auto intro!: image_eqI[of _ _ 1] simp: f_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1973
  moreover have "b \<in> B \<inter> f ` {0 .. 1}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1974
    using b by (auto intro!: image_eqI[of _ _ 0] simp: f_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1975
  moreover have "f ` {0 .. 1} \<subseteq> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1976
    using \<open>convex S\<close> a b unfolding convex_def f_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1977
  ultimately show False by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1978
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1979
71136
nipkow
parents: 71044
diff changeset
  1980
corollary%unimportant connected_UNIV[intro]: "connected (UNIV :: 'a::real_normed_vector set)"
nipkow
parents: 71044
diff changeset
  1981
by (simp add: convex_connected)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1982
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1983
lemma convex_prod:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1984
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> convex {x. P i x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1985
  shows "convex {x. \<forall>i\<in>Basis. P i (x\<bullet>i)}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1986
  using assms unfolding convex_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1987
  by (auto simp: inner_add_left)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1988
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1989
lemma convex_positive_orthant: "convex {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i)}"
71136
nipkow
parents: 71044
diff changeset
  1990
by (rule convex_prod) (simp flip: atLeast_def)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1991
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1992
subsection \<open>Convex hull\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1993
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1994
lemma convex_convex_hull [iff]: "convex (convex hull s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1995
  unfolding hull_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1996
  using convex_Inter[of "{t. convex t \<and> s \<subseteq> t}"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1997
  by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1998
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  1999
lemma convex_hull_subset:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2000
    "s \<subseteq> convex hull t \<Longrightarrow> convex hull s \<subseteq> convex hull t"
71174
nipkow
parents: 71136
diff changeset
  2001
  by (simp add: subset_hull)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2002
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2003
lemma convex_hull_eq: "convex hull s = s \<longleftrightarrow> convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2004
  by (metis convex_convex_hull hull_same)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2005
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2006
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Convex hull is "preserved" by a linear function\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2007
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2008
lemma convex_hull_linear_image:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2009
  assumes f: "linear f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2010
  shows "f ` (convex hull s) = convex hull (f ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2011
proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2012
  show "convex hull (f ` s) \<subseteq> f ` (convex hull s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2013
    by (intro hull_minimal image_mono hull_subset convex_linear_image assms convex_convex_hull)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2014
  show "f ` (convex hull s) \<subseteq> convex hull (f ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2015
  proof (unfold image_subset_iff_subset_vimage, rule hull_minimal)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2016
    show "s \<subseteq> f -` (convex hull (f ` s))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2017
      by (fast intro: hull_inc)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2018
    show "convex (f -` (convex hull (f ` s)))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2019
      by (intro convex_linear_vimage [OF f] convex_convex_hull)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2020
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2021
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2022
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2023
lemma in_convex_hull_linear_image:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2024
  assumes "linear f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2025
    and "x \<in> convex hull s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2026
  shows "f x \<in> convex hull (f ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2027
  using convex_hull_linear_image[OF assms(1)] assms(2) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2028
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2029
lemma convex_hull_Times:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2030
  "convex hull (s \<times> t) = (convex hull s) \<times> (convex hull t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2031
proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2032
  show "convex hull (s \<times> t) \<subseteq> (convex hull s) \<times> (convex hull t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2033
    by (intro hull_minimal Sigma_mono hull_subset convex_Times convex_convex_hull)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2034
  have "(x, y) \<in> convex hull (s \<times> t)" if x: "x \<in> convex hull s" and y: "y \<in> convex hull t" for x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2035
  proof (rule hull_induct [OF x], rule hull_induct [OF y])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2036
    fix x y assume "x \<in> s" and "y \<in> t"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2037
    then show "(x, y) \<in> convex hull (s \<times> t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2038
      by (simp add: hull_inc)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2039
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2040
    fix x let ?S = "((\<lambda>y. (0, y)) -` (\<lambda>p. (- x, 0) + p) ` (convex hull s \<times> t))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2041
    have "convex ?S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2042
      by (intro convex_linear_vimage convex_translation convex_convex_hull,
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2043
        simp add: linear_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2044
    also have "?S = {y. (x, y) \<in> convex hull (s \<times> t)}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2045
      by (auto simp: image_def Bex_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2046
    finally show "convex {y. (x, y) \<in> convex hull (s \<times> t)}" .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2047
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2048
    show "convex {x. (x, y) \<in> convex hull s \<times> t}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2049
    proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2050
      fix y let ?S = "((\<lambda>x. (x, 0)) -` (\<lambda>p. (0, - y) + p) ` (convex hull s \<times> t))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2051
      have "convex ?S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2052
      by (intro convex_linear_vimage convex_translation convex_convex_hull,
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2053
        simp add: linear_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2054
      also have "?S = {x. (x, y) \<in> convex hull (s \<times> t)}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2055
        by (auto simp: image_def Bex_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2056
      finally show "convex {x. (x, y) \<in> convex hull (s \<times> t)}" .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2057
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2058
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2059
  then show "(convex hull s) \<times> (convex hull t) \<subseteq> convex hull (s \<times> t)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2060
    unfolding subset_eq split_paired_Ball_Sigma by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2061
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2062
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2063
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2064
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Stepping theorems for convex hulls of finite sets\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2065
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2066
lemma convex_hull_empty[simp]: "convex hull {} = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2067
  by (rule hull_unique) auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2068
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2069
lemma convex_hull_singleton[simp]: "convex hull {a} = {a}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2070
  by (rule hull_unique) auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2071
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2072
lemma convex_hull_insert:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2073
  fixes S :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2074
  assumes "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2075
  shows "convex hull (insert a S) =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2076
         {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)}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2077
  (is "_ = ?hull")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2078
proof (intro equalityI hull_minimal subsetI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2079
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2080
  assume "x \<in> insert a S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2081
  then have "\<exists>u\<ge>0. \<exists>v\<ge>0. u + v = 1 \<and> (\<exists>b. b \<in> convex hull S \<and> x = u *\<^sub>R a + v *\<^sub>R b)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2082
  unfolding insert_iff
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2083
  proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2084
    assume "x = a"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2085
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2086
      by (rule_tac x=1 in exI) (use assms hull_subset in fastforce)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2087
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2088
    assume "x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2089
    with hull_subset[of S convex] show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2090
      by force
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2091
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2092
  then show "x \<in> ?hull"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2093
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2094
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2095
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2096
  assume "x \<in> ?hull"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2097
  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"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2098
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2099
  have "a \<in> convex hull insert a S" "b \<in> convex hull insert a S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2100
    using hull_mono[of S "insert a S" convex] hull_mono[of "{a}" "insert a S" convex] and obt(4)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2101
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2102
  then show "x \<in> convex hull insert a S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2103
    unfolding obt(5) using obt(1-3)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2104
    by (rule convexD [OF convex_convex_hull])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2105
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2106
  show "convex ?hull"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2107
  proof (rule convexI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2108
    fix x y u v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2109
    assume as: "(0::real) \<le> u" "0 \<le> v" "u + v = 1" and x: "x \<in> ?hull" and y: "y \<in> ?hull"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2110
    from x obtain u1 v1 b1 where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2111
      obt1: "u1\<ge>0" "v1\<ge>0" "u1 + v1 = 1" "b1 \<in> convex hull S" and xeq: "x = u1 *\<^sub>R a + v1 *\<^sub>R b1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2112
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2113
    from y obtain u2 v2 b2 where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2114
      obt2: "u2\<ge>0" "v2\<ge>0" "u2 + v2 = 1" "b2 \<in> convex hull S" and yeq: "y = u2 *\<^sub>R a + v2 *\<^sub>R b2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2115
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2116
    have *: "\<And>(x::'a) s1 s2. x - s1 *\<^sub>R x - s2 *\<^sub>R x = ((1::real) - (s1 + s2)) *\<^sub>R x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2117
      by (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2118
    have "\<exists>b \<in> convex hull S. u *\<^sub>R x + v *\<^sub>R y =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2119
      (u * u1) *\<^sub>R a + (v * u2) *\<^sub>R a + (b - (u * u1) *\<^sub>R b - (v * u2) *\<^sub>R b)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2120
    proof (cases "u * v1 + v * v2 = 0")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2121
      case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2122
      have *: "\<And>(x::'a) s1 s2. x - s1 *\<^sub>R x - s2 *\<^sub>R x = ((1::real) - (s1 + s2)) *\<^sub>R x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2123
        by (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2124
      have eq0: "u * v1 = 0" "v * v2 = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2125
        using True mult_nonneg_nonneg[OF \<open>u\<ge>0\<close> \<open>v1\<ge>0\<close>] mult_nonneg_nonneg[OF \<open>v\<ge>0\<close> \<open>v2\<ge>0\<close>]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2126
        by arith+
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2127
      then have "u * u1 + v * u2 = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2128
        using as(3) obt1(3) obt2(3) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2129
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2130
        using "*" eq0 as obt1(4) xeq yeq by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2131
    next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2132
      case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2133
      have "1 - (u * u1 + v * u2) = (u + v) - (u * u1 + v * u2)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2134
        using as(3) obt1(3) obt2(3) by (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2135
      also have "\<dots> = u * (v1 + u1 - u1) + v * (v2 + u2 - u2)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2136
        using as(3) obt1(3) obt2(3) by (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2137
      also have "\<dots> = u * v1 + v * v2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2138
        by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2139
      finally have **:"1 - (u * u1 + v * u2) = u * v1 + v * v2" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2140
      let ?b = "((u * v1) / (u * v1 + v * v2)) *\<^sub>R b1 + ((v * v2) / (u * v1 + v * v2)) *\<^sub>R b2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2141
      have zeroes: "0 \<le> u * v1 + v * v2" "0 \<le> u * v1" "0 \<le> u * v1 + v * v2" "0 \<le> v * v2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2142
        using as(1,2) obt1(1,2) obt2(1,2) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2143
      show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2144
      proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2145
        show "u *\<^sub>R x + v *\<^sub>R y = (u * u1) *\<^sub>R a + (v * u2) *\<^sub>R a + (?b - (u * u1) *\<^sub>R ?b - (v * u2) *\<^sub>R ?b)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2146
          unfolding xeq yeq * **
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2147
          using False by (auto simp: scaleR_left_distrib scaleR_right_distrib)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2148
        show "?b \<in> convex hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2149
          using False zeroes obt1(4) obt2(4)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2150
          by (auto simp: convexD [OF convex_convex_hull] scaleR_left_distrib scaleR_right_distrib  add_divide_distrib[symmetric]  zero_le_divide_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2151
      qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2152
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2153
    then obtain b where b: "b \<in> convex hull S" 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2154
       "u *\<^sub>R x + v *\<^sub>R y = (u * u1) *\<^sub>R a + (v * u2) *\<^sub>R a + (b - (u * u1) *\<^sub>R b - (v * u2) *\<^sub>R b)" ..
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2155
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2156
    have u1: "u1 \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2157
      unfolding obt1(3)[symmetric] and not_le using obt1(2) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2158
    have u2: "u2 \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2159
      unfolding obt2(3)[symmetric] and not_le using obt2(2) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2160
    have "u1 * u + u2 * v \<le> max u1 u2 * u + max u1 u2 * v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2161
    proof (rule add_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2162
      show "u1 * u \<le> max u1 u2 * u" "u2 * v \<le> max u1 u2 * v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2163
        by (simp_all add: as mult_right_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2164
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2165
    also have "\<dots> \<le> 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2166
      unfolding distrib_left[symmetric] and as(3) using u1 u2 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2167
    finally have le1: "u1 * u + u2 * v \<le> 1" .    
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2168
    show "u *\<^sub>R x + v *\<^sub>R y \<in> ?hull"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2169
    proof (intro CollectI exI conjI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2170
      show "0 \<le> u * u1 + v * u2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2171
        by (simp add: as(1) as(2) obt1(1) obt2(1))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2172
      show "0 \<le> 1 - u * u1 - v * u2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2173
        by (simp add: le1 diff_diff_add mult.commute)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2174
    qed (use b in \<open>auto simp: algebra_simps\<close>)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2175
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2176
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2177
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2178
lemma convex_hull_insert_alt:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2179
   "convex hull (insert a S) =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2180
     (if S = {} then {a}
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2181
      else {(1 - u) *\<^sub>R a + u *\<^sub>R x |x u. 0 \<le> u \<and> u \<le> 1 \<and> x \<in> convex hull S})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2182
  apply (auto simp: convex_hull_insert)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2183
  using diff_eq_eq apply fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2184
  by (metis add.group_left_neutral add_le_imp_le_diff diff_add_cancel)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2185
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2186
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Explicit expression for convex hull\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2187
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2188
proposition convex_hull_indexed:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2189
  fixes S :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2190
  shows "convex hull S =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2191
    {y. \<exists>k u x. (\<forall>i\<in>{1::nat .. k}. 0 \<le> u i \<and> x i \<in> S) \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2192
                (sum u {1..k} = 1) \<and> (\<Sum>i = 1..k. u i *\<^sub>R x i) = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2193
    (is "?xyz = ?hull")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2194
proof (rule hull_unique [OF _ convexI])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2195
  show "S \<subseteq> ?hull" 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2196
    by (clarsimp, rule_tac x=1 in exI, rule_tac x="\<lambda>x. 1" in exI, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2197
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2198
  fix T
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2199
  assume "S \<subseteq> T" "convex T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2200
  then show "?hull \<subseteq> T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2201
    by (blast intro: convex_sum)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2202
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2203
  fix x y u v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2204
  assume uv: "0 \<le> u" "0 \<le> v" "u + v = (1::real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2205
  assume xy: "x \<in> ?hull" "y \<in> ?hull"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2206
  from xy obtain k1 u1 x1 where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2207
    x [rule_format]: "\<forall>i\<in>{1::nat..k1}. 0\<le>u1 i \<and> x1 i \<in> S" 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2208
                      "sum u1 {Suc 0..k1} = 1" "(\<Sum>i = Suc 0..k1. u1 i *\<^sub>R x1 i) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2209
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2210
  from xy obtain k2 u2 x2 where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2211
    y [rule_format]: "\<forall>i\<in>{1::nat..k2}. 0\<le>u2 i \<and> x2 i \<in> S" 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2212
                     "sum u2 {Suc 0..k2} = 1" "(\<Sum>i = Suc 0..k2. u2 i *\<^sub>R x2 i) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2213
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2214
  have *: "\<And>P (x::'a) y s t i. (if P i then s else t) *\<^sub>R (if P i then x else y) = (if P i then s *\<^sub>R x else t *\<^sub>R y)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2215
          "{1..k1 + k2} \<inter> {1..k1} = {1..k1}" "{1..k1 + k2} \<inter> - {1..k1} = (\<lambda>i. i + k1) ` {1..k2}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2216
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2217
  have inj: "inj_on (\<lambda>i. i + k1) {1..k2}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2218
    unfolding inj_on_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2219
  let ?uu = "\<lambda>i. if i \<in> {1..k1} then u * u1 i else v * u2 (i - k1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2220
  let ?xx = "\<lambda>i. if i \<in> {1..k1} then x1 i else x2 (i - k1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2221
  show "u *\<^sub>R x + v *\<^sub>R y \<in> ?hull"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2222
  proof (intro CollectI exI conjI ballI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2223
    show "0 \<le> ?uu i" "?xx i \<in> S" if "i \<in> {1..k1+k2}" for i
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2224
      using that by (auto simp add: le_diff_conv uv(1) x(1) uv(2) y(1))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2225
    show "(\<Sum>i = 1..k1 + k2. ?uu i) = 1"  "(\<Sum>i = 1..k1 + k2. ?uu i *\<^sub>R ?xx i) = u *\<^sub>R x + v *\<^sub>R y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2226
      unfolding * sum.If_cases[OF finite_atLeastAtMost[of 1 "k1 + k2"]]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2227
        sum.reindex[OF inj] Collect_mem_eq o_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2228
      unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] sum_distrib_left[symmetric]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2229
      by (simp_all add: sum_distrib_left[symmetric]  x(2,3) y(2,3) uv(3))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2230
  qed 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2231
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2232
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2233
lemma convex_hull_finite:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2234
  fixes S :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2235
  assumes "finite S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2236
  shows "convex hull S = {y. \<exists>u. (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) S = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2237
  (is "?HULL = _")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2238
proof (rule hull_unique [OF _ convexI]; clarify)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2239
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2240
  assume "x \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2241
  then show "\<exists>u. (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> (\<Sum>x\<in>S. u x *\<^sub>R x) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2242
    by (rule_tac x="\<lambda>y. if x=y then 1 else 0" in exI) (auto simp: sum.delta'[OF assms] sum_delta''[OF assms])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2243
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2244
  fix u v :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2245
  assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2246
  fix ux assume ux [rule_format]: "\<forall>x\<in>S. 0 \<le> ux x" "sum ux S = (1::real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2247
  fix uy assume uy [rule_format]: "\<forall>x\<in>S. 0 \<le> uy x" "sum uy S = (1::real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2248
  have "0 \<le> u * ux x + v * uy x" if "x\<in>S" for x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2249
    by (simp add: that uv ux(1) uy(1))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2250
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2251
  have "(\<Sum>x\<in>S. u * ux x + v * uy x) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2252
    unfolding sum.distrib and sum_distrib_left[symmetric] ux(2) uy(2)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2253
    using uv(3) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2254
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2255
  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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2256
    unfolding scaleR_left_distrib sum.distrib scaleR_scaleR[symmetric] scaleR_right.sum [symmetric]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2257
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2258
  ultimately
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2259
  show "\<exists>uc. (\<forall>x\<in>S. 0 \<le> uc x) \<and> sum uc S = 1 \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2260
             (\<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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2261
    by (rule_tac x="\<lambda>x. u * ux x + v * uy x" in exI, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2262
qed (use assms in \<open>auto simp: convex_explicit\<close>)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2263
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2264
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2265
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Another formulation\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2266
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2267
text "Formalized by Lars Schewe."
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2268
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2269
lemma convex_hull_explicit:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2270
  fixes p :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2271
  shows "convex hull p =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2272
    {y. \<exists>S u. finite S \<and> S \<subseteq> p \<and> (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) S = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2273
  (is "?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2274
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2275
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2276
    fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2277
    assume "x\<in>?lhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2278
    then obtain k u y where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2279
        obt: "\<forall>i\<in>{1::nat..k}. 0 \<le> u i \<and> y i \<in> p" "sum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R y i) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2280
      unfolding convex_hull_indexed by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2281
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2282
    have fin: "finite {1..k}" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2283
    have fin': "\<And>v. finite {i \<in> {1..k}. y i = v}" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2284
    {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2285
      fix j
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2286
      assume "j\<in>{1..k}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2287
      then have "y j \<in> p" "0 \<le> sum u {i. Suc 0 \<le> i \<and> i \<le> k \<and> y i = y j}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2288
        using obt(1)[THEN bspec[where x=j]] and obt(2)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2289
        apply simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2290
        apply (rule sum_nonneg)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2291
        using obt(1)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2292
        apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2293
        done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2294
    }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2295
    moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2296
    have "(\<Sum>v\<in>y ` {1..k}. sum u {i \<in> {1..k}. y i = v}) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2297
      unfolding sum.image_gen[OF fin, symmetric] using obt(2) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2298
    moreover have "(\<Sum>v\<in>y ` {1..k}. sum u {i \<in> {1..k}. y i = v} *\<^sub>R v) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2299
      using sum.image_gen[OF fin, of "\<lambda>i. u i *\<^sub>R y i" y, symmetric]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2300
      unfolding scaleR_left.sum using obt(3) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2301
    ultimately
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2302
    have "\<exists>S u. finite S \<and> S \<subseteq> p \<and> (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2303
      apply (rule_tac x="y ` {1..k}" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2304
      apply (rule_tac x="\<lambda>v. sum u {i\<in>{1..k}. y i = v}" in exI, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2305
      done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2306
    then have "x\<in>?rhs" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2307
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2308
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2309
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2310
    fix y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2311
    assume "y\<in>?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2312
    then obtain S u where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2313
      obt: "finite S" "S \<subseteq> p" "\<forall>x\<in>S. 0 \<le> u x" "sum u S = 1" "(\<Sum>v\<in>S. u v *\<^sub>R v) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2314
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2315
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2316
    obtain f where f: "inj_on f {1..card S}" "f ` {1..card S} = S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2317
      using ex_bij_betw_nat_finite_1[OF obt(1)] unfolding bij_betw_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2318
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2319
    {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2320
      fix i :: nat
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2321
      assume "i\<in>{1..card S}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2322
      then have "f i \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2323
        using f(2) by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2324
      then have "0 \<le> u (f i)" "f i \<in> p" using obt(2,3) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2325
    }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2326
    moreover have *: "finite {1..card S}" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2327
    {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2328
      fix y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2329
      assume "y\<in>S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2330
      then obtain i where "i\<in>{1..card S}" "f i = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2331
        using f using image_iff[of y f "{1..card S}"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2332
        by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2333
      then have "{x. Suc 0 \<le> x \<and> x \<le> card S \<and> f x = y} = {i}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2334
        apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2335
        using f(1)[unfolded inj_on_def]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2336
        by (metis One_nat_def atLeastAtMost_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2337
      then have "card {x. Suc 0 \<le> x \<and> x \<le> card S \<and> f x = y} = 1" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2338
      then have "(\<Sum>x\<in>{x \<in> {1..card S}. f x = y}. u (f x)) = u y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2339
          "(\<Sum>x\<in>{x \<in> {1..card S}. f x = y}. u (f x) *\<^sub>R f x) = u y *\<^sub>R y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2340
        by (auto simp: sum_constant_scaleR)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2341
    }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2342
    then have "(\<Sum>x = 1..card S. u (f x)) = 1" "(\<Sum>i = 1..card S. u (f i) *\<^sub>R f i) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2343
      unfolding sum.image_gen[OF *(1), of "\<lambda>x. u (f x) *\<^sub>R f x" f]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2344
        and sum.image_gen[OF *(1), of "\<lambda>x. u (f x)" f]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2345
      unfolding f
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2346
      using sum.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"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2347
      using sum.cong [of S S "\<lambda>y. (\<Sum>x\<in>{x \<in> {1..card S}. f x = y}. u (f x))" u]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2348
      unfolding obt(4,5)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2349
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2350
    ultimately
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2351
    have "\<exists>k u x. (\<forall>i\<in>{1..k}. 0 \<le> u i \<and> x i \<in> p) \<and> sum u {1..k} = 1 \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2352
        (\<Sum>i::nat = 1..k. u i *\<^sub>R x i) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2353
      apply (rule_tac x="card S" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2354
      apply (rule_tac x="u \<circ> f" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2355
      apply (rule_tac x=f in exI, fastforce)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2356
      done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2357
    then have "y \<in> ?lhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2358
      unfolding convex_hull_indexed by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2359
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2360
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2361
    unfolding set_eq_iff by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2362
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2363
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2364
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2365
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>A stepping theorem for that expansion\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2366
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2367
lemma convex_hull_finite_step:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2368
  fixes S :: "'a::real_vector set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2369
  assumes "finite S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2370
  shows
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2371
    "(\<exists>u. (\<forall>x\<in>insert a S. 0 \<le> u x) \<and> sum u (insert a S) = w \<and> sum (\<lambda>x. u x *\<^sub>R x) (insert a S) = y)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2372
      \<longleftrightarrow> (\<exists>v\<ge>0. \<exists>u. (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = w - v \<and> sum (\<lambda>x. u x *\<^sub>R x) S = y - v *\<^sub>R a)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2373
  (is "?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2374
proof (rule, case_tac[!] "a\<in>S")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2375
  assume "a \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2376
  then have *: "insert a S = S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2377
  assume ?lhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2378
  then show ?rhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2379
    unfolding *  by (rule_tac x=0 in exI, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2380
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2381
  assume ?lhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2382
  then obtain u where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2383
      u: "\<forall>x\<in>insert a S. 0 \<le> u x" "sum u (insert a S) = w" "(\<Sum>x\<in>insert a S. u x *\<^sub>R x) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2384
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2385
  assume "a \<notin> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2386
  then show ?rhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2387
    apply (rule_tac x="u a" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2388
    using u(1)[THEN bspec[where x=a]]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2389
    apply simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2390
    apply (rule_tac x=u in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2391
    using u[unfolded sum_clauses(2)[OF assms]] and \<open>a\<notin>S\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2392
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2393
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2394
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2395
  assume "a \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2396
  then have *: "insert a S = S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2397
  have fin: "finite (insert a S)" using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2398
  assume ?rhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2399
  then obtain v u where uv: "v\<ge>0" "\<forall>x\<in>S. 0 \<le> u x" "sum u S = w - v" "(\<Sum>x\<in>S. u x *\<^sub>R x) = y - v *\<^sub>R a"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2400
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2401
  show ?lhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2402
    apply (rule_tac x = "\<lambda>x. (if a = x then v else 0) + u x" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2403
    unfolding scaleR_left_distrib and sum.distrib and sum_delta''[OF fin] and sum.delta'[OF fin]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2404
    unfolding sum_clauses(2)[OF assms]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2405
    using uv and uv(2)[THEN bspec[where x=a]] and \<open>a\<in>S\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2406
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2407
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2408
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2409
  assume ?rhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2410
  then obtain v u where uv: "v\<ge>0" "\<forall>x\<in>S. 0 \<le> u x" "sum u S = w - v" "(\<Sum>x\<in>S. u x *\<^sub>R x) = y - v *\<^sub>R a"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2411
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2412
  moreover assume "a \<notin> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2413
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2414
  have "(\<Sum>x\<in>S. if a = x then v else u x) = sum u S"  "(\<Sum>x\<in>S. (if a = x then v else u x) *\<^sub>R x) = (\<Sum>x\<in>S. u x *\<^sub>R x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2415
    using \<open>a \<notin> S\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2416
    by (auto simp: intro!: sum.cong)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2417
  ultimately show ?lhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2418
    by (rule_tac x="\<lambda>x. if a = x then v else u x" in exI) (auto simp: sum_clauses(2)[OF assms])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2419
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2420
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2421
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2422
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Hence some special cases\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2423
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2424
lemma convex_hull_2:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2425
  "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}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2426
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2427
  have *: "\<And>u. (\<forall>x\<in>{a, b}. 0 \<le> u x) \<longleftrightarrow> 0 \<le> u a \<and> 0 \<le> u b"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2428
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2429
  have **: "finite {b}" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2430
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2431
    apply (simp add: convex_hull_finite)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2432
    unfolding convex_hull_finite_step[OF **, of a 1, unfolded * conj_assoc]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2433
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2434
    apply (rule_tac x=v in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2435
    apply (rule_tac x="1 - v" in exI, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2436
    apply (rule_tac x=u in exI, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2437
    apply (rule_tac x="\<lambda>x. v" in exI, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2438
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2439
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2440
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2441
lemma convex_hull_2_alt: "convex hull {a,b} = {a + u *\<^sub>R (b - a) | u.  0 \<le> u \<and> u \<le> 1}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2442
  unfolding convex_hull_2
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2443
proof (rule Collect_cong)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2444
  have *: "\<And>x y ::real. x + y = 1 \<longleftrightarrow> x = 1 - y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2445
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2446
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2447
  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>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2448
    (\<exists>u. x = a + u *\<^sub>R (b - a) \<and> 0 \<le> u \<and> u \<le> 1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2449
    unfolding *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2450
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2451
    apply (rule_tac[!] x=u in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2452
    apply (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2453
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2454
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2455
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2456
lemma convex_hull_3:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2457
  "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}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2458
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2459
  have fin: "finite {a,b,c}" "finite {b,c}" "finite {c}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2460
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2461
  have *: "\<And>x y z ::real. x + y + z = 1 \<longleftrightarrow> x = 1 - y - z"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2462
    by (auto simp: field_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2463
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2464
    unfolding convex_hull_finite[OF fin(1)] and convex_hull_finite_step[OF fin(2)] and *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2465
    unfolding convex_hull_finite_step[OF fin(3)]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2466
    apply (rule Collect_cong, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2467
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2468
    apply (rule_tac x=va in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2469
    apply (rule_tac x="u c" in exI, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2470
    apply (rule_tac x="1 - v - w" in exI, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2471
    apply (rule_tac x=v in exI, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2472
    apply (rule_tac x="\<lambda>x. w" in exI, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2473
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2474
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2475
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2476
lemma convex_hull_3_alt:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2477
  "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}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2478
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2479
  have *: "\<And>x y z ::real. x + y + z = 1 \<longleftrightarrow> x = 1 - y - z"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2480
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2481
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2482
    unfolding convex_hull_3
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2483
    apply (auto simp: *)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2484
    apply (rule_tac x=v in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2485
    apply (rule_tac x=w in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2486
    apply (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2487
    apply (rule_tac x=u in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2488
    apply (rule_tac x=v in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2489
    apply (simp add: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2490
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2491
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2492
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2493
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2494
subsection\<^marker>\<open>tag unimportant\<close> \<open>Relations among closure notions and corresponding hulls\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2495
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2496
lemma affine_imp_convex: "affine s \<Longrightarrow> convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2497
  unfolding affine_def convex_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2498
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2499
lemma convex_affine_hull [simp]: "convex (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2500
  by (simp add: affine_imp_convex)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2501
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2502
lemma subspace_imp_convex: "subspace s \<Longrightarrow> convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2503
  using subspace_imp_affine affine_imp_convex by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2504
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2505
lemma affine_hull_subset_span: "(affine hull s) \<subseteq> (span s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2506
  by (metis hull_minimal span_superset subspace_imp_affine subspace_span)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2507
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2508
lemma convex_hull_subset_span: "(convex hull s) \<subseteq> (span s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2509
  by (metis hull_minimal span_superset subspace_imp_convex subspace_span)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2510
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2511
lemma convex_hull_subset_affine_hull: "(convex hull s) \<subseteq> (affine hull s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2512
  by (metis affine_affine_hull affine_imp_convex hull_minimal hull_subset)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2513
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2514
lemma affine_dependent_imp_dependent: "affine_dependent s \<Longrightarrow> dependent s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2515
  unfolding affine_dependent_def dependent_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2516
  using affine_hull_subset_span by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2517
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2518
lemma dependent_imp_affine_dependent:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2519
  assumes "dependent {x - a| x . x \<in> s}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2520
    and "a \<notin> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2521
  shows "affine_dependent (insert a s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2522
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2523
  from assms(1)[unfolded dependent_explicit] obtain S u v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2524
    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"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2525
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2526
  define t where "t = (\<lambda>x. x + a) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2527
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2528
  have inj: "inj_on (\<lambda>x. x + a) S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2529
    unfolding inj_on_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2530
  have "0 \<notin> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2531
    using obt(2) assms(2) unfolding subset_eq by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2532
  have fin: "finite t" and "t \<subseteq> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2533
    unfolding t_def using obt(1,2) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2534
  then have "finite (insert a t)" and "insert a t \<subseteq> insert a s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2535
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2536
  moreover have *: "\<And>P Q. (\<Sum>x\<in>t. (if x = a then P x else Q x)) = (\<Sum>x\<in>t. Q x)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2537
    apply (rule sum.cong)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2538
    using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2539
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2540
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2541
  have "(\<Sum>x\<in>insert a t. if x = a then - (\<Sum>x\<in>t. u (x - a)) else u (x - a)) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2542
    unfolding sum_clauses(2)[OF fin] * using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2543
  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"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2544
    using obt(3,4) \<open>0\<notin>S\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2545
    by (rule_tac x="v + a" in bexI) (auto simp: t_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2546
  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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2547
    using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close> by (auto intro!: sum.cong)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2548
  have "(\<Sum>x\<in>t. u (x - a)) *\<^sub>R a = (\<Sum>v\<in>t. u (v - a) *\<^sub>R v)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2549
    unfolding scaleR_left.sum
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2550
    unfolding t_def and sum.reindex[OF inj] and o_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2551
    using obt(5)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2552
    by (auto simp: sum.distrib scaleR_right_distrib)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2553
  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"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2554
    unfolding sum_clauses(2)[OF fin]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2555
    using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2556
    by (auto simp: *)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2557
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2558
    unfolding affine_dependent_explicit
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2559
    apply (rule_tac x="insert a t" in exI, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2560
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2561
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2562
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2563
lemma convex_cone:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2564
  "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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2565
  (is "?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2566
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2567
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2568
    fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2569
    assume "x\<in>s" "y\<in>s" and ?lhs
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2570
    then have "2 *\<^sub>R x \<in>s" "2 *\<^sub>R y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2571
      unfolding cone_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2572
    then have "x + y \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2573
      using \<open>?lhs\<close>[unfolded convex_def, THEN conjunct1]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2574
      apply (erule_tac x="2*\<^sub>R x" in ballE)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2575
      apply (erule_tac x="2*\<^sub>R y" in ballE)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2576
      apply (erule_tac x="1/2" in allE, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2577
      apply (erule_tac x="1/2" in allE, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2578
      done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2579
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2580
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2581
    unfolding convex_def cone_def by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2582
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2583
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2584
lemma affine_dependent_biggerset:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2585
  fixes s :: "'a::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2586
  assumes "finite s" "card s \<ge> DIM('a) + 2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2587
  shows "affine_dependent s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2588
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2589
  have "s \<noteq> {}" using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2590
  then obtain a where "a\<in>s" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2591
  have *: "{x - a |x. x \<in> s - {a}} = (\<lambda>x. x - a) ` (s - {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2592
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2593
  have "card {x - a |x. x \<in> s - {a}} = card (s - {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2594
    unfolding * by (simp add: card_image inj_on_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2595
  also have "\<dots> > DIM('a)" using assms(2)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2596
    unfolding card_Diff_singleton[OF assms(1) \<open>a\<in>s\<close>] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2597
  finally show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2598
    apply (subst insert_Diff[OF \<open>a\<in>s\<close>, symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2599
    apply (rule dependent_imp_affine_dependent)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2600
    apply (rule dependent_biggerset, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2601
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2602
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2603
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2604
lemma affine_dependent_biggerset_general:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2605
  assumes "finite (S :: 'a::euclidean_space set)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2606
    and "card S \<ge> dim S + 2"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2607
  shows "affine_dependent S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2608
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2609
  from assms(2) have "S \<noteq> {}" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2610
  then obtain a where "a\<in>S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2611
  have *: "{x - a |x. x \<in> S - {a}} = (\<lambda>x. x - a) ` (S - {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2612
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2613
  have **: "card {x - a |x. x \<in> S - {a}} = card (S - {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2614
    by (metis (no_types, lifting) "*" card_image diff_add_cancel inj_on_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2615
  have "dim {x - a |x. x \<in> S - {a}} \<le> dim S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2616
    using \<open>a\<in>S\<close> by (auto simp: span_base span_diff intro: subset_le_dim)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2617
  also have "\<dots> < dim S + 1" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2618
  also have "\<dots> \<le> card (S - {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2619
    using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2620
    using card_Diff_singleton[OF assms(1) \<open>a\<in>S\<close>]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2621
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2622
  finally show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2623
    apply (subst insert_Diff[OF \<open>a\<in>S\<close>, symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2624
    apply (rule dependent_imp_affine_dependent)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2625
    apply (rule dependent_biggerset_general)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2626
    unfolding **
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2627
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2628
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2629
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2630
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2631
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2632
subsection\<^marker>\<open>tag unimportant\<close> \<open>Some Properties of Affine Dependent Sets\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2633
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2634
lemma affine_independent_0 [simp]: "\<not> affine_dependent {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2635
  by (simp add: affine_dependent_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2636
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2637
lemma affine_independent_1 [simp]: "\<not> affine_dependent {a}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2638
  by (simp add: affine_dependent_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2639
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2640
lemma affine_independent_2 [simp]: "\<not> affine_dependent {a,b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2641
  by (simp add: affine_dependent_def insert_Diff_if hull_same)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2642
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2643
lemma affine_hull_translation: "affine hull ((\<lambda>x. a + x) `  S) = (\<lambda>x. a + x) ` (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2644
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2645
  have "affine ((\<lambda>x. a + x) ` (affine hull S))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2646
    using affine_translation affine_affine_hull by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2647
  moreover have "(\<lambda>x. a + x) `  S \<subseteq> (\<lambda>x. a + x) ` (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2648
    using hull_subset[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2649
  ultimately have h1: "affine hull ((\<lambda>x. a + x) `  S) \<subseteq> (\<lambda>x. a + x) ` (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2650
    by (metis hull_minimal)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2651
  have "affine((\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S)))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2652
    using affine_translation affine_affine_hull by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2653
  moreover have "(\<lambda>x. -a + x) ` (\<lambda>x. a + x) `  S \<subseteq> (\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2654
    using hull_subset[of "(\<lambda>x. a + x) `  S"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2655
  moreover have "S = (\<lambda>x. -a + x) ` (\<lambda>x. a + x) `  S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2656
    using translation_assoc[of "-a" a] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2657
  ultimately have "(\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S)) >= (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2658
    by (metis hull_minimal)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2659
  then have "affine hull ((\<lambda>x. a + x) ` S) >= (\<lambda>x. a + x) ` (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2660
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2661
  then show ?thesis using h1 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2662
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2663
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2664
lemma affine_dependent_translation:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2665
  assumes "affine_dependent S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2666
  shows "affine_dependent ((\<lambda>x. a + x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2667
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2668
  obtain x where x: "x \<in> S \<and> x \<in> affine hull (S - {x})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2669
    using assms affine_dependent_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2670
  have "(+) a ` (S - {x}) = (+) a ` S - {a + x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2671
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2672
  then have "a + x \<in> affine hull ((\<lambda>x. a + x) ` S - {a + x})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2673
    using affine_hull_translation[of a "S - {x}"] x by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2674
  moreover have "a + x \<in> (\<lambda>x. a + x) ` S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2675
    using x by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2676
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2677
    unfolding affine_dependent_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2678
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2679
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2680
lemma affine_dependent_translation_eq:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2681
  "affine_dependent S \<longleftrightarrow> affine_dependent ((\<lambda>x. a + x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2682
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2683
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2684
    assume "affine_dependent ((\<lambda>x. a + x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2685
    then have "affine_dependent S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2686
      using affine_dependent_translation[of "((\<lambda>x. a + x) ` S)" "-a"] translation_assoc[of "-a" a]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2687
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2688
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2689
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2690
    using affine_dependent_translation by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2691
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2692
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2693
lemma affine_hull_0_dependent:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2694
  assumes "0 \<in> affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2695
  shows "dependent S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2696
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2697
  obtain s u where s_u: "finite s \<and> s \<noteq> {} \<and> s \<subseteq> S \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2698
    using assms affine_hull_explicit[of S] by auto
71040
9d2753406c60 removed redundant lemma
nipkow
parents: 70817
diff changeset
  2699
  then have "\<exists>v\<in>s. u v \<noteq> 0" by auto
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2700
  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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2701
    using s_u by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2702
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2703
    unfolding dependent_explicit[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2704
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2705
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2706
lemma affine_dependent_imp_dependent2:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2707
  assumes "affine_dependent (insert 0 S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2708
  shows "dependent S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2709
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2710
  obtain x where x: "x \<in> insert 0 S \<and> x \<in> affine hull (insert 0 S - {x})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2711
    using affine_dependent_def[of "(insert 0 S)"] assms by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2712
  then have "x \<in> span (insert 0 S - {x})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2713
    using affine_hull_subset_span by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2714
  moreover have "span (insert 0 S - {x}) = span (S - {x})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2715
    using insert_Diff_if[of "0" S "{x}"] span_insert_0[of "S-{x}"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2716
  ultimately have "x \<in> span (S - {x})" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2717
  then have "x \<noteq> 0 \<Longrightarrow> dependent S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2718
    using x dependent_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2719
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2720
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2721
    assume "x = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2722
    then have "0 \<in> affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2723
      using x hull_mono[of "S - {0}" S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2724
    then have "dependent S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2725
      using affine_hull_0_dependent by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2726
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2727
  ultimately show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2728
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2729
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2730
lemma affine_dependent_iff_dependent:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2731
  assumes "a \<notin> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2732
  shows "affine_dependent (insert a S) \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2733
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2734
  have "((+) (- a) ` S) = {x - a| x . x \<in> S}" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2735
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2736
    using affine_dependent_translation_eq[of "(insert a S)" "-a"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2737
      affine_dependent_imp_dependent2 assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2738
      dependent_imp_affine_dependent[of a S]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2739
    by (auto simp del: uminus_add_conv_diff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2740
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2741
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2742
lemma affine_dependent_iff_dependent2:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2743
  assumes "a \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2744
  shows "affine_dependent S \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` (S-{a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2745
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2746
  have "insert a (S - {a}) = S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2747
    using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2748
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2749
    using assms affine_dependent_iff_dependent[of a "S-{a}"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2750
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2751
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2752
lemma affine_hull_insert_span_gen:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2753
  "affine hull (insert a s) = (\<lambda>x. a + x) ` span ((\<lambda>x. - a + x) ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2754
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2755
  have h1: "{x - a |x. x \<in> s} = ((\<lambda>x. -a+x) ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2756
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2757
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2758
    assume "a \<notin> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2759
    then have ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2760
      using affine_hull_insert_span[of a s] h1 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2761
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2762
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2763
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2764
    assume a1: "a \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2765
    have "\<exists>x. x \<in> s \<and> -a+x=0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2766
      apply (rule exI[of _ a])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2767
      using a1
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2768
      apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2769
      done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2770
    then have "insert 0 ((\<lambda>x. -a+x) ` (s - {a})) = (\<lambda>x. -a+x) ` s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2771
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2772
    then have "span ((\<lambda>x. -a+x) ` (s - {a}))=span ((\<lambda>x. -a+x) ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2773
      using span_insert_0[of "(+) (- a) ` (s - {a})"] by (auto simp del: uminus_add_conv_diff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2774
    moreover have "{x - a |x. x \<in> (s - {a})} = ((\<lambda>x. -a+x) ` (s - {a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2775
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2776
    moreover have "insert a (s - {a}) = insert a s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2777
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2778
    ultimately have ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2779
      using affine_hull_insert_span[of "a" "s-{a}"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2780
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2781
  ultimately show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2782
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2783
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2784
lemma affine_hull_span2:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2785
  assumes "a \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2786
  shows "affine hull s = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` (s-{a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2787
  using affine_hull_insert_span_gen[of a "s - {a}", unfolded insert_Diff[OF assms]]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2788
  by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2789
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2790
lemma affine_hull_span_gen:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2791
  assumes "a \<in> affine hull s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2792
  shows "affine hull s = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` s)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2793
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2794
  have "affine hull (insert a s) = affine hull s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2795
    using hull_redundant[of a affine s] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2796
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2797
    using affine_hull_insert_span_gen[of a "s"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2798
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2799
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2800
lemma affine_hull_span_0:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2801
  assumes "0 \<in> affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2802
  shows "affine hull S = span S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2803
  using affine_hull_span_gen[of "0" S] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2804
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2805
lemma extend_to_affine_basis_nonempty:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2806
  fixes S V :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2807
  assumes "\<not> affine_dependent S" "S \<subseteq> V" "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2808
  shows "\<exists>T. \<not> affine_dependent T \<and> S \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2809
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2810
  obtain a where a: "a \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2811
    using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2812
  then have h0: "independent  ((\<lambda>x. -a + x) ` (S-{a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2813
    using affine_dependent_iff_dependent2 assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2814
  obtain B where B:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2815
    "(\<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"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2816
    using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2817
    by (blast intro: maximal_independent_subset_extend[OF _ h0, of "(\<lambda>x. -a + x) ` V"])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2818
  define T where "T = (\<lambda>x. a+x) ` insert 0 B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2819
  then have "T = insert a ((\<lambda>x. a+x) ` B)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2820
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2821
  then have "affine hull T = (\<lambda>x. a+x) ` span B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2822
    using affine_hull_insert_span_gen[of a "((\<lambda>x. a+x) ` B)"] translation_assoc[of "-a" a B]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2823
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2824
  then have "V \<subseteq> affine hull T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2825
    using B assms translation_inverse_subset[of a V "span B"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2826
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2827
  moreover have "T \<subseteq> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2828
    using T_def B a assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2829
  ultimately have "affine hull T = affine hull V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2830
    by (metis Int_absorb1 Int_absorb2 hull_hull hull_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2831
  moreover have "S \<subseteq> T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2832
    using T_def B translation_inverse_subset[of a "S-{a}" B]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2833
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2834
  moreover have "\<not> affine_dependent T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2835
    using T_def affine_dependent_translation_eq[of "insert 0 B"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2836
      affine_dependent_imp_dependent2 B
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2837
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2838
  ultimately show ?thesis using \<open>T \<subseteq> V\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2839
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2840
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2841
lemma affine_basis_exists:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2842
  fixes V :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2843
  shows "\<exists>B. B \<subseteq> V \<and> \<not> affine_dependent B \<and> affine hull V = affine hull B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2844
proof (cases "V = {}")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2845
  case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2846
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2847
    using affine_independent_0 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2848
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2849
  case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2850
  then obtain x where "x \<in> V" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2851
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2852
    using affine_dependent_def[of "{x}"] extend_to_affine_basis_nonempty[of "{x}" V]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2853
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2854
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2855
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2856
proposition extend_to_affine_basis:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2857
  fixes S V :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2858
  assumes "\<not> affine_dependent S" "S \<subseteq> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2859
  obtains T where "\<not> affine_dependent T" "S \<subseteq> T" "T \<subseteq> V" "affine hull T = affine hull V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2860
proof (cases "S = {}")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2861
  case True then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2862
    using affine_basis_exists by (metis empty_subsetI that)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2863
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2864
  case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2865
  then show ?thesis by (metis assms extend_to_affine_basis_nonempty that)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2866
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2867
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2868
subsection \<open>Affine Dimension of a Set\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2869
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  2870
definition\<^marker>\<open>tag important\<close> aff_dim :: "('a::euclidean_space) set \<Rightarrow> int"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2871
  where "aff_dim V =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2872
  (SOME d :: int.
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2873
    \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = d + 1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2874
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2875
lemma aff_dim_basis_exists:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2876
  fixes V :: "('n::euclidean_space) set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2877
  shows "\<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2878
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2879
  obtain B where "\<not> affine_dependent B \<and> affine hull B = affine hull V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2880
    using affine_basis_exists[of V] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2881
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2882
    unfolding aff_dim_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2883
      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"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2884
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2885
    apply (rule exI[of _ "int (card B) - (1 :: int)"])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2886
    apply (rule exI[of _ "B"], auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2887
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2888
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2889
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2890
lemma affine_hull_nonempty: "S \<noteq> {} \<longleftrightarrow> affine hull S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2891
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2892
  have "S = {} \<Longrightarrow> affine hull S = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2893
    using affine_hull_empty by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2894
  moreover have "affine hull S = {} \<Longrightarrow> S = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2895
    unfolding hull_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2896
  ultimately show ?thesis by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2897
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2898
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2899
lemma aff_dim_parallel_subspace_aux:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2900
  fixes B :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2901
  assumes "\<not> affine_dependent B" "a \<in> B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2902
  shows "finite B \<and> ((card B) - 1 = dim (span ((\<lambda>x. -a+x) ` (B-{a}))))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2903
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2904
  have "independent ((\<lambda>x. -a + x) ` (B-{a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2905
    using affine_dependent_iff_dependent2 assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2906
  then have fin: "dim (span ((\<lambda>x. -a+x) ` (B-{a}))) = card ((\<lambda>x. -a + x) ` (B-{a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2907
    "finite ((\<lambda>x. -a + x) ` (B - {a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2908
    using indep_card_eq_dim_span[of "(\<lambda>x. -a+x) ` (B-{a})"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2909
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2910
  proof (cases "(\<lambda>x. -a + x) ` (B - {a}) = {}")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2911
    case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2912
    have "B = insert a ((\<lambda>x. a + x) ` (\<lambda>x. -a + x) ` (B - {a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2913
      using translation_assoc[of "a" "-a" "(B - {a})"] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2914
    then have "B = {a}" using True by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2915
    then show ?thesis using assms fin by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2916
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2917
    case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2918
    then have "card ((\<lambda>x. -a + x) ` (B - {a})) > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2919
      using fin by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2920
    moreover have h1: "card ((\<lambda>x. -a + x) ` (B-{a})) = card (B-{a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2921
      by (rule card_image) (use translate_inj_on in blast)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2922
    ultimately have "card (B-{a}) > 0" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2923
    then have *: "finite (B - {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2924
      using card_gt_0_iff[of "(B - {a})"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2925
    then have "card (B - {a}) = card B - 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2926
      using card_Diff_singleton assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2927
    with * show ?thesis using fin h1 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2928
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2929
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2930
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2931
lemma aff_dim_parallel_subspace:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2932
  fixes V L :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2933
  assumes "V \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2934
    and "subspace L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2935
    and "affine_parallel (affine hull V) L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2936
  shows "aff_dim V = int (dim L)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2937
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2938
  obtain B where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2939
    B: "affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = aff_dim V + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2940
    using aff_dim_basis_exists by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2941
  then have "B \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2942
    using assms B affine_hull_nonempty[of V] affine_hull_nonempty[of B]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2943
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2944
  then obtain a where a: "a \<in> B" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2945
  define Lb where "Lb = span ((\<lambda>x. -a+x) ` (B-{a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2946
  moreover have "affine_parallel (affine hull B) Lb"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2947
    using Lb_def B assms affine_hull_span2[of a B] a
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2948
      affine_parallel_commut[of "Lb" "(affine hull B)"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2949
    unfolding affine_parallel_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2950
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2951
  moreover have "subspace Lb"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2952
    using Lb_def subspace_span by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2953
  moreover have "affine hull B \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2954
    using assms B affine_hull_nonempty[of V] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2955
  ultimately have "L = Lb"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2956
    using assms affine_parallel_subspace[of "affine hull B"] affine_affine_hull[of B] B
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2957
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2958
  then have "dim L = dim Lb"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2959
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2960
  moreover have "card B - 1 = dim Lb" and "finite B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2961
    using Lb_def aff_dim_parallel_subspace_aux a B by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2962
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2963
    using B \<open>B \<noteq> {}\<close> card_gt_0_iff[of B] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2964
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2965
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2966
lemma aff_independent_finite:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2967
  fixes B :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2968
  assumes "\<not> affine_dependent B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2969
  shows "finite B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2970
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2971
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2972
    assume "B \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2973
    then obtain a where "a \<in> B" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2974
    then have ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2975
      using aff_dim_parallel_subspace_aux assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2976
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2977
  then show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2978
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2979
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2980
lemmas independent_finite = independent_imp_finite
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2981
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2982
lemma span_substd_basis:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2983
  assumes d: "d \<subseteq> Basis"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2984
  shows "span d = {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2985
  (is "_ = ?B")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2986
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2987
  have "d \<subseteq> ?B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2988
    using d by (auto simp: inner_Basis)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2989
  moreover have s: "subspace ?B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2990
    using subspace_substandard[of "\<lambda>i. i \<notin> d"] .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2991
  ultimately have "span d \<subseteq> ?B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2992
    using span_mono[of d "?B"] span_eq_iff[of "?B"] by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2993
  moreover have *: "card d \<le> dim (span d)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2994
    using independent_card_le_dim[of d "span d"] independent_substdbasis[OF assms]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2995
      span_superset[of d]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2996
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2997
  moreover from * have "dim ?B \<le> dim (span d)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2998
    using dim_substandard[OF assms] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  2999
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3000
    using s subspace_dim_equal[of "span d" "?B"] subspace_span[of d] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3001
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3002
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3003
lemma basis_to_substdbasis_subspace_isomorphism:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3004
  fixes B :: "'a::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3005
  assumes "independent B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3006
  shows "\<exists>f d::'a set. card d = card B \<and> linear f \<and> f ` B = d \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3007
    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"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3008
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3009
  have B: "card B = dim B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3010
    using dim_unique[of B B "card B"] assms span_superset[of B] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3011
  have "dim B \<le> card (Basis :: 'a set)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3012
    using dim_subset_UNIV[of B] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3013
  from ex_card[OF this] obtain d :: "'a set" where d: "d \<subseteq> Basis" and t: "card d = dim B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3014
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3015
  let ?t = "{x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3016
  have "\<exists>f. linear f \<and> f ` B = d \<and> f ` span B = ?t \<and> inj_on f (span B)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3017
  proof (intro basis_to_basis_subspace_isomorphism subspace_span subspace_substandard span_superset)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3018
    show "d \<subseteq> {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3019
      using d inner_not_same_Basis by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3020
  qed (auto simp: span_substd_basis independent_substdbasis dim_substandard d t B assms)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3021
  with t \<open>card B = dim B\<close> d show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3022
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3023
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3024
lemma aff_dim_empty:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3025
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3026
  shows "S = {} \<longleftrightarrow> aff_dim S = -1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3027
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3028
  obtain B where *: "affine hull B = affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3029
    and "\<not> affine_dependent B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3030
    and "int (card B) = aff_dim S + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3031
    using aff_dim_basis_exists by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3032
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3033
  from * have "S = {} \<longleftrightarrow> B = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3034
    using affine_hull_nonempty[of B] affine_hull_nonempty[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3035
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3036
    using aff_independent_finite[of B] card_gt_0_iff[of B] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3037
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3038
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3039
lemma aff_dim_empty_eq [simp]: "aff_dim ({}::'a::euclidean_space set) = -1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3040
  by (simp add: aff_dim_empty [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3041
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3042
lemma aff_dim_affine_hull [simp]: "aff_dim (affine hull S) = aff_dim S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3043
  unfolding aff_dim_def using hull_hull[of _ S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3044
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3045
lemma aff_dim_affine_hull2:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3046
  assumes "affine hull S = affine hull T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3047
  shows "aff_dim S = aff_dim T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3048
  unfolding aff_dim_def using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3049
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3050
lemma aff_dim_unique:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3051
  fixes B V :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3052
  assumes "affine hull B = affine hull V \<and> \<not> affine_dependent B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3053
  shows "of_nat (card B) = aff_dim V + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3054
proof (cases "B = {}")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3055
  case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3056
  then have "V = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3057
    using affine_hull_nonempty[of V] affine_hull_nonempty[of B] assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3058
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3059
  then have "aff_dim V = (-1::int)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3060
    using aff_dim_empty by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3061
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3062
    using \<open>B = {}\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3063
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3064
  case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3065
  then obtain a where a: "a \<in> B" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3066
  define Lb where "Lb = span ((\<lambda>x. -a+x) ` (B-{a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3067
  have "affine_parallel (affine hull B) Lb"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3068
    using Lb_def affine_hull_span2[of a B] a
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3069
      affine_parallel_commut[of "Lb" "(affine hull B)"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3070
    unfolding affine_parallel_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3071
  moreover have "subspace Lb"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3072
    using Lb_def subspace_span by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3073
  ultimately have "aff_dim B = int(dim Lb)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3074
    using aff_dim_parallel_subspace[of B Lb] \<open>B \<noteq> {}\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3075
  moreover have "(card B) - 1 = dim Lb" "finite B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3076
    using Lb_def aff_dim_parallel_subspace_aux a assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3077
  ultimately have "of_nat (card B) = aff_dim B + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3078
    using \<open>B \<noteq> {}\<close> card_gt_0_iff[of B] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3079
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3080
    using aff_dim_affine_hull2 assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3081
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3082
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3083
lemma aff_dim_affine_independent:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3084
  fixes B :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3085
  assumes "\<not> affine_dependent B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3086
  shows "of_nat (card B) = aff_dim B + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3087
  using aff_dim_unique[of B B] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3088
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3089
lemma affine_independent_iff_card:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3090
    fixes s :: "'a::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3091
    shows "\<not> affine_dependent s \<longleftrightarrow> finite s \<and> aff_dim s = int(card s) - 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3092
  apply (rule iffI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3093
  apply (simp add: aff_dim_affine_independent aff_independent_finite)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3094
  by (metis affine_basis_exists [of s] aff_dim_unique card_subset_eq diff_add_cancel of_nat_eq_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3095
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3096
lemma aff_dim_sing [simp]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3097
  fixes a :: "'n::euclidean_space"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3098
  shows "aff_dim {a} = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3099
  using aff_dim_affine_independent[of "{a}"] affine_independent_1 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3100
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3101
lemma aff_dim_2 [simp]: "aff_dim {a,b} = (if a = b then 0 else 1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3102
proof (clarsimp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3103
  assume "a \<noteq> b"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3104
  then have "aff_dim{a,b} = card{a,b} - 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3105
    using affine_independent_2 [of a b] aff_dim_affine_independent by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3106
  also have "\<dots> = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3107
    using \<open>a \<noteq> b\<close> by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3108
  finally show "aff_dim {a, b} = 1" .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3109
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3110
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3111
lemma aff_dim_inner_basis_exists:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3112
  fixes V :: "('n::euclidean_space) set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3113
  shows "\<exists>B. B \<subseteq> V \<and> affine hull B = affine hull V \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3114
    \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3115
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3116
  obtain B where B: "\<not> affine_dependent B" "B \<subseteq> V" "affine hull B = affine hull V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3117
    using affine_basis_exists[of V] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3118
  then have "of_nat(card B) = aff_dim V+1" using aff_dim_unique by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3119
  with B show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3120
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3121
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3122
lemma aff_dim_le_card:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3123
  fixes V :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3124
  assumes "finite V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3125
  shows "aff_dim V \<le> of_nat (card V) - 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3126
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3127
  obtain B where B: "B \<subseteq> V" "of_nat (card B) = aff_dim V + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3128
    using aff_dim_inner_basis_exists[of V] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3129
  then have "card B \<le> card V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3130
    using assms card_mono by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3131
  with B show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3132
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3133
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3134
lemma aff_dim_parallel_eq:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3135
  fixes S T :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3136
  assumes "affine_parallel (affine hull S) (affine hull T)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3137
  shows "aff_dim S = aff_dim T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3138
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3139
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3140
    assume "T \<noteq> {}" "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3141
    then obtain L where L: "subspace L \<and> affine_parallel (affine hull T) L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3142
      using affine_parallel_subspace[of "affine hull T"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3143
        affine_affine_hull[of T] affine_hull_nonempty
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3144
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3145
    then have "aff_dim T = int (dim L)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3146
      using aff_dim_parallel_subspace \<open>T \<noteq> {}\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3147
    moreover have *: "subspace L \<and> affine_parallel (affine hull S) L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3148
       using L affine_parallel_assoc[of "affine hull S" "affine hull T" L] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3149
    moreover from * have "aff_dim S = int (dim L)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3150
      using aff_dim_parallel_subspace \<open>S \<noteq> {}\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3151
    ultimately have ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3152
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3153
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3154
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3155
    assume "S = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3156
    then have "S = {}" and "T = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3157
      using assms affine_hull_nonempty
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3158
      unfolding affine_parallel_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3159
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3160
    then have ?thesis using aff_dim_empty by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3161
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3162
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3163
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3164
    assume "T = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3165
    then have "S = {}" and "T = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3166
      using assms affine_hull_nonempty
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3167
      unfolding affine_parallel_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3168
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3169
    then have ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3170
      using aff_dim_empty by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3171
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3172
  ultimately show ?thesis by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3173
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3174
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3175
lemma aff_dim_translation_eq:
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3176
  "aff_dim ((+) a ` S) = aff_dim S" for a :: "'n::euclidean_space"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3177
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3178
  have "affine_parallel (affine hull S) (affine hull ((\<lambda>x. a + x) ` S))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3179
    unfolding affine_parallel_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3180
    apply (rule exI[of _ "a"])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3181
    using affine_hull_translation[of a S]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3182
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3183
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3184
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3185
    using aff_dim_parallel_eq[of S "(\<lambda>x. a + x) ` S"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3186
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3187
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3188
lemma aff_dim_translation_eq_subtract:
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3189
  "aff_dim ((\<lambda>x. x - a) ` S) = aff_dim S" for a :: "'n::euclidean_space"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3190
  using aff_dim_translation_eq [of "- a"] by (simp cong: image_cong_simp)
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3191
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3192
lemma aff_dim_affine:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3193
  fixes S L :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3194
  assumes "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3195
    and "affine S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3196
    and "subspace L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3197
    and "affine_parallel S L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3198
  shows "aff_dim S = int (dim L)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3199
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3200
  have *: "affine hull S = S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3201
    using assms affine_hull_eq[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3202
  then have "affine_parallel (affine hull S) L"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3203
    using assms by (simp add: *)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3204
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3205
    using assms aff_dim_parallel_subspace[of S L] by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3206
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3207
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3208
lemma dim_affine_hull:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3209
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3210
  shows "dim (affine hull S) = dim S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3211
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3212
  have "dim (affine hull S) \<ge> dim S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3213
    using dim_subset by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3214
  moreover have "dim (span S) \<ge> dim (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3215
    using dim_subset affine_hull_subset_span by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3216
  moreover have "dim (span S) = dim S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3217
    using dim_span by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3218
  ultimately show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3219
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3220
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3221
lemma aff_dim_subspace:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3222
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3223
  assumes "subspace S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3224
  shows "aff_dim S = int (dim S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3225
proof (cases "S={}")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3226
  case True with assms show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3227
    by (simp add: subspace_affine)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3228
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3229
  case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3230
  with aff_dim_affine[of S S] assms subspace_imp_affine[of S] affine_parallel_reflex[of S] subspace_affine
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3231
  show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3232
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3233
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3234
lemma aff_dim_zero:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3235
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3236
  assumes "0 \<in> affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3237
  shows "aff_dim S = int (dim S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3238
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3239
  have "subspace (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3240
    using subspace_affine[of "affine hull S"] affine_affine_hull assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3241
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3242
  then have "aff_dim (affine hull S) = int (dim (affine hull S))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3243
    using assms aff_dim_subspace[of "affine hull S"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3244
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3245
    using aff_dim_affine_hull[of S] dim_affine_hull[of S]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3246
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3247
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3248
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3249
lemma aff_dim_eq_dim:
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3250
  "aff_dim S = int (dim ((+) (- a) ` S))" if "a \<in> affine hull S"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3251
    for S :: "'n::euclidean_space set"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3252
proof -
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3253
  have "0 \<in> affine hull (+) (- a) ` S"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3254
    unfolding affine_hull_translation
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3255
    using that by (simp add: ac_simps)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3256
  with aff_dim_zero show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3257
    by (metis aff_dim_translation_eq)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3258
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3259
69661
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3260
lemma aff_dim_eq_dim_subtract:
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3261
  "aff_dim S = int (dim ((\<lambda>x. x - a) ` S))" if "a \<in> affine hull S"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3262
    for S :: "'n::euclidean_space set"
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3263
  using aff_dim_eq_dim [of a] that by (simp cong: image_cong_simp)
a03a63b81f44 tuned proofs
haftmann
parents: 69619
diff changeset
  3264
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3265
lemma aff_dim_UNIV [simp]: "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3266
  using aff_dim_subspace[of "(UNIV :: 'n::euclidean_space set)"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3267
    dim_UNIV[where 'a="'n::euclidean_space"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3268
  by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3269
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3270
lemma aff_dim_geq:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3271
  fixes V :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3272
  shows "aff_dim V \<ge> -1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3273
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3274
  obtain B where "affine hull B = affine hull V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3275
    and "\<not> affine_dependent B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3276
    and "int (card B) = aff_dim V + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3277
    using aff_dim_basis_exists by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3278
  then show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3279
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3280
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3281
lemma aff_dim_negative_iff [simp]:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3282
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3283
  shows "aff_dim S < 0 \<longleftrightarrow>S = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3284
by (metis aff_dim_empty aff_dim_geq diff_0 eq_iff zle_diff1_eq)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3285
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3286
lemma aff_lowdim_subset_hyperplane:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3287
  fixes S :: "'a::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3288
  assumes "aff_dim S < DIM('a)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3289
  obtains a b where "a \<noteq> 0" "S \<subseteq> {x. a \<bullet> x = b}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3290
proof (cases "S={}")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3291
  case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3292
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3293
  have "(SOME b. b \<in> Basis) \<noteq> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3294
    by (metis norm_some_Basis norm_zero zero_neq_one)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3295
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3296
    using that by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3297
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3298
  case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3299
  then obtain c S' where "c \<notin> S'" "S = insert c S'"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3300
    by (meson equals0I mk_disjoint_insert)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3301
  have "dim ((+) (-c) ` S) < DIM('a)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3302
    by (metis \<open>S = insert c S'\<close> aff_dim_eq_dim assms hull_inc insertI1 of_nat_less_imp_less)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3303
  then obtain a where "a \<noteq> 0" "span ((+) (-c) ` S) \<subseteq> {x. a \<bullet> x = 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3304
    using lowdim_subset_hyperplane by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3305
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3306
  have "a \<bullet> w = a \<bullet> c" if "span ((+) (- c) ` S) \<subseteq> {x. a \<bullet> x = 0}" "w \<in> S" for w
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3307
  proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3308
    have "w-c \<in> span ((+) (- c) ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3309
      by (simp add: span_base \<open>w \<in> S\<close>)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3310
    with that have "w-c \<in> {x. a \<bullet> x = 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3311
      by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3312
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3313
      by (auto simp: algebra_simps)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3314
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3315
  ultimately have "S \<subseteq> {x. a \<bullet> x = a \<bullet> c}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3316
    by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3317
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3318
    by (rule that[OF \<open>a \<noteq> 0\<close>])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3319
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3320
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3321
lemma affine_independent_card_dim_diffs:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3322
  fixes S :: "'a :: euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3323
  assumes "\<not> affine_dependent S" "a \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3324
    shows "card S = dim {x - a|x. x \<in> S} + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3325
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3326
  have 1: "{b - a|b. b \<in> (S - {a})} \<subseteq> {x - a|x. x \<in> S}" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3327
  have 2: "x - a \<in> span {b - a |b. b \<in> S - {a}}" if "x \<in> S" for x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3328
  proof (cases "x = a")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3329
    case True then show ?thesis by (simp add: span_clauses)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3330
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3331
    case False then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3332
      using assms by (blast intro: span_base that)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3333
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3334
  have "\<not> affine_dependent (insert a S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3335
    by (simp add: assms insert_absorb)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3336
  then have 3: "independent {b - a |b. b \<in> S - {a}}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3337
      using dependent_imp_affine_dependent by fastforce
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3338
  have "{b - a |b. b \<in> S - {a}} = (\<lambda>b. b-a) ` (S - {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3339
    by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3340
  then have "card {b - a |b. b \<in> S - {a}} = card ((\<lambda>b. b-a) ` (S - {a}))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3341
    by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3342
  also have "\<dots> = card (S - {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3343
    by (metis (no_types, lifting) card_image diff_add_cancel inj_onI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3344
  also have "\<dots> = card S - 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3345
    by (simp add: aff_independent_finite assms)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3346
  finally have 4: "card {b - a |b. b \<in> S - {a}} = card S - 1" .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3347
  have "finite S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3348
    by (meson assms aff_independent_finite)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3349
  with \<open>a \<in> S\<close> have "card S \<noteq> 0" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3350
  moreover have "dim {x - a |x. x \<in> S} = card S - 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3351
    using 2 by (blast intro: dim_unique [OF 1 _ 3 4])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3352
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3353
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3354
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3355
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3356
lemma independent_card_le_aff_dim:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3357
  fixes B :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3358
  assumes "B \<subseteq> V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3359
  assumes "\<not> affine_dependent B"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3360
  shows "int (card B) \<le> aff_dim V + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3361
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3362
  obtain T where T: "\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3363
    by (metis assms extend_to_affine_basis[of B V])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3364
  then have "of_nat (card T) = aff_dim V + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3365
    using aff_dim_unique by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3366
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3367
    using T card_mono[of T B] aff_independent_finite[of T] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3368
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3369
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3370
lemma aff_dim_subset:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3371
  fixes S T :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3372
  assumes "S \<subseteq> T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3373
  shows "aff_dim S \<le> aff_dim T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3374
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3375
  obtain B where B: "\<not> affine_dependent B" "B \<subseteq> S" "affine hull B = affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3376
    "of_nat (card B) = aff_dim S + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3377
    using aff_dim_inner_basis_exists[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3378
  then have "int (card B) \<le> aff_dim T + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3379
    using assms independent_card_le_aff_dim[of B T] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3380
  with B show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3381
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3382
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3383
lemma aff_dim_le_DIM:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3384
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3385
  shows "aff_dim S \<le> int (DIM('n))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3386
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3387
  have "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3388
    using aff_dim_UNIV by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3389
  then show "aff_dim (S:: 'n::euclidean_space set) \<le> int(DIM('n))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3390
    using aff_dim_subset[of S "(UNIV :: ('n::euclidean_space) set)"] subset_UNIV by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3391
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3392
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3393
lemma affine_dim_equal:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3394
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3395
  assumes "affine S" "affine T" "S \<noteq> {}" "S \<subseteq> T" "aff_dim S = aff_dim T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3396
  shows "S = T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3397
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3398
  obtain a where "a \<in> S" using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3399
  then have "a \<in> T" using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3400
  define LS where "LS = {y. \<exists>x \<in> S. (-a) + x = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3401
  then have ls: "subspace LS" "affine_parallel S LS"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3402
    using assms parallel_subspace_explicit[of S a LS] \<open>a \<in> S\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3403
  then have h1: "int(dim LS) = aff_dim S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3404
    using assms aff_dim_affine[of S LS] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3405
  have "T \<noteq> {}" using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3406
  define LT where "LT = {y. \<exists>x \<in> T. (-a) + x = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3407
  then have lt: "subspace LT \<and> affine_parallel T LT"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3408
    using assms parallel_subspace_explicit[of T a LT] \<open>a \<in> T\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3409
  then have "int(dim LT) = aff_dim T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3410
    using assms aff_dim_affine[of T LT] \<open>T \<noteq> {}\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3411
  then have "dim LS = dim LT"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3412
    using h1 assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3413
  moreover have "LS \<le> LT"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3414
    using LS_def LT_def assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3415
  ultimately have "LS = LT"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3416
    using subspace_dim_equal[of LS LT] ls lt by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3417
  moreover have "S = {x. \<exists>y \<in> LS. a+y=x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3418
    using LS_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3419
  moreover have "T = {x. \<exists>y \<in> LT. a+y=x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3420
    using LT_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3421
  ultimately show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3422
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3423
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3424
lemma aff_dim_eq_0:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3425
  fixes S :: "'a::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3426
  shows "aff_dim S = 0 \<longleftrightarrow> (\<exists>a. S = {a})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3427
proof (cases "S = {}")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3428
  case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3429
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3430
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3431
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3432
  case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3433
  then obtain a where "a \<in> S" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3434
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3435
  proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3436
    assume 0: "aff_dim S = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3437
    have "\<not> {a,b} \<subseteq> S" if "b \<noteq> a" for b
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3438
      by (metis "0" aff_dim_2 aff_dim_subset not_one_le_zero that)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3439
    then show "\<exists>a. S = {a}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3440
      using \<open>a \<in> S\<close> by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3441
  qed auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3442
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3443
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3444
lemma affine_hull_UNIV:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3445
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3446
  assumes "aff_dim S = int(DIM('n))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3447
  shows "affine hull S = (UNIV :: ('n::euclidean_space) set)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3448
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3449
  have "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3450
    using assms aff_dim_empty[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3451
  have h0: "S \<subseteq> affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3452
    using hull_subset[of S _] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3453
  have h1: "aff_dim (UNIV :: ('n::euclidean_space) set) = aff_dim S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3454
    using aff_dim_UNIV assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3455
  then have h2: "aff_dim (affine hull S) \<le> aff_dim (UNIV :: ('n::euclidean_space) set)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3456
    using aff_dim_le_DIM[of "affine hull S"] assms h0 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3457
  have h3: "aff_dim S \<le> aff_dim (affine hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3458
    using h0 aff_dim_subset[of S "affine hull S"] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3459
  then have h4: "aff_dim (affine hull S) = aff_dim (UNIV :: ('n::euclidean_space) set)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3460
    using h0 h1 h2 by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3461
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3462
    using affine_dim_equal[of "affine hull S" "(UNIV :: ('n::euclidean_space) set)"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3463
      affine_affine_hull[of S] affine_UNIV assms h4 h0 \<open>S \<noteq> {}\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3464
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3465
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3466
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3467
lemma disjoint_affine_hull:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3468
  fixes s :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3469
  assumes "\<not> affine_dependent s" "t \<subseteq> s" "u \<subseteq> s" "t \<inter> u = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3470
    shows "(affine hull t) \<inter> (affine hull u) = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3471
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3472
  have "finite s" using assms by (simp add: aff_independent_finite)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3473
  then have "finite t" "finite u" using assms finite_subset by blast+
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3474
  { fix y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3475
    assume yt: "y \<in> affine hull t" and yu: "y \<in> affine hull u"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3476
    then obtain a b
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3477
           where a1 [simp]: "sum a t = 1" and [simp]: "sum (\<lambda>v. a v *\<^sub>R v) t = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3478
             and [simp]: "sum b u = 1" "sum (\<lambda>v. b v *\<^sub>R v) u = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3479
      by (auto simp: affine_hull_finite \<open>finite t\<close> \<open>finite u\<close>)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3480
    define c where "c x = (if x \<in> t then a x else if x \<in> u then -(b x) else 0)" for x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3481
    have [simp]: "s \<inter> t = t" "s \<inter> - t \<inter> u = u" using assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3482
    have "sum c s = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3483
      by (simp add: c_def comm_monoid_add_class.sum.If_cases \<open>finite s\<close> sum_negf)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3484
    moreover have "\<not> (\<forall>v\<in>s. c v = 0)"
71040
9d2753406c60 removed redundant lemma
nipkow
parents: 70817
diff changeset
  3485
      by (metis (no_types) IntD1 \<open>s \<inter> t = t\<close> a1 c_def sum.neutral zero_neq_one)
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3486
    moreover have "(\<Sum>v\<in>s. c v *\<^sub>R v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3487
      by (simp add: c_def if_smult sum_negf
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3488
             comm_monoid_add_class.sum.If_cases \<open>finite s\<close>)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3489
    ultimately have False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3490
      using assms \<open>finite s\<close> by (auto simp: affine_dependent_explicit)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3491
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3492
  then show ?thesis by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3493
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3494
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3495
lemma aff_dim_convex_hull:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3496
  fixes S :: "'n::euclidean_space set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3497
  shows "aff_dim (convex hull S) = aff_dim S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3498
  using aff_dim_affine_hull[of S] convex_hull_subset_affine_hull[of S]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3499
    hull_subset[of S "convex"] aff_dim_subset[of S "convex hull S"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3500
    aff_dim_subset[of "convex hull S" "affine hull S"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3501
  by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3502
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3503
subsection \<open>Caratheodory's theorem\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3504
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3505
lemma convex_hull_caratheodory_aff_dim:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3506
  fixes p :: "('a::euclidean_space) set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3507
  shows "convex hull p =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3508
    {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> aff_dim p + 1 \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3509
      (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) s = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3510
  unfolding convex_hull_explicit set_eq_iff mem_Collect_eq
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3511
proof (intro allI iffI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3512
  fix y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3513
  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>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3514
    sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3515
  assume "\<exists>s u. finite s \<and> s \<subseteq> p \<and> (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3516
  then obtain N where "?P N" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3517
  then have "\<exists>n\<le>N. (\<forall>k<n. \<not> ?P k) \<and> ?P n"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3518
    apply (rule_tac ex_least_nat_le, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3519
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3520
  then obtain n where "?P n" and smallest: "\<forall>k<n. \<not> ?P k"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3521
    by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3522
  then obtain s u where obt: "finite s" "card s = n" "s\<subseteq>p" "\<forall>x\<in>s. 0 \<le> u x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3523
    "sum u s = 1"  "(\<Sum>v\<in>s. u v *\<^sub>R v) = y" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3524
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3525
  have "card s \<le> aff_dim p + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3526
  proof (rule ccontr, simp only: not_le)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3527
    assume "aff_dim p + 1 < card s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3528
    then have "affine_dependent s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3529
      using affine_dependent_biggerset[OF obt(1)] independent_card_le_aff_dim not_less obt(3)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3530
      by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3531
    then obtain w v where wv: "sum w s = 0" "v\<in>s" "w v \<noteq> 0" "(\<Sum>v\<in>s. w v *\<^sub>R v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3532
      using affine_dependent_explicit_finite[OF obt(1)] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3533
    define i where "i = (\<lambda>v. (u v) / (- w v)) ` {v\<in>s. w v < 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3534
    define t where "t = Min i"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3535
    have "\<exists>x\<in>s. w x < 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3536
    proof (rule ccontr, simp add: not_less)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3537
      assume as:"\<forall>x\<in>s. 0 \<le> w x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3538
      then have "sum w (s - {v}) \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3539
        apply (rule_tac sum_nonneg, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3540
        done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3541
      then have "sum w s > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3542
        unfolding sum.remove[OF obt(1) \<open>v\<in>s\<close>]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3543
        using as[THEN bspec[where x=v]]  \<open>v\<in>s\<close>  \<open>w v \<noteq> 0\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3544
      then show False using wv(1) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3545
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3546
    then have "i \<noteq> {}" unfolding i_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3547
    then have "t \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3548
      using Min_ge_iff[of i 0 ] and obt(1)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3549
      unfolding t_def i_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3550
      using obt(4)[unfolded le_less]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3551
      by (auto simp: divide_le_0_iff)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3552
    have t: "\<forall>v\<in>s. u v + t * w v \<ge> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3553
    proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3554
      fix v
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3555
      assume "v \<in> s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3556
      then have v: "0 \<le> u v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3557
        using obt(4)[THEN bspec[where x=v]] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3558
      show "0 \<le> u v + t * w v"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3559
      proof (cases "w v < 0")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3560
        case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3561
        thus ?thesis using v \<open>t\<ge>0\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3562
      next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3563
        case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3564
        then have "t \<le> u v / (- w v)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3565
          using \<open>v\<in>s\<close> unfolding t_def i_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3566
          apply (rule_tac Min_le)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3567
          using obt(1) apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3568
          done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3569
        then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3570
          unfolding real_0_le_add_iff
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3571
          using pos_le_divide_eq[OF True[unfolded neg_0_less_iff_less[symmetric]]]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3572
          by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3573
      qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3574
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3575
    obtain a where "a \<in> s" and "t = (\<lambda>v. (u v) / (- w v)) a" and "w a < 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3576
      using Min_in[OF _ \<open>i\<noteq>{}\<close>] and obt(1) unfolding i_def t_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3577
    then have a: "a \<in> s" "u a + t * w a = 0" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3578
    have *: "\<And>f. sum f (s - {a}) = sum f s - ((f a)::'b::ab_group_add)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3579
      unfolding sum.remove[OF obt(1) \<open>a\<in>s\<close>] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3580
    have "(\<Sum>v\<in>s. u v + t * w v) = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3581
      unfolding sum.distrib wv(1) sum_distrib_left[symmetric] obt(5) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3582
    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"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3583
      unfolding sum.distrib obt(6) scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] wv(4)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3584
      using a(2) [THEN eq_neg_iff_add_eq_0 [THEN iffD2]] by simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3585
    ultimately have "?P (n - 1)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3586
      apply (rule_tac x="(s - {a})" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3587
      apply (rule_tac x="\<lambda>v. u v + t * w v" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3588
      using obt(1-3) and t and a
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3589
      apply (auto simp: * scaleR_left_distrib)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3590
      done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3591
    then show False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3592
      using smallest[THEN spec[where x="n - 1"]] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3593
  qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3594
  then show "\<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> aff_dim p + 1 \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3595
      (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3596
    using obt by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3597
qed auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3598
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3599
lemma caratheodory_aff_dim:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3600
  fixes p :: "('a::euclidean_space) set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3601
  shows "convex hull p = {x. \<exists>s. finite s \<and> s \<subseteq> p \<and> card s \<le> aff_dim p + 1 \<and> x \<in> convex hull s}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3602
        (is "?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3603
proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3604
  show "?lhs \<subseteq> ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3605
    apply (subst convex_hull_caratheodory_aff_dim, clarify)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3606
    apply (rule_tac x=s in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3607
    apply (simp add: hull_subset convex_explicit [THEN iffD1, OF convex_convex_hull])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3608
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3609
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3610
  show "?rhs \<subseteq> ?lhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3611
    using hull_mono by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3612
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3613
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3614
lemma convex_hull_caratheodory:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3615
  fixes p :: "('a::euclidean_space) set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3616
  shows "convex hull p =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3617
            {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3618
              (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) s = y}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3619
        (is "?lhs = ?rhs")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3620
proof (intro set_eqI iffI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3621
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3622
  assume "x \<in> ?lhs" then show "x \<in> ?rhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3623
    apply (simp only: convex_hull_caratheodory_aff_dim Set.mem_Collect_eq)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3624
    apply (erule ex_forward)+
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3625
    using aff_dim_le_DIM [of p]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3626
    apply simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3627
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3628
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3629
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3630
  assume "x \<in> ?rhs" then show "x \<in> ?lhs"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3631
    by (auto simp: convex_hull_explicit)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3632
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3633
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3634
theorem caratheodory:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3635
  "convex hull p =
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3636
    {x::'a::euclidean_space. \<exists>s. finite s \<and> s \<subseteq> p \<and>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3637
      card s \<le> DIM('a) + 1 \<and> x \<in> convex hull s}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3638
proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3639
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3640
  assume "x \<in> convex hull p"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3641
  then obtain s u where "finite s" "s \<subseteq> p" "card s \<le> DIM('a) + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3642
    "\<forall>x\<in>s. 0 \<le> u x" "sum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3643
    unfolding convex_hull_caratheodory by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3644
  then show "\<exists>s. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and> x \<in> convex hull s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3645
    apply (rule_tac x=s in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3646
    using hull_subset[of s convex]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3647
    using convex_convex_hull[simplified convex_explicit, of s,
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3648
      THEN spec[where x=s], THEN spec[where x=u]]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3649
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3650
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3651
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3652
  fix x s
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3653
  assume  "finite s" "s \<subseteq> p" "card s \<le> DIM('a) + 1" "x \<in> convex hull s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3654
  then show "x \<in> convex hull p"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3655
    using hull_mono[OF \<open>s\<subseteq>p\<close>] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3656
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3657
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  3658
subsection\<^marker>\<open>tag unimportant\<close>\<open>Some Properties of subset of standard basis\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3659
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3660
lemma affine_hull_substd_basis:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3661
  assumes "d \<subseteq> Basis"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3662
  shows "affine hull (insert 0 d) = {x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3663
  (is "affine hull (insert 0 ?A) = ?B")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3664
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3665
  have *: "\<And>A. (+) (0::'a) ` A = A" "\<And>A. (+) (- (0::'a)) ` A = A"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3666
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3667
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3668
    unfolding affine_hull_insert_span_gen span_substd_basis[OF assms,symmetric] * ..
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3669
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3670
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3671
lemma affine_hull_convex_hull [simp]: "affine hull (convex hull S) = affine hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3672
  by (metis Int_absorb1 Int_absorb2 convex_hull_subset_affine_hull hull_hull hull_mono hull_subset)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3673
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3674
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  3675
subsection\<^marker>\<open>tag unimportant\<close> \<open>Moving and scaling convex hulls\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3676
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3677
lemma convex_hull_set_plus:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3678
  "convex hull (S + T) = convex hull S + convex hull T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3679
  unfolding set_plus_image
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3680
  apply (subst convex_hull_linear_image [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3681
  apply (simp add: linear_iff scaleR_right_distrib)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3682
  apply (simp add: convex_hull_Times)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3683
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3684
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3685
lemma translation_eq_singleton_plus: "(\<lambda>x. a + x) ` T = {a} + T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3686
  unfolding set_plus_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3687
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3688
lemma convex_hull_translation:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3689
  "convex hull ((\<lambda>x. a + x) ` S) = (\<lambda>x. a + x) ` (convex hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3690
  unfolding translation_eq_singleton_plus
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3691
  by (simp only: convex_hull_set_plus convex_hull_singleton)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3692
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3693
lemma convex_hull_scaling:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3694
  "convex hull ((\<lambda>x. c *\<^sub>R x) ` S) = (\<lambda>x. c *\<^sub>R x) ` (convex hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3695
  using linear_scaleR by (rule convex_hull_linear_image [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3696
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3697
lemma convex_hull_affinity:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3698
  "convex hull ((\<lambda>x. a + c *\<^sub>R x) ` S) = (\<lambda>x. a + c *\<^sub>R x) ` (convex hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3699
  by(simp only: image_image[symmetric] convex_hull_scaling convex_hull_translation)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3700
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3701
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  3702
subsection\<^marker>\<open>tag unimportant\<close> \<open>Convexity of cone hulls\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3703
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3704
lemma convex_cone_hull:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3705
  assumes "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3706
  shows "convex (cone hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3707
proof (rule convexI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3708
  fix x y
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3709
  assume xy: "x \<in> cone hull S" "y \<in> cone hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3710
  then have "S \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3711
    using cone_hull_empty_iff[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3712
  fix u v :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3713
  assume uv: "u \<ge> 0" "v \<ge> 0" "u + v = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3714
  then have *: "u *\<^sub>R x \<in> cone hull S" "v *\<^sub>R y \<in> cone hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3715
    using cone_cone_hull[of S] xy cone_def[of "cone hull S"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3716
  from * obtain cx :: real and xx where x: "u *\<^sub>R x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3717
    using cone_hull_expl[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3718
  from * obtain cy :: real and yy where y: "v *\<^sub>R y = cy *\<^sub>R yy" "cy \<ge> 0" "yy \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3719
    using cone_hull_expl[of S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3720
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3721
    assume "cx + cy \<le> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3722
    then have "u *\<^sub>R x = 0" and "v *\<^sub>R y = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3723
      using x y by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3724
    then have "u *\<^sub>R x + v *\<^sub>R y = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3725
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3726
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3727
      using cone_hull_contains_0[of S] \<open>S \<noteq> {}\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3728
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3729
  moreover
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3730
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3731
    assume "cx + cy > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3732
    then have "(cx / (cx + cy)) *\<^sub>R xx + (cy / (cx + cy)) *\<^sub>R yy \<in> S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3733
      using assms mem_convex_alt[of S xx yy cx cy] x y by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3734
    then have "cx *\<^sub>R xx + cy *\<^sub>R yy \<in> cone hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3735
      using mem_cone_hull[of "(cx/(cx+cy)) *\<^sub>R xx + (cy/(cx+cy)) *\<^sub>R yy" S "cx+cy"] \<open>cx+cy>0\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3736
      by (auto simp: scaleR_right_distrib)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3737
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3738
      using x y by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3739
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3740
  moreover have "cx + cy \<le> 0 \<or> cx + cy > 0" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3741
  ultimately show "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S" by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3742
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3743
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3744
lemma cone_convex_hull:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3745
  assumes "cone S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3746
  shows "cone (convex hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3747
proof (cases "S = {}")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3748
  case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3749
  then show ?thesis by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3750
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3751
  case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3752
  then have *: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (*\<^sub>R) c ` S = S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3753
    using cone_iff[of S] assms by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3754
  {
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3755
    fix c :: real
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3756
    assume "c > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3757
    then have "(*\<^sub>R) c ` (convex hull S) = convex hull ((*\<^sub>R) c ` S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3758
      using convex_hull_scaling[of _ S] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3759
    also have "\<dots> = convex hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3760
      using * \<open>c > 0\<close> by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3761
    finally have "(*\<^sub>R) c ` (convex hull S) = convex hull S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3762
      by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3763
  }
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3764
  then have "0 \<in> convex hull S" "\<And>c. c > 0 \<Longrightarrow> ((*\<^sub>R) c ` (convex hull S)) = (convex hull S)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3765
    using * hull_subset[of S convex] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3766
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3767
    using \<open>S \<noteq> {}\<close> cone_iff[of "convex hull S"] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3768
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3769
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3770
subsection \<open>Radon's theorem\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3771
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3772
text "Formalized by Lars Schewe."
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3773
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3774
lemma Radon_ex_lemma:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3775
  assumes "finite c" "affine_dependent c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3776
  shows "\<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) c = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3777
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3778
  from assms(2)[unfolded affine_dependent_explicit]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3779
  obtain s u where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3780
      "finite s" "s \<subseteq> c" "sum u s = 0" "\<exists>v\<in>s. u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3781
    by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3782
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3783
    apply (rule_tac x="\<lambda>v. if v\<in>s then u v else 0" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3784
    unfolding if_smult scaleR_zero_left and sum.inter_restrict[OF assms(1), symmetric]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3785
    apply (auto simp: Int_absorb1)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3786
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3787
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3788
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3789
lemma Radon_s_lemma:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3790
  assumes "finite s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3791
    and "sum f s = (0::real)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3792
  shows "sum f {x\<in>s. 0 < f x} = - sum f {x\<in>s. f x < 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3793
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3794
  have *: "\<And>x. (if f x < 0 then f x else 0) + (if 0 < f x then f x else 0) = f x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3795
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3796
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3797
    unfolding add_eq_0_iff[symmetric] and sum.inter_filter[OF assms(1)]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3798
      and sum.distrib[symmetric] and *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3799
    using assms(2)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3800
    by assumption
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3801
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3802
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3803
lemma Radon_v_lemma:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3804
  assumes "finite s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3805
    and "sum f s = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3806
    and "\<forall>x. g x = (0::real) \<longrightarrow> f x = (0::'a::euclidean_space)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3807
  shows "(sum f {x\<in>s. 0 < g x}) = - sum f {x\<in>s. g x < 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3808
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3809
  have *: "\<And>x. (if 0 < g x then f x else 0) + (if g x < 0 then f x else 0) = f x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3810
    using assms(3) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3811
  show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3812
    unfolding eq_neg_iff_add_eq_0 and sum.inter_filter[OF assms(1)]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3813
      and sum.distrib[symmetric] and *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3814
    using assms(2)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3815
    apply assumption
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3816
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3817
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3818
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3819
lemma Radon_partition:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3820
  assumes "finite c" "affine_dependent c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3821
  shows "\<exists>m p. m \<inter> p = {} \<and> m \<union> p = c \<and> (convex hull m) \<inter> (convex hull p) \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3822
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3823
  obtain u v where uv: "sum u c = 0" "v\<in>c" "u v \<noteq> 0"  "(\<Sum>v\<in>c. u v *\<^sub>R v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3824
    using Radon_ex_lemma[OF assms] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3825
  have fin: "finite {x \<in> c. 0 < u x}" "finite {x \<in> c. 0 > u x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3826
    using assms(1) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3827
  define z  where "z = inverse (sum u {x\<in>c. u x > 0}) *\<^sub>R sum (\<lambda>x. u x *\<^sub>R x) {x\<in>c. u x > 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3828
  have "sum u {x \<in> c. 0 < u x} \<noteq> 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3829
  proof (cases "u v \<ge> 0")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3830
    case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3831
    then have "u v < 0" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3832
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3833
    proof (cases "\<exists>w\<in>{x \<in> c. 0 < u x}. u w > 0")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3834
      case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3835
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3836
        using sum_nonneg_eq_0_iff[of _ u, OF fin(1)] by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3837
    next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3838
      case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3839
      then have "sum u c \<le> sum (\<lambda>x. if x=v then u v else 0) c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3840
        apply (rule_tac sum_mono, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3841
        done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3842
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3843
        unfolding sum.delta[OF assms(1)] using uv(2) and \<open>u v < 0\<close> and uv(1) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3844
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3845
  qed (insert sum_nonneg_eq_0_iff[of _ u, OF fin(1)] uv(2-3), auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3846
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3847
  then have *: "sum u {x\<in>c. u x > 0} > 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3848
    unfolding less_le
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3849
    apply (rule_tac conjI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3850
    apply (rule_tac sum_nonneg, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3851
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3852
  moreover have "sum u ({x \<in> c. 0 < u x} \<union> {x \<in> c. u x < 0}) = sum u c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3853
    "(\<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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3854
    using assms(1)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3855
    apply (rule_tac[!] sum.mono_neutral_left, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3856
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3857
  then have "sum u {x \<in> c. 0 < u x} = - sum u {x \<in> c. 0 > u x}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3858
    "(\<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)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3859
    unfolding eq_neg_iff_add_eq_0
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3860
    using uv(1,4)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3861
    by (auto simp: sum.union_inter_neutral[OF fin, symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3862
  moreover have "\<forall>x\<in>{v \<in> c. u v < 0}. 0 \<le> inverse (sum u {x \<in> c. 0 < u x}) * - u x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3863
    apply rule
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3864
    apply (rule mult_nonneg_nonneg)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3865
    using *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3866
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3867
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3868
  ultimately have "z \<in> convex hull {v \<in> c. u v \<le> 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3869
    unfolding convex_hull_explicit mem_Collect_eq
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3870
    apply (rule_tac x="{v \<in> c. u v < 0}" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3871
    apply (rule_tac x="\<lambda>y. inverse (sum u {x\<in>c. u x > 0}) * - u y" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3872
    using assms(1) unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] and z_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3873
    apply (auto simp: sum_negf sum_distrib_left[symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3874
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3875
  moreover have "\<forall>x\<in>{v \<in> c. 0 < u v}. 0 \<le> inverse (sum u {x \<in> c. 0 < u x}) * u x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3876
    apply rule
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3877
    apply (rule mult_nonneg_nonneg)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3878
    using *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3879
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3880
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3881
  then have "z \<in> convex hull {v \<in> c. u v > 0}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3882
    unfolding convex_hull_explicit mem_Collect_eq
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3883
    apply (rule_tac x="{v \<in> c. 0 < u v}" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3884
    apply (rule_tac x="\<lambda>y. inverse (sum u {x\<in>c. u x > 0}) * u y" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3885
    using assms(1)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3886
    unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] and z_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3887
    using *
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3888
    apply (auto simp: sum_negf sum_distrib_left[symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3889
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3890
  ultimately show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3891
    apply (rule_tac x="{v\<in>c. u v \<le> 0}" in exI)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3892
    apply (rule_tac x="{v\<in>c. u v > 0}" in exI, auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3893
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3894
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3895
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3896
theorem Radon:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3897
  assumes "affine_dependent c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3898
  obtains m p where "m \<subseteq> c" "p \<subseteq> c" "m \<inter> p = {}" "(convex hull m) \<inter> (convex hull p) \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3899
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3900
  from assms[unfolded affine_dependent_explicit]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3901
  obtain s u where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3902
      "finite s" "s \<subseteq> c" "sum u s = 0" "\<exists>v\<in>s. u v \<noteq> 0" "(\<Sum>v\<in>s. u v *\<^sub>R v) = 0"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3903
    by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3904
  then have *: "finite s" "affine_dependent s" and s: "s \<subseteq> c"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3905
    unfolding affine_dependent_explicit by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3906
  from Radon_partition[OF *]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3907
  obtain m p where "m \<inter> p = {}" "m \<union> p = s" "convex hull m \<inter> convex hull p \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3908
    by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3909
  then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3910
    apply (rule_tac that[of p m])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3911
    using s
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3912
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3913
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3914
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3915
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3916
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3917
subsection \<open>Helly's theorem\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3918
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3919
lemma Helly_induct:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3920
  fixes f :: "'a::euclidean_space set set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3921
  assumes "card f = n"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3922
    and "n \<ge> DIM('a) + 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3923
    and "\<forall>s\<in>f. convex s" "\<forall>t\<subseteq>f. card t = DIM('a) + 1 \<longrightarrow> \<Inter>t \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3924
  shows "\<Inter>f \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3925
  using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3926
proof (induction n arbitrary: f)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3927
  case 0
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3928
  then show ?case by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3929
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3930
  case (Suc n)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3931
  have "finite f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3932
    using \<open>card f = Suc n\<close> by (auto intro: card_ge_0_finite)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3933
  show "\<Inter>f \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3934
  proof (cases "n = DIM('a)")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3935
    case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3936
    then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3937
      by (simp add: Suc.prems(1) Suc.prems(4))
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3938
  next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3939
    case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3940
    have "\<Inter>(f - {s}) \<noteq> {}" if "s \<in> f" for s
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3941
    proof (rule Suc.IH[rule_format])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3942
      show "card (f - {s}) = n"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3943
        by (simp add: Suc.prems(1) \<open>finite f\<close> that)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3944
      show "DIM('a) + 1 \<le> n"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3945
        using False Suc.prems(2) by linarith
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3946
      show "\<And>t. \<lbrakk>t \<subseteq> f - {s}; card t = DIM('a) + 1\<rbrakk> \<Longrightarrow> \<Inter>t \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3947
        by (simp add: Suc.prems(4) subset_Diff_insert)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3948
    qed (use Suc in auto)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3949
    then have "\<forall>s\<in>f. \<exists>x. x \<in> \<Inter>(f - {s})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3950
      by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3951
    then obtain X where X: "\<And>s. s\<in>f \<Longrightarrow> X s \<in> \<Inter>(f - {s})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3952
      by metis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3953
    show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3954
    proof (cases "inj_on X f")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3955
      case False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3956
      then obtain s t where "s\<noteq>t" and st: "s\<in>f" "t\<in>f" "X s = X t"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3957
        unfolding inj_on_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3958
      then have *: "\<Inter>f = \<Inter>(f - {s}) \<inter> \<Inter>(f - {t})" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3959
      show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3960
        by (metis "*" X disjoint_iff_not_equal st)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3961
    next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3962
      case True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3963
      then obtain m p where mp: "m \<inter> p = {}" "m \<union> p = X ` f" "convex hull m \<inter> convex hull p \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3964
        using Radon_partition[of "X ` f"] and affine_dependent_biggerset[of "X ` f"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3965
        unfolding card_image[OF True] and \<open>card f = Suc n\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3966
        using Suc(3) \<open>finite f\<close> and False
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3967
        by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3968
      have "m \<subseteq> X ` f" "p \<subseteq> X ` f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3969
        using mp(2) by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3970
      then obtain g h where gh:"m = X ` g" "p = X ` h" "g \<subseteq> f" "h \<subseteq> f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3971
        unfolding subset_image_iff by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3972
      then have "f \<union> (g \<union> h) = f" by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3973
      then have f: "f = g \<union> h"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3974
        using inj_on_Un_image_eq_iff[of X f "g \<union> h"] and True
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3975
        unfolding mp(2)[unfolded image_Un[symmetric] gh]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3976
        by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3977
      have *: "g \<inter> h = {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3978
        using mp(1)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3979
        unfolding gh
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3980
        using inj_on_image_Int[OF True gh(3,4)]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3981
        by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3982
      have "convex hull (X ` h) \<subseteq> \<Inter>g" "convex hull (X ` g) \<subseteq> \<Inter>h"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3983
        by (rule hull_minimal; use X * f in \<open>auto simp: Suc.prems(3) convex_Inter\<close>)+
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3984
      then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3985
        unfolding f using mp(3)[unfolded gh] by blast
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3986
    qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3987
  qed 
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3988
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3989
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3990
theorem Helly:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3991
  fixes f :: "'a::euclidean_space set set"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3992
  assumes "card f \<ge> DIM('a) + 1" "\<forall>s\<in>f. convex s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3993
    and "\<And>t. \<lbrakk>t\<subseteq>f; card t = DIM('a) + 1\<rbrakk> \<Longrightarrow> \<Inter>t \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3994
  shows "\<Inter>f \<noteq> {}"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3995
  apply (rule Helly_induct)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3996
  using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3997
  apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3998
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  3999
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4000
subsection \<open>Epigraphs of convex functions\<close>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4001
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  4002
definition\<^marker>\<open>tag important\<close> "epigraph S (f :: _ \<Rightarrow> real) = {xy. fst xy \<in> S \<and> f (fst xy) \<le> snd xy}"
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4003
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4004
lemma mem_epigraph: "(x, y) \<in> epigraph S f \<longleftrightarrow> x \<in> S \<and> f x \<le> y"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4005
  unfolding epigraph_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4006
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4007
lemma convex_epigraph: "convex (epigraph S f) \<longleftrightarrow> convex_on S f \<and> convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4008
proof safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4009
  assume L: "convex (epigraph S f)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4010
  then show "convex_on S f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4011
    by (auto simp: convex_def convex_on_def epigraph_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4012
  show "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4013
    using L
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4014
    apply (clarsimp simp: convex_def convex_on_def epigraph_def)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4015
    apply (erule_tac x=x in allE)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4016
    apply (erule_tac x="f x" in allE, safe)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4017
    apply (erule_tac x=y in allE)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4018
    apply (erule_tac x="f y" in allE)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4019
    apply (auto simp: )
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4020
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4021
next
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4022
  assume "convex_on S f" "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4023
  then show "convex (epigraph S f)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4024
    unfolding convex_def convex_on_def epigraph_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4025
    apply safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4026
     apply (rule_tac [2] y="u * f a + v * f aa" in order_trans)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4027
      apply (auto intro!:mult_left_mono add_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4028
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4029
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4030
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4031
lemma convex_epigraphI: "convex_on S f \<Longrightarrow> convex S \<Longrightarrow> convex (epigraph S f)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4032
  unfolding convex_epigraph by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4033
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4034
lemma convex_epigraph_convex: "convex S \<Longrightarrow> convex_on S f \<longleftrightarrow> convex(epigraph S f)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4035
  by (simp add: convex_epigraph)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4036
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4037
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  4038
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Use this to derive general bound property of convex function\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4039
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4040
lemma convex_on:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4041
  assumes "convex S"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4042
  shows "convex_on S f \<longleftrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4043
    (\<forall>k u x. (\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> x i \<in> S) \<and> sum u {1..k} = 1 \<longrightarrow>
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4044
      f (sum (\<lambda>i. u i *\<^sub>R x i) {1..k}) \<le> sum (\<lambda>i. u i * f(x i)) {1..k})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4045
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4046
  unfolding convex_epigraph_convex[OF assms] convex epigraph_def Ball_def mem_Collect_eq
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4047
  unfolding fst_sum snd_sum fst_scaleR snd_scaleR
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4048
  apply safe
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4049
    apply (drule_tac x=k in spec)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4050
    apply (drule_tac x=u in spec)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4051
    apply (drule_tac x="\<lambda>i. (x i, f (x i))" in spec)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4052
    apply simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4053
  using assms[unfolded convex] apply simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4054
  apply (rule_tac y="\<Sum>i = 1..k. u i * f (fst (x i))" in order_trans, force)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4055
   apply (rule sum_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4056
   apply (erule_tac x=i in allE)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4057
  unfolding real_scaleR_def
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4058
   apply (rule mult_left_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4059
  using assms[unfolded convex] apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4060
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4061
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 70097
diff changeset
  4062
subsection\<^marker>\<open>tag unimportant\<close> \<open>A bound within a convex hull\<close>
69619
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4063
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4064
lemma convex_on_convex_hull_bound:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4065
  assumes "convex_on (convex hull s) f"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4066
    and "\<forall>x\<in>s. f x \<le> b"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4067
  shows "\<forall>x\<in> convex hull s. f x \<le> b"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4068
proof
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4069
  fix x
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4070
  assume "x \<in> convex hull s"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4071
  then obtain k u v where
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4072
    obt: "\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> v i \<in> s" "sum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R v i) = x"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4073
    unfolding convex_hull_indexed mem_Collect_eq by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4074
  have "(\<Sum>i = 1..k. u i * f (v i)) \<le> b"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4075
    using sum_mono[of "{1..k}" "\<lambda>i. u i * f (v i)" "\<lambda>i. u i * b"]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4076
    unfolding sum_distrib_right[symmetric] obt(2) mult_1
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4077
    apply (drule_tac meta_mp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4078
    apply (rule mult_left_mono)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4079
    using assms(2) obt(1)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4080
    apply auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4081
    done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4082
  then show "f x \<le> b"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4083
    using assms(1)[unfolded convex_on[OF convex_convex_hull], rule_format, of k u v]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4084
    unfolding obt(2-3)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4085
    using obt(1) and hull_subset[unfolded subset_eq, rule_format, of _ s]
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4086
    by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4087
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4088
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4089
lemma inner_sum_Basis[simp]: "i \<in> Basis \<Longrightarrow> (\<Sum>Basis) \<bullet> i = 1"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4090
  by (simp add: inner_sum_left sum.If_cases inner_Basis)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4091
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4092
lemma convex_set_plus:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4093
  assumes "convex S" and "convex T" shows "convex (S + T)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4094
proof -
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4095
  have "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4096
    using assms by (rule convex_sums)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4097
  moreover have "(\<Union>x\<in> S. \<Union>y \<in> T. {x + y}) = S + T"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4098
    unfolding set_plus_def by auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4099
  finally show "convex (S + T)" .
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4100
qed
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4101
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4102
lemma convex_set_sum:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4103
  assumes "\<And>i. i \<in> A \<Longrightarrow> convex (B i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4104
  shows "convex (\<Sum>i\<in>A. B i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4105
proof (cases "finite A")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4106
  case True then show ?thesis using assms
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4107
    by induct (auto simp: convex_set_plus)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4108
qed auto
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4109
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4110
lemma finite_set_sum:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4111
  assumes "finite A" and "\<forall>i\<in>A. finite (B i)" shows "finite (\<Sum>i\<in>A. B i)"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4112
  using assms by (induct set: finite, simp, simp add: finite_set_plus)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4113
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4114
lemma box_eq_set_sum_Basis:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4115
  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))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4116
  apply (subst set_sum_alt [OF finite_Basis], safe)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4117
  apply (fast intro: euclidean_representation [symmetric])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4118
  apply (subst inner_sum_left)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4119
apply (rename_tac f)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4120
  apply (subgoal_tac "(\<Sum>x\<in>Basis. f x \<bullet> i) = f i \<bullet> i")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4121
  apply (drule (1) bspec)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4122
  apply clarsimp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4123
  apply (frule sum.remove [OF finite_Basis])
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4124
  apply (erule trans, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4125
  apply (rule sum.neutral, clarsimp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4126
  apply (frule_tac x=i in bspec, assumption)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4127
  apply (drule_tac x=x in bspec, assumption, clarsimp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4128
  apply (cut_tac u=x and v=i in inner_Basis, assumption+)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4129
  apply (rule ccontr, simp)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4130
  done
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4131
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4132
lemma convex_hull_set_sum:
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4133
  "convex hull (\<Sum>i\<in>A. B i) = (\<Sum>i\<in>A. convex hull (B i))"
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4134
proof (cases "finite A")
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4135
  assume "finite A" then show ?thesis
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4136
    by (induct set: finite, simp, simp add: convex_hull_set_plus)
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4137
qed simp
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4138
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4139
3f7d8e05e0f2 split off Convex.thy: material that does not require Topology_Euclidean_Space
immler
parents:
diff changeset
  4140
end