src/HOL/Analysis/Convex_Euclidean_Space.thy
author paulson <lp15@cam.ac.uk>
Thu, 10 May 2018 15:41:34 +0100
changeset 68136 f022083489d0
parent 68074 8d50467f7555
child 68527 2f4e2aab190a
permissions -rw-r--r--
more on infinite products
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
     1
(* Title:      HOL/Analysis/Convex_Euclidean_Space.thy
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
     2
   Author:     L C Paulson, University of Cambridge
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
     3
   Author:     Robert Himmelmann, TU Muenchen
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
     4
   Author:     Bogdan Grechuk, University of Edinburgh
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
     5
   Author:     Armin Heller, TU Muenchen
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
     6
   Author:     Johannes Hoelzl, TU Muenchen
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     7
*)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     8
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
     9
section \<open>Convex sets, functions and related things\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    10
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    11
theory Convex_Euclidean_Space
44132
0f35a870ecf1 full import paths
huffman
parents: 44125
diff changeset
    12
imports
66827
c94531b5007d Divided Topology_Euclidean_Space in two, creating new theory Connected. Also deleted some duplicate / variant theorems
paulson <lp15@cam.ac.uk>
parents: 66793
diff changeset
    13
  Connected
66453
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 66289
diff changeset
    14
  "HOL-Library.Set_Algebras"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    15
begin
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    16
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    17
lemma swap_continuous: (*move to Topological_Spaces?*)
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    18
  assumes "continuous_on (cbox (a,c) (b,d)) (\<lambda>(x,y). f x y)"
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    19
    shows "continuous_on (cbox (c,a) (d,b)) (\<lambda>(x, y). f y x)"
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    20
proof -
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    21
  have "(\<lambda>(x, y). f y x) = (\<lambda>(x, y). f x y) \<circ> prod.swap"
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    22
    by auto
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    23
  then show ?thesis
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    24
    apply (rule ssubst)
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    25
    apply (rule continuous_on_compose)
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    26
    apply (simp add: split_def)
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    27
    apply (rule continuous_intros | simp add: assms)+
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    28
    done
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    29
qed
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
    30
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    31
lemma substdbasis_expansion_unique:
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
    32
  assumes d: "d \<subseteq> Basis"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    33
  shows "(\<Sum>i\<in>d. f i *\<^sub>R i) = (x::'a::euclidean_space) \<longleftrightarrow>
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    34
    (\<forall>i\<in>Basis. (i \<in> d \<longrightarrow> f i = x \<bullet> i) \<and> (i \<notin> d \<longrightarrow> x \<bullet> i = 0))"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    35
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    36
  have *: "\<And>x a b P. x * (if P then a else b) = (if P then x * a else x * b)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    37
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    38
  have **: "finite d"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    39
    by (auto intro: finite_subset[OF assms])
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
    40
  have ***: "\<And>i. i \<in> Basis \<Longrightarrow> (\<Sum>i\<in>d. f i *\<^sub>R i) \<bullet> i = (\<Sum>x\<in>d. if x = i then f x else 0)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
    41
    using d
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
    42
    by (auto intro!: sum.cong simp: inner_Basis inner_sum_left)
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
    43
  show ?thesis
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
    44
    unfolding euclidean_eq_iff[where 'a='a] by (auto simp: sum.delta[OF **] ***)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
    45
qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
    46
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
    47
lemma independent_substdbasis: "d \<subseteq> Basis \<Longrightarrow> independent d"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
    48
  by (rule independent_mono[OF independent_Basis])
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    49
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
    50
lemma dim_cball:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    51
  assumes "e > 0"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    52
  shows "dim (cball (0 :: 'n::euclidean_space) e) = DIM('n)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    53
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    54
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    55
    fix x :: "'n::euclidean_space"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
    56
    define y where "y = (e / norm x) *\<^sub>R x"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    57
    then have "y \<in> cball 0 e"
62397
5ae24f33d343 Substantial new material for multivariate analysis. Also removal of some duplicates.
paulson <lp15@cam.ac.uk>
parents: 62381
diff changeset
    58
      using assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    59
    moreover have *: "x = (norm x / e) *\<^sub>R y"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    60
      using y_def assms by simp
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    61
    moreover from * have "x = (norm x/e) *\<^sub>R y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    62
      by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    63
    ultimately have "x \<in> span (cball 0 e)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
    64
      using span_scale[of y "cball 0 e" "norm x/e"]
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
    65
        span_superset[of "cball 0 e"]
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
    66
      by (simp add: span_base)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    67
  }
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    68
  then have "span (cball 0 e) = (UNIV :: 'n::euclidean_space set)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
    69
    by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    70
  then show ?thesis
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
    71
    using dim_span[of "cball (0 :: 'n::euclidean_space) e"] by (auto simp: dim_UNIV)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    72
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    73
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
    74
lemma sum_not_0: "sum f A \<noteq> 0 \<Longrightarrow> \<exists>a \<in> A. f a \<noteq> 0"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    75
  by (rule ccontr) auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    76
61694
6571c78c9667 Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
    77
lemma subset_translation_eq [simp]:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
    78
    fixes a :: "'a::real_vector" shows "(+) a ` s \<subseteq> (+) a ` t \<longleftrightarrow> s \<subseteq> t"
61694
6571c78c9667 Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
    79
  by auto
6571c78c9667 Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
    80
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
    81
lemma translate_inj_on:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    82
  fixes A :: "'a::ab_group_add set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    83
  shows "inj_on (\<lambda>x. a + x) A"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    84
  unfolding inj_on_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    85
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    86
lemma translation_assoc:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    87
  fixes a b :: "'a::ab_group_add"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    88
  shows "(\<lambda>x. b + x) ` ((\<lambda>x. a + x) ` S) = (\<lambda>x. (a + b) + x) ` S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    89
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    90
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    91
lemma translation_invert:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
    92
  fixes a :: "'a::ab_group_add"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    93
  assumes "(\<lambda>x. a + x) ` A = (\<lambda>x. a + x) ` B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    94
  shows "A = B"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    95
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
    96
  have "(\<lambda>x. -a + x) ` ((\<lambda>x. a + x) ` A) = (\<lambda>x. - a + x) ` ((\<lambda>x. a + x) ` B)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    97
    using assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    98
  then show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
    99
    using translation_assoc[of "-a" a A] translation_assoc[of "-a" a B] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   100
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   101
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   102
lemma translation_galois:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   103
  fixes a :: "'a::ab_group_add"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   104
  shows "T = ((\<lambda>x. a + x) ` S) \<longleftrightarrow> S = ((\<lambda>x. (- a) + x) ` T)"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   105
  using translation_assoc[of "-a" a S]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   106
  apply auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   107
  using translation_assoc[of a "-a" T]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   108
  apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   109
  done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   110
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   111
lemma translation_inverse_subset:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   112
  assumes "((\<lambda>x. - a + x) ` V) \<le> (S :: 'n::ab_group_add set)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
   113
  shows "V \<le> ((\<lambda>x. a + x) ` S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   114
proof -
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   115
  {
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   116
    fix x
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   117
    assume "x \<in> V"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   118
    then have "x-a \<in> S" using assms by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   119
    then have "x \<in> {a + v |v. v \<in> S}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   120
      apply auto
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
   121
      apply (rule exI[of _ "x-a"], simp)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
   122
      done
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   123
    then have "x \<in> ((\<lambda>x. a+x) ` S)" by auto
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   124
  }
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
   125
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   126
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
   127
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   128
subsection \<open>Convexity\<close>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   129
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   130
definition%important convex :: "'a::real_vector set \<Rightarrow> bool"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   131
  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)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   132
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   133
lemma convexI:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   134
  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"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   135
  shows "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   136
  using assms unfolding convex_def by fast
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   137
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   138
lemma convexD:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   139
  assumes "convex s" and "x \<in> s" and "y \<in> s" and "0 \<le> u" and "0 \<le> v" and "u + v = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   140
  shows "u *\<^sub>R x + v *\<^sub>R y \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   141
  using assms unfolding convex_def by fast
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   142
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   143
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)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   144
  (is "_ \<longleftrightarrow> ?alt")
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   145
proof
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   146
  show "convex s" if alt: ?alt
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   147
  proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   148
    {
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   149
      fix x y and u v :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   150
      assume mem: "x \<in> s" "y \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   151
      assume "0 \<le> u" "0 \<le> v"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   152
      moreover
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   153
      assume "u + v = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   154
      then have "u = 1 - v" by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   155
      ultimately have "u *\<^sub>R x + v *\<^sub>R y \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   156
        using alt [rule_format, OF mem] by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   157
    }
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   158
    then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   159
      unfolding convex_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   160
  qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   161
  show ?alt if "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   162
    using that by (auto simp: convex_def)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   163
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   164
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   165
lemma convexD_alt:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   166
  assumes "convex s" "a \<in> s" "b \<in> s" "0 \<le> u" "u \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   167
  shows "((1 - u) *\<^sub>R a + u *\<^sub>R b) \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   168
  using assms unfolding convex_alt by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   169
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   170
lemma mem_convex_alt:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   171
  assumes "convex S" "x \<in> S" "y \<in> S" "u \<ge> 0" "v \<ge> 0" "u + v > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   172
  shows "((u/(u+v)) *\<^sub>R x + (v/(u+v)) *\<^sub>R y) \<in> S"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   173
  apply (rule convexD)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   174
  using assms
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   175
       apply (simp_all add: zero_le_divide_iff add_divide_distrib [symmetric])
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   176
  done
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   177
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   178
lemma convex_empty[intro,simp]: "convex {}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   179
  unfolding convex_def by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   180
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   181
lemma convex_singleton[intro,simp]: "convex {a}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   182
  unfolding convex_def by (auto simp: scaleR_left_distrib[symmetric])
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   183
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   184
lemma convex_UNIV[intro,simp]: "convex UNIV"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   185
  unfolding convex_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   186
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   187
lemma convex_Inter: "(\<And>s. s\<in>f \<Longrightarrow> convex s) \<Longrightarrow> convex(\<Inter>f)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   188
  unfolding convex_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   189
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   190
lemma convex_Int: "convex s \<Longrightarrow> convex t \<Longrightarrow> convex (s \<inter> t)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   191
  unfolding convex_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   192
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   193
lemma convex_INT: "(\<And>i. i \<in> A \<Longrightarrow> convex (B i)) \<Longrightarrow> convex (\<Inter>i\<in>A. B i)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   194
  unfolding convex_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   195
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   196
lemma convex_Times: "convex s \<Longrightarrow> convex t \<Longrightarrow> convex (s \<times> t)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   197
  unfolding convex_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   198
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   199
lemma convex_halfspace_le: "convex {x. inner a x \<le> b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   200
  unfolding convex_def
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   201
  by (auto simp: inner_add intro!: convex_bound_le)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   202
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   203
lemma convex_halfspace_ge: "convex {x. inner a x \<ge> b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   204
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   205
  have *: "{x. inner a x \<ge> b} = {x. inner (-a) x \<le> -b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   206
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   207
  show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   208
    unfolding * using convex_halfspace_le[of "-a" "-b"] by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   209
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   210
65583
8d53b3bebab4 Further new material. The simprule status of some exp and ln identities was reverted.
paulson <lp15@cam.ac.uk>
parents: 65057
diff changeset
   211
lemma convex_halfspace_abs_le: "convex {x. \<bar>inner a x\<bar> \<le> b}"
8d53b3bebab4 Further new material. The simprule status of some exp and ln identities was reverted.
paulson <lp15@cam.ac.uk>
parents: 65057
diff changeset
   212
proof -
8d53b3bebab4 Further new material. The simprule status of some exp and ln identities was reverted.
paulson <lp15@cam.ac.uk>
parents: 65057
diff changeset
   213
  have *: "{x. \<bar>inner a x\<bar> \<le> b} = {x. inner a x \<le> b} \<inter> {x. -b \<le> inner a x}"
8d53b3bebab4 Further new material. The simprule status of some exp and ln identities was reverted.
paulson <lp15@cam.ac.uk>
parents: 65057
diff changeset
   214
    by auto
8d53b3bebab4 Further new material. The simprule status of some exp and ln identities was reverted.
paulson <lp15@cam.ac.uk>
parents: 65057
diff changeset
   215
  show ?thesis
8d53b3bebab4 Further new material. The simprule status of some exp and ln identities was reverted.
paulson <lp15@cam.ac.uk>
parents: 65057
diff changeset
   216
    unfolding * by (simp add: convex_Int convex_halfspace_ge convex_halfspace_le)
8d53b3bebab4 Further new material. The simprule status of some exp and ln identities was reverted.
paulson <lp15@cam.ac.uk>
parents: 65057
diff changeset
   217
qed
8d53b3bebab4 Further new material. The simprule status of some exp and ln identities was reverted.
paulson <lp15@cam.ac.uk>
parents: 65057
diff changeset
   218
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   219
lemma convex_hyperplane: "convex {x. inner a x = b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   220
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   221
  have *: "{x. inner a x = b} = {x. inner a x \<le> b} \<inter> {x. inner a x \<ge> b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   222
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   223
  show ?thesis using convex_halfspace_le convex_halfspace_ge
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   224
    by (auto intro!: convex_Int simp: *)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   225
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   226
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   227
lemma convex_halfspace_lt: "convex {x. inner a x < b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   228
  unfolding convex_def
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   229
  by (auto simp: convex_bound_lt inner_add)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   230
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   231
lemma convex_halfspace_gt: "convex {x. inner a x > b}"
67135
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   232
  using convex_halfspace_lt[of "-a" "-b"] by auto
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   233
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   234
lemma convex_halfspace_Re_ge: "convex {x. Re x \<ge> b}"
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   235
  using convex_halfspace_ge[of b "1::complex"] by simp
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   236
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   237
lemma convex_halfspace_Re_le: "convex {x. Re x \<le> b}"
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   238
  using convex_halfspace_le[of "1::complex" b] by simp
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   239
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   240
lemma convex_halfspace_Im_ge: "convex {x. Im x \<ge> b}"
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   241
  using convex_halfspace_ge[of b \<i>] by simp
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   242
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   243
lemma convex_halfspace_Im_le: "convex {x. Im x \<le> b}"
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   244
  using convex_halfspace_le[of \<i> b] by simp
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   245
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   246
lemma convex_halfspace_Re_gt: "convex {x. Re x > b}"
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   247
  using convex_halfspace_gt[of b "1::complex"] by simp
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   248
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   249
lemma convex_halfspace_Re_lt: "convex {x. Re x < b}"
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   250
  using convex_halfspace_lt[of "1::complex" b] by simp
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   251
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   252
lemma convex_halfspace_Im_gt: "convex {x. Im x > b}"
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   253
  using convex_halfspace_gt[of b \<i>] by simp
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   254
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   255
lemma convex_halfspace_Im_lt: "convex {x. Im x < b}"
1a94352812f4 Moved material from AFP to Analysis/Number_Theory
Manuel Eberl <eberlm@in.tum.de>
parents: 66939
diff changeset
   256
  using convex_halfspace_lt[of \<i> b] by simp
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   257
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   258
lemma convex_real_interval [iff]:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   259
  fixes a b :: "real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   260
  shows "convex {a..}" and "convex {..b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   261
    and "convex {a<..}" and "convex {..<b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   262
    and "convex {a..b}" and "convex {a<..b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   263
    and "convex {a..<b}" and "convex {a<..<b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   264
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   265
  have "{a..} = {x. a \<le> inner 1 x}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   266
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   267
  then show 1: "convex {a..}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   268
    by (simp only: convex_halfspace_ge)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   269
  have "{..b} = {x. inner 1 x \<le> b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   270
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   271
  then show 2: "convex {..b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   272
    by (simp only: convex_halfspace_le)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   273
  have "{a<..} = {x. a < inner 1 x}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   274
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   275
  then show 3: "convex {a<..}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   276
    by (simp only: convex_halfspace_gt)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   277
  have "{..<b} = {x. inner 1 x < b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   278
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   279
  then show 4: "convex {..<b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   280
    by (simp only: convex_halfspace_lt)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   281
  have "{a..b} = {a..} \<inter> {..b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   282
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   283
  then show "convex {a..b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   284
    by (simp only: convex_Int 1 2)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   285
  have "{a<..b} = {a<..} \<inter> {..b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   286
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   287
  then show "convex {a<..b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   288
    by (simp only: convex_Int 3 2)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   289
  have "{a..<b} = {a..} \<inter> {..<b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   290
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   291
  then show "convex {a..<b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   292
    by (simp only: convex_Int 1 4)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   293
  have "{a<..<b} = {a<..} \<inter> {..<b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   294
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   295
  then show "convex {a<..<b}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   296
    by (simp only: convex_Int 3 4)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   297
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   298
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   299
lemma convex_Reals: "convex \<real>"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   300
  by (simp add: convex_def scaleR_conv_of_real)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   301
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   302
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   303
subsection%unimportant \<open>Explicit expressions for convexity in terms of arbitrary sums\<close>
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   304
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   305
lemma convex_sum:
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   306
  fixes C :: "'a::real_vector set"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   307
  assumes "finite s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   308
    and "convex C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   309
    and "(\<Sum> i \<in> s. a i) = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   310
  assumes "\<And>i. i \<in> s \<Longrightarrow> a i \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   311
    and "\<And>i. i \<in> s \<Longrightarrow> y i \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   312
  shows "(\<Sum> j \<in> s. a j *\<^sub>R y j) \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   313
  using assms(1,3,4,5)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   314
proof (induct arbitrary: a set: finite)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   315
  case empty
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   316
  then show ?case by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   317
next
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   318
  case (insert i s) note IH = this(3)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   319
  have "a i + sum a s = 1"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   320
    and "0 \<le> a i"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   321
    and "\<forall>j\<in>s. 0 \<le> a j"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   322
    and "y i \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   323
    and "\<forall>j\<in>s. y j \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   324
    using insert.hyps(1,2) insert.prems by simp_all
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   325
  then have "0 \<le> sum a s"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   326
    by (simp add: sum_nonneg)
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   327
  have "a i *\<^sub>R y i + (\<Sum>j\<in>s. a j *\<^sub>R y j) \<in> C"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   328
  proof (cases "sum a s = 0")
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   329
    case True
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   330
    with \<open>a i + sum a s = 1\<close> have "a i = 1"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   331
      by simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   332
    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"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   333
      by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   334
    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>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   335
      by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   336
  next
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   337
    case False
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   338
    with \<open>0 \<le> sum a s\<close> have "0 < sum a s"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   339
      by simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   340
    then have "(\<Sum>j\<in>s. (a j / sum a s) *\<^sub>R y j) \<in> C"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   341
      using \<open>\<forall>j\<in>s. 0 \<le> a j\<close> and \<open>\<forall>j\<in>s. y j \<in> C\<close>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   342
      by (simp add: IH sum_divide_distrib [symmetric])
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   343
    from \<open>convex C\<close> and \<open>y i \<in> C\<close> and this and \<open>0 \<le> a i\<close>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   344
      and \<open>0 \<le> sum a s\<close> and \<open>a i + sum a s = 1\<close>
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   345
    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"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   346
      by (rule convexD)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   347
    then show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   348
      by (simp add: scaleR_sum_right False)
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   349
  qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   350
  then show ?case using \<open>finite s\<close> and \<open>i \<notin> s\<close>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   351
    by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   352
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   353
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   354
lemma convex:
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   355
  "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)
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   356
      \<longrightarrow> sum (\<lambda>i. u i *\<^sub>R x i) {1..k} \<in> s)"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   357
proof safe
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   358
  fix k :: nat
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   359
  fix u :: "nat \<Rightarrow> real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   360
  fix x
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   361
  assume "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   362
    "\<forall>i. 1 \<le> i \<and> i \<le> k \<longrightarrow> 0 \<le> u i \<and> x i \<in> s"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   363
    "sum u {1..k} = 1"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   364
  with convex_sum[of "{1 .. k}" s] show "(\<Sum>j\<in>{1 .. k}. u j *\<^sub>R x j) \<in> s"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   365
    by auto
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   366
next
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   367
  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
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   368
    \<longrightarrow> (\<Sum>i = 1..k. u i *\<^sub>R (x i :: 'a)) \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   369
  {
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   370
    fix \<mu> :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   371
    fix x y :: 'a
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   372
    assume xy: "x \<in> s" "y \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   373
    assume mu: "\<mu> \<ge> 0" "\<mu> \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   374
    let ?u = "\<lambda>i. if (i :: nat) = 1 then \<mu> else 1 - \<mu>"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   375
    let ?x = "\<lambda>i. if (i :: nat) = 1 then x else y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   376
    have "{1 :: nat .. 2} \<inter> - {x. x = 1} = {2}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   377
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   378
    then have card: "card ({1 :: nat .. 2} \<inter> - {x. x = 1}) = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   379
      by simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   380
    then have "sum ?u {1 .. 2} = 1"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   381
      using sum.If_cases[of "{(1 :: nat) .. 2}" "\<lambda> x. x = 1" "\<lambda> x. \<mu>" "\<lambda> x. 1 - \<mu>"]
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   382
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   383
    with *[rule_format, of "2" ?u ?x] have s: "(\<Sum>j \<in> {1..2}. ?u j *\<^sub>R ?x j) \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   384
      using mu xy by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   385
    have grarr: "(\<Sum>j \<in> {Suc (Suc 0)..2}. ?u j *\<^sub>R ?x j) = (1 - \<mu>) *\<^sub>R y"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   386
      using sum_head_Suc[of "Suc (Suc 0)" 2 "\<lambda> j. (1 - \<mu>) *\<^sub>R y"] by auto
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   387
    from sum_head_Suc[of "Suc 0" 2 "\<lambda> j. ?u j *\<^sub>R ?x j", simplified this]
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   388
    have "(\<Sum>j \<in> {1..2}. ?u j *\<^sub>R ?x j) = \<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   389
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   390
    then have "(1 - \<mu>) *\<^sub>R y + \<mu> *\<^sub>R x \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   391
      using s by (auto simp: add.commute)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   392
  }
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   393
  then show "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   394
    unfolding convex_alt by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   395
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   396
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   397
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   398
lemma convex_explicit:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   399
  fixes s :: "'a::real_vector set"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   400
  shows "convex s \<longleftrightarrow>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   401
    (\<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)"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   402
proof safe
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   403
  fix t
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   404
  fix u :: "'a \<Rightarrow> real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   405
  assume "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   406
    and "finite t"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   407
    and "t \<subseteq> s" "\<forall>x\<in>t. 0 \<le> u x" "sum u t = 1"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   408
  then show "(\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   409
    using convex_sum[of t s u "\<lambda> x. x"] by auto
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   410
next
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   411
  assume *: "\<forall>t. \<forall> u. finite t \<and> t \<subseteq> s \<and> (\<forall>x\<in>t. 0 \<le> u x) \<and>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   412
    sum u t = 1 \<longrightarrow> (\<Sum>x\<in>t. u x *\<^sub>R x) \<in> s"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   413
  show "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   414
    unfolding convex_alt
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   415
  proof safe
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   416
    fix x y
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   417
    fix \<mu> :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   418
    assume **: "x \<in> s" "y \<in> s" "0 \<le> \<mu>" "\<mu> \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   419
    show "(1 - \<mu>) *\<^sub>R x + \<mu> *\<^sub>R y \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   420
    proof (cases "x = y")
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   421
      case False
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   422
      then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   423
        using *[rule_format, of "{x, y}" "\<lambda> z. if z = x then 1 - \<mu> else \<mu>"] **
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   424
        by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   425
    next
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   426
      case True
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   427
      then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   428
        using *[rule_format, of "{x, y}" "\<lambda> z. 1"] **
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   429
        by (auto simp: field_simps real_vector.scale_left_diff_distrib)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   430
    qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   431
  qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   432
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   433
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   434
lemma convex_finite:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   435
  assumes "finite s"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   436
  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)"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   437
  unfolding convex_explicit
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   438
  apply safe
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   439
  subgoal for u by (erule allE [where x=s], erule allE [where x=u]) auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   440
  subgoal for t u
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   441
  proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   442
    have if_distrib_arg: "\<And>P f g x. (if P then f else g) x = (if P then f x else g x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   443
      by simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   444
    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"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   445
    assume *: "\<forall>x\<in>t. 0 \<le> u x" "sum u t = 1"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   446
    assume "t \<subseteq> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   447
    then have "s \<inter> t = t" by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   448
    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"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   449
      by (auto simp: assms sum.If_cases if_distrib if_distrib_arg)
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   450
  qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   451
  done
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   452
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   453
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   454
subsection \<open>Functions that are convex on a set\<close>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   455
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   456
definition%important convex_on :: "'a::real_vector set \<Rightarrow> ('a \<Rightarrow> real) \<Rightarrow> bool"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   457
  where "convex_on s f \<longleftrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   458
    (\<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)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   459
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   460
lemma convex_onI [intro?]:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   461
  assumes "\<And>t x y. t > 0 \<Longrightarrow> t < 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   462
    f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   463
  shows "convex_on A f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   464
  unfolding convex_on_def
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   465
proof clarify
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   466
  fix x y
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   467
  fix u v :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   468
  assume A: "x \<in> A" "y \<in> A" "u \<ge> 0" "v \<ge> 0" "u + v = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   469
  from A(5) have [simp]: "v = 1 - u"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   470
    by (simp add: algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   471
  from A(1-4) show "f (u *\<^sub>R x + v *\<^sub>R y) \<le> u * f x + v * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   472
    using assms[of u y x]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   473
    by (cases "u = 0 \<or> u = 1") (auto simp: algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   474
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   475
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   476
lemma convex_on_linorderI [intro?]:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   477
  fixes A :: "('a::{linorder,real_vector}) set"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   478
  assumes "\<And>t x y. t > 0 \<Longrightarrow> t < 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x < y \<Longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   479
    f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   480
  shows "convex_on A f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   481
proof
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   482
  fix x y
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   483
  fix t :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   484
  assume A: "x \<in> A" "y \<in> A" "t > 0" "t < 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   485
  with assms [of t x y] assms [of "1 - t" y x]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   486
  show "f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   487
    by (cases x y rule: linorder_cases) (auto simp: algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   488
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   489
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   490
lemma convex_onD:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   491
  assumes "convex_on A f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   492
  shows "\<And>t x y. t \<ge> 0 \<Longrightarrow> t \<le> 1 \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   493
    f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   494
  using assms by (auto simp: convex_on_def)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   495
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   496
lemma convex_onD_Icc:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   497
  assumes "convex_on {x..y} f" "x \<le> (y :: _ :: {real_vector,preorder})"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   498
  shows "\<And>t. t \<ge> 0 \<Longrightarrow> t \<le> 1 \<Longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   499
    f ((1 - t) *\<^sub>R x + t *\<^sub>R y) \<le> (1 - t) * f x + t * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   500
  using assms(2) by (intro convex_onD [OF assms(1)]) simp_all
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   501
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   502
lemma convex_on_subset: "convex_on t f \<Longrightarrow> s \<subseteq> t \<Longrightarrow> convex_on s f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   503
  unfolding convex_on_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   504
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   505
lemma convex_on_add [intro]:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   506
  assumes "convex_on s f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   507
    and "convex_on s g"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   508
  shows "convex_on s (\<lambda>x. f x + g x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   509
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   510
  {
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   511
    fix x y
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   512
    assume "x \<in> s" "y \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   513
    moreover
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   514
    fix u v :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   515
    assume "0 \<le> u" "0 \<le> v" "u + v = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   516
    ultimately
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   517
    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)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   518
      using assms unfolding convex_on_def by (auto simp: add_mono)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   519
    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)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   520
      by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   521
  }
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   522
  then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   523
    unfolding convex_on_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   524
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   525
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   526
lemma convex_on_cmul [intro]:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   527
  fixes c :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   528
  assumes "0 \<le> c"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   529
    and "convex_on s f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   530
  shows "convex_on s (\<lambda>x. c * f x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   531
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   532
  have *: "u * (c * fx) + v * (c * fy) = c * (u * fx + v * fy)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   533
    for u c fx v fy :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   534
    by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   535
  show ?thesis using assms(2) and mult_left_mono [OF _ assms(1)]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   536
    unfolding convex_on_def and * by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   537
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   538
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   539
lemma convex_lower:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   540
  assumes "convex_on s f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   541
    and "x \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   542
    and "y \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   543
    and "0 \<le> u"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   544
    and "0 \<le> v"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   545
    and "u + v = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   546
  shows "f (u *\<^sub>R x + v *\<^sub>R y) \<le> max (f x) (f y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   547
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   548
  let ?m = "max (f x) (f y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   549
  have "u * f x + v * f y \<le> u * max (f x) (f y) + v * max (f x) (f y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   550
    using assms(4,5) by (auto simp: mult_left_mono add_mono)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   551
  also have "\<dots> = max (f x) (f y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   552
    using assms(6) by (simp add: distrib_right [symmetric])
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   553
  finally show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   554
    using assms unfolding convex_on_def by fastforce
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   555
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   556
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   557
lemma convex_on_dist [intro]:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   558
  fixes s :: "'a::real_normed_vector set"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   559
  shows "convex_on s (\<lambda>x. dist a x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   560
proof (auto simp: convex_on_def dist_norm)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   561
  fix x y
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   562
  assume "x \<in> s" "y \<in> s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   563
  fix u v :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   564
  assume "0 \<le> u"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   565
  assume "0 \<le> v"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   566
  assume "u + v = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   567
  have "a = u *\<^sub>R a + v *\<^sub>R a"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   568
    unfolding scaleR_left_distrib[symmetric] and \<open>u + v = 1\<close> by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   569
  then have *: "a - (u *\<^sub>R x + v *\<^sub>R y) = (u *\<^sub>R (a - x)) + (v *\<^sub>R (a - y))"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   570
    by (auto simp: algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   571
  show "norm (a - (u *\<^sub>R x + v *\<^sub>R y)) \<le> u * norm (a - x) + v * norm (a - y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   572
    unfolding * using norm_triangle_ineq[of "u *\<^sub>R (a - x)" "v *\<^sub>R (a - y)"]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   573
    using \<open>0 \<le> u\<close> \<open>0 \<le> v\<close> by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   574
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   575
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   576
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   577
subsection%unimportant \<open>Arithmetic operations on sets preserve convexity\<close>
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   578
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   579
lemma convex_linear_image:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   580
  assumes "linear f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   581
    and "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   582
  shows "convex (f ` s)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   583
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   584
  interpret f: linear f by fact
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   585
  from \<open>convex s\<close> show "convex (f ` s)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   586
    by (simp add: convex_def f.scaleR [symmetric] f.add [symmetric])
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   587
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   588
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   589
lemma convex_linear_vimage:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   590
  assumes "linear f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   591
    and "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   592
  shows "convex (f -` s)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   593
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   594
  interpret f: linear f by fact
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   595
  from \<open>convex s\<close> show "convex (f -` s)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   596
    by (simp add: convex_def f.add f.scaleR)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   597
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   598
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   599
lemma convex_scaling:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   600
  assumes "convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   601
  shows "convex ((\<lambda>x. c *\<^sub>R x) ` s)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   602
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   603
  have "linear (\<lambda>x. c *\<^sub>R x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   604
    by (simp add: linearI scaleR_add_right)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   605
  then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   606
    using \<open>convex s\<close> by (rule convex_linear_image)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   607
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   608
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   609
lemma convex_scaled:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   610
  assumes "convex S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   611
  shows "convex ((\<lambda>x. x *\<^sub>R c) ` S)"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   612
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   613
  have "linear (\<lambda>x. x *\<^sub>R c)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   614
    by (simp add: linearI scaleR_add_left)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   615
  then show ?thesis
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   616
    using \<open>convex S\<close> by (rule convex_linear_image)
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   617
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   618
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   619
lemma convex_negations:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   620
  assumes "convex S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   621
  shows "convex ((\<lambda>x. - x) ` S)"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   622
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   623
  have "linear (\<lambda>x. - x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   624
    by (simp add: linearI)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   625
  then show ?thesis
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   626
    using \<open>convex S\<close> by (rule convex_linear_image)
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   627
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   628
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   629
lemma convex_sums:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   630
  assumes "convex S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   631
    and "convex T"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   632
  shows "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   633
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   634
  have "linear (\<lambda>(x, y). x + y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   635
    by (auto intro: linearI simp: scaleR_add_right)
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   636
  with assms have "convex ((\<lambda>(x, y). x + y) ` (S \<times> T))"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   637
    by (intro convex_linear_image convex_Times)
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   638
  also have "((\<lambda>(x, y). x + y) ` (S \<times> T)) = (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   639
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   640
  finally show ?thesis .
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   641
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   642
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   643
lemma convex_differences:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   644
  assumes "convex S" "convex T"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   645
  shows "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   646
proof -
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   647
  have "{x - y| x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   648
    by (auto simp: diff_conv_add_uminus simp del: add_uminus_conv_diff)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   649
  then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   650
    using convex_sums[OF assms(1) convex_negations[OF assms(2)]] by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   651
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   652
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   653
lemma convex_translation:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   654
  assumes "convex S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   655
  shows "convex ((\<lambda>x. a + x) ` S)"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   656
proof -
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   657
  have "(\<Union> x\<in> {a}. \<Union>y \<in> S. {x + y}) = (\<lambda>x. a + x) ` S"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   658
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   659
  then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   660
    using convex_sums[OF convex_singleton[of a] assms] by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   661
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   662
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   663
lemma convex_affinity:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   664
  assumes "convex S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   665
  shows "convex ((\<lambda>x. a + c *\<^sub>R x) ` S)"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
   666
proof -
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
   667
  have "(\<lambda>x. a + c *\<^sub>R x) ` S = (+) a ` ( *\<^sub>R) c ` S"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   668
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   669
  then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   670
    using convex_translation[OF convex_scaling[OF assms], of a c] by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   671
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   672
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   673
lemma pos_is_convex: "convex {0 :: real <..}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   674
  unfolding convex_alt
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   675
proof safe
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   676
  fix y x \<mu> :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   677
  assume *: "y > 0" "x > 0" "\<mu> \<ge> 0" "\<mu> \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   678
  {
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   679
    assume "\<mu> = 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   680
    then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y = y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   681
      by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   682
    then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   683
      using * by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   684
  }
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   685
  moreover
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   686
  {
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   687
    assume "\<mu> = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   688
    then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   689
      using * by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   690
  }
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   691
  moreover
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   692
  {
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   693
    assume "\<mu> \<noteq> 1" "\<mu> \<noteq> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   694
    then have "\<mu> > 0" "(1 - \<mu>) > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   695
      using * by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   696
    then have "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   697
      using * by (auto simp: add_pos_pos)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   698
  }
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   699
  ultimately show "(1 - \<mu>) *\<^sub>R y + \<mu> *\<^sub>R x > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   700
    by fastforce
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   701
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   702
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   703
lemma convex_on_sum:
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   704
  fixes a :: "'a \<Rightarrow> real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   705
    and y :: "'a \<Rightarrow> 'b::real_vector"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   706
    and f :: "'b \<Rightarrow> real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   707
  assumes "finite s" "s \<noteq> {}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   708
    and "convex_on C f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   709
    and "convex C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   710
    and "(\<Sum> i \<in> s. a i) = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   711
    and "\<And>i. i \<in> s \<Longrightarrow> a i \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   712
    and "\<And>i. i \<in> s \<Longrightarrow> y i \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   713
  shows "f (\<Sum> i \<in> s. a i *\<^sub>R y i) \<le> (\<Sum> i \<in> s. a i * f (y i))"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   714
  using assms
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   715
proof (induct s arbitrary: a rule: finite_ne_induct)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   716
  case (singleton i)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   717
  then have ai: "a i = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   718
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   719
  then show ?case
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   720
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   721
next
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   722
  case (insert i s)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   723
  then have "convex_on C f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   724
    by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   725
  from this[unfolded convex_on_def, rule_format]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   726
  have conv: "\<And>x y \<mu>. x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> 0 \<le> \<mu> \<Longrightarrow> \<mu> \<le> 1 \<Longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   727
      f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   728
    by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   729
  show ?case
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   730
  proof (cases "a i = 1")
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   731
    case True
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   732
    then have "(\<Sum> j \<in> s. a j) = 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   733
      using insert by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   734
    then have "\<And>j. j \<in> s \<Longrightarrow> a j = 0"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   735
      using insert by (fastforce simp: sum_nonneg_eq_0_iff)
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   736
    then show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   737
      using insert by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   738
  next
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   739
    case False
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   740
    from insert have yai: "y i \<in> C" "a i \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   741
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   742
    have fis: "finite (insert i s)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   743
      using insert by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   744
    then have ai1: "a i \<le> 1"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   745
      using sum_nonneg_leq_bound[of "insert i s" a] insert by simp
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   746
    then have "a i < 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   747
      using False by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   748
    then have i0: "1 - a i > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   749
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   750
    let ?a = "\<lambda>j. a j / (1 - a i)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   751
    have a_nonneg: "?a j \<ge> 0" if "j \<in> s" for j
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   752
      using i0 insert that by fastforce
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   753
    have "(\<Sum> j \<in> insert i s. a j) = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   754
      using insert by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   755
    then have "(\<Sum> j \<in> s. a j) = 1 - a i"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   756
      using sum.insert insert by fastforce
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   757
    then have "(\<Sum> j \<in> s. a j) / (1 - a i) = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   758
      using i0 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   759
    then have a1: "(\<Sum> j \<in> s. ?a j) = 1"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   760
      unfolding sum_divide_distrib by simp
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   761
    have "convex C" using insert by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   762
    then have asum: "(\<Sum> j \<in> s. ?a j *\<^sub>R y j) \<in> C"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   763
      using insert convex_sum [OF \<open>finite s\<close> \<open>convex C\<close> a1 a_nonneg] by auto
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   764
    have asum_le: "f (\<Sum> j \<in> s. ?a j *\<^sub>R y j) \<le> (\<Sum> j \<in> s. ?a j * f (y j))"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   765
      using a_nonneg a1 insert by blast
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   766
    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)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   767
      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
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   768
      by (auto simp only: add.commute)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   769
    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)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   770
      using i0 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   771
    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)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   772
      using scaleR_right.sum[of "inverse (1 - a i)" "\<lambda> j. a j *\<^sub>R y j" s, symmetric]
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   773
      by (auto simp: algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   774
    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)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   775
      by (auto simp: divide_inverse)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   776
    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)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   777
      using conv[of "y i" "(\<Sum> j \<in> s. ?a j *\<^sub>R y j)" "a i", OF yai(1) asum yai(2) ai1]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   778
      by (auto simp: add.commute)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   779
    also have "\<dots> \<le> (1 - a i) * (\<Sum> j \<in> s. ?a j * f (y j)) + a i * f (y i)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   780
      using add_right_mono [OF mult_left_mono [of _ _ "1 - a i",
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   781
            OF asum_le less_imp_le[OF i0]], of "a i * f (y i)"]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   782
      by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   783
    also have "\<dots> = (\<Sum> j \<in> s. (1 - a i) * ?a j * f (y j)) + a i * f (y i)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
   784
      unfolding sum_distrib_left[of "1 - a i" "\<lambda> j. ?a j * f (y j)"]
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   785
      using i0 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   786
    also have "\<dots> = (\<Sum> j \<in> s. a j * f (y j)) + a i * f (y i)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   787
      using i0 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   788
    also have "\<dots> = (\<Sum> j \<in> insert i s. a j * f (y j))"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   789
      using insert by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   790
    finally show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   791
      by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   792
  qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   793
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   794
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   795
lemma convex_on_alt:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   796
  fixes C :: "'a::real_vector set"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   797
  assumes "convex C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   798
  shows "convex_on C f \<longleftrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   799
    (\<forall>x \<in> C. \<forall> y \<in> C. \<forall> \<mu> :: real. \<mu> \<ge> 0 \<and> \<mu> \<le> 1 \<longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   800
      f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   801
proof safe
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   802
  fix x y
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   803
  fix \<mu> :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   804
  assume *: "convex_on C f" "x \<in> C" "y \<in> C" "0 \<le> \<mu>" "\<mu> \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   805
  from this[unfolded convex_on_def, rule_format]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   806
  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
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   807
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   808
  from this [of "\<mu>" "1 - \<mu>", simplified] *
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   809
  show "f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   810
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   811
next
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   812
  assume *: "\<forall>x\<in>C. \<forall>y\<in>C. \<forall>\<mu>. 0 \<le> \<mu> \<and> \<mu> \<le> 1 \<longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   813
    f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   814
  {
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   815
    fix x y
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   816
    fix u v :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   817
    assume **: "x \<in> C" "y \<in> C" "u \<ge> 0" "v \<ge> 0" "u + v = 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   818
    then have[simp]: "1 - u = v" by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   819
    from *[rule_format, of x y u]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   820
    have "f (u *\<^sub>R x + v *\<^sub>R y) \<le> u * f x + v * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   821
      using ** by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   822
  }
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   823
  then show "convex_on C f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   824
    unfolding convex_on_def by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   825
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   826
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   827
lemma convex_on_diff:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   828
  fixes f :: "real \<Rightarrow> real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   829
  assumes f: "convex_on I f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   830
    and I: "x \<in> I" "y \<in> I"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   831
    and t: "x < t" "t < y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   832
  shows "(f x - f t) / (x - t) \<le> (f x - f y) / (x - y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   833
    and "(f x - f y) / (x - y) \<le> (f t - f y) / (t - y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   834
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   835
  define a where "a \<equiv> (t - y) / (x - y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   836
  with t have "0 \<le> a" "0 \<le> 1 - a"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   837
    by (auto simp: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   838
  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"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   839
    by (auto simp: convex_on_def)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   840
  have "a * x + (1 - a) * y = a * (x - y) + y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   841
    by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   842
  also have "\<dots> = t"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   843
    unfolding a_def using \<open>x < t\<close> \<open>t < y\<close> by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   844
  finally have "f t \<le> a * f x + (1 - a) * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   845
    using cvx by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   846
  also have "\<dots> = a * (f x - f y) + f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   847
    by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   848
  finally have "f t - f y \<le> a * (f x - f y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   849
    by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   850
  with t show "(f x - f t) / (x - t) \<le> (f x - f y) / (x - y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   851
    by (simp add: le_divide_eq divide_le_eq field_simps a_def)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   852
  with t show "(f x - f y) / (x - y) \<le> (f t - f y) / (t - y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   853
    by (simp add: le_divide_eq divide_le_eq field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   854
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   855
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   856
lemma pos_convex_function:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   857
  fixes f :: "real \<Rightarrow> real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   858
  assumes "convex C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   859
    and leq: "\<And>x y. x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> f' x * (y - x) \<le> f y - f x"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   860
  shows "convex_on C f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   861
  unfolding convex_on_alt[OF assms(1)]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   862
  using assms
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   863
proof safe
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   864
  fix x y \<mu> :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   865
  let ?x = "\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   866
  assume *: "convex C" "x \<in> C" "y \<in> C" "\<mu> \<ge> 0" "\<mu> \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   867
  then have "1 - \<mu> \<ge> 0" by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   868
  then have xpos: "?x \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   869
    using * unfolding convex_alt by fastforce
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   870
  have geq: "\<mu> * (f x - f ?x) + (1 - \<mu>) * (f y - f ?x) \<ge>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   871
      \<mu> * f' ?x * (x - ?x) + (1 - \<mu>) * f' ?x * (y - ?x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   872
    using add_mono [OF mult_left_mono [OF leq [OF xpos *(2)] \<open>\<mu> \<ge> 0\<close>]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   873
        mult_left_mono [OF leq [OF xpos *(3)] \<open>1 - \<mu> \<ge> 0\<close>]]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   874
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   875
  then have "\<mu> * f x + (1 - \<mu>) * f y - f ?x \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   876
    by (auto simp: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   877
  then show "f (\<mu> *\<^sub>R x + (1 - \<mu>) *\<^sub>R y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   878
    using convex_on_alt by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   879
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   880
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   881
lemma atMostAtLeast_subset_convex:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   882
  fixes C :: "real set"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   883
  assumes "convex C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   884
    and "x \<in> C" "y \<in> C" "x < y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   885
  shows "{x .. y} \<subseteq> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   886
proof safe
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   887
  fix z assume z: "z \<in> {x .. y}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   888
  have less: "z \<in> C" if *: "x < z" "z < y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   889
  proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   890
    let ?\<mu> = "(y - z) / (y - x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   891
    have "0 \<le> ?\<mu>" "?\<mu> \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   892
      using assms * by (auto simp: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   893
    then have comb: "?\<mu> * x + (1 - ?\<mu>) * y \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   894
      using assms iffD1[OF convex_alt, rule_format, of C y x ?\<mu>]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   895
      by (simp add: algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   896
    have "?\<mu> * x + (1 - ?\<mu>) * y = (y - z) * x / (y - x) + (1 - (y - z) / (y - x)) * y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   897
      by (auto simp: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   898
    also have "\<dots> = ((y - z) * x + (y - x - (y - z)) * y) / (y - x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   899
      using assms by (simp only: add_divide_distrib) (auto simp: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   900
    also have "\<dots> = z"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   901
      using assms by (auto simp: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   902
    finally show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   903
      using comb by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   904
  qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   905
  show "z \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   906
    using z less assms by (auto simp: le_less)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   907
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   908
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   909
lemma f''_imp_f':
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   910
  fixes f :: "real \<Rightarrow> real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   911
  assumes "convex C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   912
    and f': "\<And>x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   913
    and f'': "\<And>x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   914
    and pos: "\<And>x. x \<in> C \<Longrightarrow> f'' x \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   915
    and x: "x \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   916
    and y: "y \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   917
  shows "f' x * (y - x) \<le> f y - f x"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   918
  using assms
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   919
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   920
  have less_imp: "f y - f x \<ge> f' x * (y - x)" "f' y * (x - y) \<le> f x - f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   921
    if *: "x \<in> C" "y \<in> C" "y > x" for x y :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   922
  proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   923
    from * have ge: "y - x > 0" "y - x \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   924
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   925
    from * have le: "x - y < 0" "x - y \<le> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   926
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   927
    then obtain z1 where z1: "z1 > x" "z1 < y" "f y - f x = (y - x) * f' z1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   928
      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>],
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   929
          THEN f', THEN MVT2[OF \<open>x < y\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   930
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   931
    then have "z1 \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   932
      using atMostAtLeast_subset_convex \<open>convex C\<close> \<open>x \<in> C\<close> \<open>y \<in> C\<close> \<open>x < y\<close>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   933
      by fastforce
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   934
    from z1 have z1': "f x - f y = (x - y) * f' z1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   935
      by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   936
    obtain z2 where z2: "z2 > x" "z2 < z1" "f' z1 - f' x = (z1 - x) * f'' z2"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   937
      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>],
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   938
          THEN f'', THEN MVT2[OF \<open>x < z1\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]] z1
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   939
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   940
    obtain z3 where z3: "z3 > z1" "z3 < y" "f' y - f' z1 = (y - z1) * f'' z3"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   941
      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>],
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   942
          THEN f'', THEN MVT2[OF \<open>z1 < y\<close>, rule_format, unfolded atLeastAtMost_iff[symmetric]]] z1
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   943
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   944
    have "f' y - (f x - f y) / (x - y) = f' y - f' z1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   945
      using * z1' by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   946
    also have "\<dots> = (y - z1) * f'' z3"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   947
      using z3 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   948
    finally have cool': "f' y - (f x - f y) / (x - y) = (y - z1) * f'' z3"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   949
      by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   950
    have A': "y - z1 \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   951
      using z1 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   952
    have "z3 \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   953
      using z3 * atMostAtLeast_subset_convex \<open>convex C\<close> \<open>x \<in> C\<close> \<open>z1 \<in> C\<close> \<open>x < z1\<close>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   954
      by fastforce
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   955
    then have B': "f'' z3 \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   956
      using assms by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   957
    from A' B' have "(y - z1) * f'' z3 \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   958
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   959
    from cool' this have "f' y - (f x - f y) / (x - y) \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   960
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   961
    from mult_right_mono_neg[OF this le(2)]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   962
    have "f' y * (x - y) - (f x - f y) / (x - y) * (x - y) \<le> 0 * (x - y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   963
      by (simp add: algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   964
    then have "f' y * (x - y) - (f x - f y) \<le> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   965
      using le by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   966
    then have res: "f' y * (x - y) \<le> f x - f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   967
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   968
    have "(f y - f x) / (y - x) - f' x = f' z1 - f' x"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   969
      using * z1 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   970
    also have "\<dots> = (z1 - x) * f'' z2"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   971
      using z2 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   972
    finally have cool: "(f y - f x) / (y - x) - f' x = (z1 - x) * f'' z2"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   973
      by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   974
    have A: "z1 - x \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   975
      using z1 by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   976
    have "z2 \<in> C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   977
      using z2 z1 * atMostAtLeast_subset_convex \<open>convex C\<close> \<open>z1 \<in> C\<close> \<open>y \<in> C\<close> \<open>z1 < y\<close>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   978
      by fastforce
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   979
    then have B: "f'' z2 \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   980
      using assms by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   981
    from A B have "(z1 - x) * f'' z2 \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   982
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   983
    with cool have "(f y - f x) / (y - x) - f' x \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   984
      by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   985
    from mult_right_mono[OF this ge(2)]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   986
    have "(f y - f x) / (y - x) * (y - x) - f' x * (y - x) \<ge> 0 * (y - x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   987
      by (simp add: algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   988
    then have "f y - f x - f' x * (y - x) \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   989
      using ge by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   990
    then show "f y - f x \<ge> f' x * (y - x)" "f' y * (x - y) \<le> f x - f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   991
      using res by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   992
  qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   993
  show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   994
  proof (cases "x = y")
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   995
    case True
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   996
    with x y show ?thesis by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   997
  next
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   998
    case False
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
   999
    with less_imp x y show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1000
      by (auto simp: neq_iff)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1001
  qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1002
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1003
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1004
lemma f''_ge0_imp_convex:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1005
  fixes f :: "real \<Rightarrow> real"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1006
  assumes conv: "convex C"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1007
    and f': "\<And>x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1008
    and f'': "\<And>x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1009
    and pos: "\<And>x. x \<in> C \<Longrightarrow> f'' x \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1010
  shows "convex_on C f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1011
  using f''_imp_f'[OF conv f' f'' pos] assms pos_convex_function
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1012
  by fastforce
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1013
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1014
lemma minus_log_convex:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1015
  fixes b :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1016
  assumes "b > 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1017
  shows "convex_on {0 <..} (\<lambda> x. - log b x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1018
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1019
  have "\<And>z. z > 0 \<Longrightarrow> DERIV (log b) z :> 1 / (ln b * z)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1020
    using DERIV_log by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1021
  then have f': "\<And>z. z > 0 \<Longrightarrow> DERIV (\<lambda> z. - log b z) z :> - 1 / (ln b * z)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1022
    by (auto simp: DERIV_minus)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1023
  have "\<And>z::real. z > 0 \<Longrightarrow> DERIV inverse z :> - (inverse z ^ Suc (Suc 0))"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1024
    using less_imp_neq[THEN not_sym, THEN DERIV_inverse] by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1025
  from this[THEN DERIV_cmult, of _ "- 1 / ln b"]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1026
  have "\<And>z::real. z > 0 \<Longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1027
    DERIV (\<lambda> z. (- 1 / ln b) * inverse z) z :> (- 1 / ln b) * (- (inverse z ^ Suc (Suc 0)))"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1028
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1029
  then have f''0: "\<And>z::real. z > 0 \<Longrightarrow>
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1030
    DERIV (\<lambda> z. - 1 / (ln b * z)) z :> 1 / (ln b * z * z)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1031
    unfolding inverse_eq_divide by (auto simp: mult.assoc)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1032
  have f''_ge0: "\<And>z::real. z > 0 \<Longrightarrow> 1 / (ln b * z * z) \<ge> 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1033
    using \<open>b > 1\<close> by (auto intro!: less_imp_le)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1034
  from f''_ge0_imp_convex[OF pos_is_convex, unfolded greaterThan_iff, OF f' f''0 f''_ge0]
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1035
  show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1036
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1037
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1038
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1039
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1040
subsection%unimportant \<open>Convexity of real functions\<close>
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1041
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1042
lemma convex_on_realI:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1043
  assumes "connected A"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1044
    and "\<And>x. x \<in> A \<Longrightarrow> (f has_real_derivative f' x) (at x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1045
    and "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x \<le> y \<Longrightarrow> f' x \<le> f' y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1046
  shows "convex_on A f"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1047
proof (rule convex_on_linorderI)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1048
  fix t x y :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1049
  assume t: "t > 0" "t < 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1050
  assume xy: "x \<in> A" "y \<in> A" "x < y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1051
  define z where "z = (1 - t) * x + t * y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1052
  with \<open>connected A\<close> and xy have ivl: "{x..y} \<subseteq> A"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1053
    using connected_contains_Icc by blast
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1054
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1055
  from xy t have xz: "z > x"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1056
    by (simp add: z_def algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1057
  have "y - z = (1 - t) * (y - x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1058
    by (simp add: z_def algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1059
  also from xy t have "\<dots> > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1060
    by (intro mult_pos_pos) simp_all
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1061
  finally have yz: "z < y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1062
    by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1063
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1064
  from assms xz yz ivl t have "\<exists>\<xi>. \<xi> > x \<and> \<xi> < z \<and> f z - f x = (z - x) * f' \<xi>"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1065
    by (intro MVT2) (auto intro!: assms(2))
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1066
  then obtain \<xi> where \<xi>: "\<xi> > x" "\<xi> < z" "f' \<xi> = (f z - f x) / (z - x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1067
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1068
  from assms xz yz ivl t have "\<exists>\<eta>. \<eta> > z \<and> \<eta> < y \<and> f y - f z = (y - z) * f' \<eta>"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1069
    by (intro MVT2) (auto intro!: assms(2))
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1070
  then obtain \<eta> where \<eta>: "\<eta> > z" "\<eta> < y" "f' \<eta> = (f y - f z) / (y - z)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1071
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1072
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1073
  from \<eta>(3) have "(f y - f z) / (y - z) = f' \<eta>" ..
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1074
  also from \<xi> \<eta> ivl have "\<xi> \<in> A" "\<eta> \<in> A"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1075
    by auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1076
  with \<xi> \<eta> have "f' \<eta> \<ge> f' \<xi>"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1077
    by (intro assms(3)) auto
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1078
  also from \<xi>(3) have "f' \<xi> = (f z - f x) / (z - x)" .
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1079
  finally have "(f y - f z) * (z - x) \<ge> (f z - f x) * (y - z)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1080
    using xz yz by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1081
  also have "z - x = t * (y - x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1082
    by (simp add: z_def algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1083
  also have "y - z = (1 - t) * (y - x)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1084
    by (simp add: z_def algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1085
  finally have "(f y - f z) * t \<ge> (f z - f x) * (1 - t)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1086
    using xy by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1087
  then show "(1 - t) * f x + t * f y \<ge> f ((1 - t) *\<^sub>R x + t *\<^sub>R y)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1088
    by (simp add: z_def algebra_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1089
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1090
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1091
lemma convex_on_inverse:
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1092
  assumes "A \<subseteq> {0<..}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1093
  shows "convex_on A (inverse :: real \<Rightarrow> real)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1094
proof (rule convex_on_subset[OF _ assms], intro convex_on_realI[of _ _ "\<lambda>x. -inverse (x^2)"])
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1095
  fix u v :: real
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1096
  assume "u \<in> {0<..}" "v \<in> {0<..}" "u \<le> v"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1097
  with assms show "-inverse (u^2) \<le> -inverse (v^2)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1098
    by (intro le_imp_neg_le le_imp_inverse_le power_mono) (simp_all)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1099
qed (insert assms, auto intro!: derivative_eq_intros simp: divide_simps power2_eq_square)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1100
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1101
lemma convex_onD_Icc':
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1102
  assumes "convex_on {x..y} f" "c \<in> {x..y}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1103
  defines "d \<equiv> y - x"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1104
  shows "f c \<le> (f y - f x) / d * (c - x) + f x"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1105
proof (cases x y rule: linorder_cases)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1106
  case less
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1107
  then have d: "d > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1108
    by (simp add: d_def)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1109
  from assms(2) less have A: "0 \<le> (c - x) / d" "(c - x) / d \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1110
    by (simp_all add: d_def divide_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1111
  have "f c = f (x + (c - x) * 1)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1112
    by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1113
  also from less have "1 = ((y - x) / d)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1114
    by (simp add: d_def)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1115
  also from d have "x + (c - x) * \<dots> = (1 - (c - x) / d) *\<^sub>R x + ((c - x) / d) *\<^sub>R y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1116
    by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1117
  also have "f \<dots> \<le> (1 - (c - x) / d) * f x + (c - x) / d * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1118
    using assms less by (intro convex_onD_Icc) simp_all
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1119
  also from d have "\<dots> = (f y - f x) / d * (c - x) + f x"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1120
    by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1121
  finally show ?thesis .
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1122
qed (insert assms(2), simp_all)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1123
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1124
lemma convex_onD_Icc'':
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1125
  assumes "convex_on {x..y} f" "c \<in> {x..y}"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1126
  defines "d \<equiv> y - x"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1127
  shows "f c \<le> (f x - f y) / d * (y - c) + f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1128
proof (cases x y rule: linorder_cases)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1129
  case less
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1130
  then have d: "d > 0"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1131
    by (simp add: d_def)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1132
  from assms(2) less have A: "0 \<le> (y - c) / d" "(y - c) / d \<le> 1"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1133
    by (simp_all add: d_def divide_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1134
  have "f c = f (y - (y - c) * 1)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1135
    by simp
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1136
  also from less have "1 = ((y - x) / d)"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1137
    by (simp add: d_def)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1138
  also from d have "y - (y - c) * \<dots> = (1 - (1 - (y - c) / d)) *\<^sub>R x + (1 - (y - c) / d) *\<^sub>R y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1139
    by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1140
  also have "f \<dots> \<le> (1 - (1 - (y - c) / d)) * f x + (1 - (y - c) / d) * f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1141
    using assms less by (intro convex_onD_Icc) (simp_all add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1142
  also from d have "\<dots> = (f x - f y) / d * (y - c) + f y"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1143
    by (simp add: field_simps)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1144
  finally show ?thesis .
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1145
qed (insert assms(2), simp_all)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1146
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1147
lemma convex_supp_sum:
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1148
  assumes "convex S" and 1: "supp_sum u I = 1"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1149
      and "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> u i \<and> (u i = 0 \<or> f i \<in> S)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1150
    shows "supp_sum (\<lambda>i. u i *\<^sub>R f i) I \<in> S"
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1151
proof -
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1152
  have fin: "finite {i \<in> I. u i \<noteq> 0}"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1153
    using 1 sum.infinite by (force simp: supp_sum_def support_on_def)
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1154
  then have eq: "supp_sum (\<lambda>i. u i *\<^sub>R f i) I = sum (\<lambda>i. u i *\<^sub>R f i) {i \<in> I. u i \<noteq> 0}"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1155
    by (force intro: sum.mono_neutral_left simp: supp_sum_def support_on_def)
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1156
  show ?thesis
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1157
    apply (simp add: eq)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1158
    apply (rule convex_sum [OF fin \<open>convex S\<close>])
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1159
    using 1 assms apply (auto simp: supp_sum_def support_on_def)
63969
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1160
    done
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1161
qed
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1162
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1163
lemma convex_translation_eq [simp]: "convex ((\<lambda>x. a + x) ` s) \<longleftrightarrow> convex s"
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1164
  by (metis convex_translation translation_galois)
f4b4fba60b1d HOL-Analysis: move Library/Convex to Convex_Euclidean_Space
hoelzl
parents: 63967
diff changeset
  1165
61694
6571c78c9667 Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
  1166
lemma convex_linear_image_eq [simp]:
6571c78c9667 Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
  1167
    fixes f :: "'a::real_vector \<Rightarrow> 'b::real_vector"
6571c78c9667 Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
  1168
    shows "\<lbrakk>linear f; inj f\<rbrakk> \<Longrightarrow> convex (f ` s) \<longleftrightarrow> convex s"
6571c78c9667 Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
  1169
    by (metis (no_types) convex_linear_image convex_linear_vimage inj_vimage_image_eq)
6571c78c9667 Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
  1170
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1171
lemma closure_bounded_linear_image_subset:
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  1172
  assumes f: "bounded_linear f"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1173
  shows "f ` closure S \<subseteq> closure (f ` S)"
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  1174
  using linear_continuous_on [OF f] closed_closure closure_subset
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  1175
  by (rule image_closure_subset)
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  1176
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1177
lemma closure_linear_image_subset:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1178
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::real_normed_vector"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1179
  assumes "linear f"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1180
  shows "f ` (closure S) \<subseteq> closure (f ` S)"
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  1181
  using assms unfolding linear_conv_bounded_linear
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1182
  by (rule closure_bounded_linear_image_subset)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1183
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1184
lemma closed_injective_linear_image:
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1185
    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1186
    assumes S: "closed S" and f: "linear f" "inj f"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1187
    shows "closed (f ` S)"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1188
proof -
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1189
  obtain g where g: "linear g" "g \<circ> f = id"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1190
    using linear_injective_left_inverse [OF f] by blast
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1191
  then have confg: "continuous_on (range f) g"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1192
    using linear_continuous_on linear_conv_bounded_linear by blast
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1193
  have [simp]: "g ` f ` S = S"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1194
    using g by (simp add: image_comp)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1195
  have cgf: "closed (g ` f ` S)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61762
diff changeset
  1196
    by (simp add: \<open>g \<circ> f = id\<close> S image_comp)
66884
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1197
  have [simp]: "(range f \<inter> g -` S) = f ` S"
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1198
    using g unfolding o_def id_def image_def by auto metis+
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1199
  show ?thesis
66884
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1200
  proof (rule closedin_closed_trans [of "range f"])
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1201
    show "closedin (subtopology euclidean (range f)) (f ` S)"
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1202
      using continuous_closedin_preimage [OF confg cgf] by simp
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1203
    show "closed (range f)"
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1204
      apply (rule closed_injective_image_subspace)
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1205
      using f apply (auto simp: linear_linear linear_injective_0)
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1206
      done
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  1207
  qed
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1208
qed
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1209
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1210
lemma closed_injective_linear_image_eq:
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1211
    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1212
    assumes f: "linear f" "inj f"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1213
      shows "(closed(image f s) \<longleftrightarrow> closed s)"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1214
  by (metis closed_injective_linear_image closure_eq closure_linear_image_subset closure_subset_eq f(1) f(2) inj_image_subset_iff)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1215
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1216
lemma closure_injective_linear_image:
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1217
    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1218
    shows "\<lbrakk>linear f; inj f\<rbrakk> \<Longrightarrow> f ` (closure S) = closure (f ` S)"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1219
  apply (rule subset_antisym)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1220
  apply (simp add: closure_linear_image_subset)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1221
  by (simp add: closure_minimal closed_injective_linear_image closure_subset image_mono)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1222
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1223
lemma closure_bounded_linear_image:
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1224
    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1225
    shows "\<lbrakk>linear f; bounded S\<rbrakk> \<Longrightarrow> f ` (closure S) = closure (f ` S)"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1226
  apply (rule subset_antisym, simp add: closure_linear_image_subset)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1227
  apply (rule closure_minimal, simp add: closure_subset image_mono)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1228
  by (meson bounded_closure closed_closure compact_continuous_image compact_eq_bounded_closed linear_continuous_on linear_conv_bounded_linear)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1229
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  1230
lemma closure_scaleR:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1231
  fixes S :: "'a::real_normed_vector set"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1232
  shows "(( *\<^sub>R) c) ` (closure S) = closure ((( *\<^sub>R) c) ` S)"
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  1233
proof
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1234
  show "(( *\<^sub>R) c) ` (closure S) \<subseteq> closure ((( *\<^sub>R) c) ` S)"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1235
    using bounded_linear_scaleR_right
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  1236
    by (rule closure_bounded_linear_image_subset)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1237
  show "closure ((( *\<^sub>R) c) ` S) \<subseteq> (( *\<^sub>R) c) ` (closure S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1238
    by (intro closure_minimal image_mono closure_subset closed_scaling closed_closure)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1239
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1240
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1241
lemma fst_linear: "linear fst"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
  1242
  unfolding linear_iff by (simp add: algebra_simps)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1243
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1244
lemma snd_linear: "linear snd"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
  1245
  unfolding linear_iff by (simp add: algebra_simps)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1246
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1247
lemma fst_snd_linear: "linear (\<lambda>(x,y). x + y)"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53406
diff changeset
  1248
  unfolding linear_iff by (simp add: algebra_simps)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1249
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1250
lemma vector_choose_size:
62381
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1251
  assumes "0 \<le> c"
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1252
  obtains x :: "'a::{real_normed_vector, perfect_space}" where "norm x = c"
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1253
proof -
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1254
  obtain a::'a where "a \<noteq> 0"
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1255
    using UNIV_not_singleton UNIV_eq_I set_zero singletonI by fastforce
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1256
  then show ?thesis
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1257
    by (rule_tac x="scaleR (c / norm a) a" in that) (simp add: assms)
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1258
qed
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1259
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1260
lemma vector_choose_dist:
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1261
  assumes "0 \<le> c"
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1262
  obtains y :: "'a::{real_normed_vector, perfect_space}" where "dist x y = c"
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1263
by (metis add_diff_cancel_left' assms dist_commute dist_norm vector_choose_size)
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1264
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1265
lemma sphere_eq_empty [simp]:
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1266
  fixes a :: "'a::{real_normed_vector, perfect_space}"
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1267
  shows "sphere a r = {} \<longleftrightarrow> r < 0"
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  1268
by (auto simp: sphere_def dist_norm) (metis dist_norm le_less_linear vector_choose_dist)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1269
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1270
lemma sum_delta_notmem:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1271
  assumes "x \<notin> s"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1272
  shows "sum (\<lambda>y. if (y = x) then P x else Q y) s = sum Q s"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1273
    and "sum (\<lambda>y. if (x = y) then P x else Q y) s = sum Q s"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1274
    and "sum (\<lambda>y. if (y = x) then P y else Q y) s = sum Q s"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1275
    and "sum (\<lambda>y. if (x = y) then P y else Q y) s = sum Q s"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1276
  apply (rule_tac [!] sum.cong)
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1277
  using assms
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1278
  apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1279
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1280
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1281
lemma sum_delta'':
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1282
  fixes s::"'a::real_vector set"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1283
  assumes "finite s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1284
  shows "(\<Sum>x\<in>s. (if y = x then f x else 0) *\<^sub>R x) = (if y\<in>s then (f y) *\<^sub>R y else 0)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1285
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1286
  have *: "\<And>x y. (if y = x then f x else (0::real)) *\<^sub>R x = (if x=y then (f x) *\<^sub>R x else 0)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1287
    by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1288
  show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1289
    unfolding * using sum.delta[OF assms, of y "\<lambda>x. f x *\<^sub>R x"] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1290
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1291
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1292
lemma if_smult: "(if P then x else (y::real)) *\<^sub>R v = (if P then x *\<^sub>R v else y *\<^sub>R v)"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56889
diff changeset
  1293
  by (fact if_distrib)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1294
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1295
lemma dist_triangle_eq:
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  1296
  fixes x y z :: "'a::real_inner"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1297
  shows "dist x z = dist x y + dist y z \<longleftrightarrow>
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1298
    norm (x - y) *\<^sub>R (y - z) = norm (y - z) *\<^sub>R (x - y)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1299
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1300
  have *: "x - y + (y - z) = x - z" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  1301
  show ?thesis unfolding dist_norm norm_triangle_eq[of "x - y" "y - z", unfolded *]
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1302
    by (auto simp:norm_minus_commute)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1303
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1304
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  1305
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1306
subsection \<open>Affine set and affine hull\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1307
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1308
definition%important affine :: "'a::real_vector set \<Rightarrow> bool"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1309
  where "affine s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u v. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> s)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1310
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1311
lemma affine_alt: "affine s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. \<forall>u::real. (1 - u) *\<^sub>R x + u *\<^sub>R y \<in> s)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1312
  unfolding affine_def by (metis eq_diff_eq')
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1313
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  1314
lemma affine_empty [iff]: "affine {}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1315
  unfolding affine_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1316
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  1317
lemma affine_sing [iff]: "affine {x}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1318
  unfolding affine_alt by (auto simp: scaleR_left_distrib [symmetric])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1319
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  1320
lemma affine_UNIV [iff]: "affine UNIV"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1321
  unfolding affine_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1322
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  1323
lemma affine_Inter [intro]: "(\<And>s. s\<in>f \<Longrightarrow> affine s) \<Longrightarrow> affine (\<Inter>f)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1324
  unfolding affine_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1325
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  1326
lemma affine_Int[intro]: "affine s \<Longrightarrow> affine t \<Longrightarrow> affine (s \<inter> t)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1327
  unfolding affine_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1328
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  1329
lemma affine_scaling: "affine s \<Longrightarrow> affine (image (\<lambda>x. c *\<^sub>R x) s)"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  1330
  apply (clarsimp simp add: affine_def)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  1331
  apply (rule_tac x="u *\<^sub>R x + v *\<^sub>R y" in image_eqI)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  1332
  apply (auto simp: algebra_simps)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  1333
  done
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  1334
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  1335
lemma affine_affine_hull [simp]: "affine(affine hull s)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1336
  unfolding hull_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1337
  using affine_Inter[of "{t. affine t \<and> s \<subseteq> t}"] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1338
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1339
lemma affine_hull_eq[simp]: "(affine hull s = s) \<longleftrightarrow> affine s"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1340
  by (metis affine_affine_hull hull_same)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1341
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  1342
lemma affine_hyperplane: "affine {x. a \<bullet> x = b}"
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  1343
  by (simp add: affine_def algebra_simps) (metis distrib_right mult.left_neutral)
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  1344
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1345
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1346
subsubsection%unimportant \<open>Some explicit formulations (from Lars Schewe)\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1347
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1348
lemma affine:
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1349
  fixes V::"'a::real_vector set"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1350
  shows "affine V \<longleftrightarrow>
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1351
         (\<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)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1352
proof -
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1353
  have "u *\<^sub>R x + v *\<^sub>R y \<in> V" if "x \<in> V" "y \<in> V" "u + v = (1::real)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1354
    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
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1355
  proof (cases "x = y")
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1356
    case True
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1357
    then show ?thesis
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1358
      using that by (metis scaleR_add_left scaleR_one)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1359
  next
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1360
    case False
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1361
    then show ?thesis
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1362
      using that *[of "{x,y}" "\<lambda>w. if w = x then u else v"] by auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1363
  qed
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1364
  moreover have "(\<Sum>x\<in>S. u x *\<^sub>R x) \<in> V"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1365
                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"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1366
                  and "finite S" "S \<noteq> {}" "S \<subseteq> V" "sum u S = 1" for S u
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1367
  proof -
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1368
    define n where "n = card S"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1369
    consider "card S = 0" | "card S = 1" | "card S = 2" | "card S > 2" by linarith
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1370
    then show "(\<Sum>x\<in>S. u x *\<^sub>R x) \<in> V"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1371
    proof cases
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1372
      assume "card S = 1"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1373
      then obtain a where "S={a}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1374
        by (auto simp: card_Suc_eq)
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1375
      then show ?thesis
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1376
        using that by simp
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1377
    next
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1378
      assume "card S = 2"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1379
      then obtain a b where "S = {a, b}"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1380
        by (metis Suc_1 card_1_singletonE card_Suc_eq)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1381
      then show ?thesis
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1382
        using *[of a b] that
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1383
        by (auto simp: sum_clauses(2))
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1384
    next
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1385
      assume "card S > 2"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1386
      then show ?thesis using that n_def
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1387
      proof (induct n arbitrary: u S)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1388
        case 0
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1389
        then show ?case by auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1390
      next
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1391
        case (Suc n u S)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1392
        have "sum u S = card S" if "\<not> (\<exists>x\<in>S. u x \<noteq> 1)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1393
          using that unfolding card_eq_sum by auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1394
        with Suc.prems obtain x where "x \<in> S" and x: "u x \<noteq> 1" by force
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1395
        have c: "card (S - {x}) = card S - 1"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1396
          by (simp add: Suc.prems(3) \<open>x \<in> S\<close>)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1397
        have "sum u (S - {x}) = 1 - u x"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1398
          by (simp add: Suc.prems sum_diff1_ring \<open>x \<in> S\<close>)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1399
        with x have eq1: "inverse (1 - u x) * sum u (S - {x}) = 1"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1400
          by auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1401
        have inV: "(\<Sum>y\<in>S - {x}. (inverse (1 - u x) * u y) *\<^sub>R y) \<in> V"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1402
        proof (cases "card (S - {x}) > 2")
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1403
          case True
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1404
          then have S: "S - {x} \<noteq> {}" "card (S - {x}) = n"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1405
            using Suc.prems c by force+
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1406
          show ?thesis
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1407
          proof (rule Suc.hyps)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1408
            show "(\<Sum>a\<in>S - {x}. inverse (1 - u x) * u a) = 1"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1409
              by (auto simp: eq1 sum_distrib_left[symmetric])
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1410
          qed (use S Suc.prems True in auto)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1411
        next
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1412
          case False
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1413
          then have "card (S - {x}) = Suc (Suc 0)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1414
            using Suc.prems c by auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1415
          then obtain a b where ab: "(S - {x}) = {a, b}" "a\<noteq>b"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1416
            unfolding card_Suc_eq by auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1417
          then show ?thesis
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1418
            using eq1 \<open>S \<subseteq> V\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1419
            by (auto simp: sum_distrib_left distrib_left intro!: Suc.prems(2)[of a b])
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1420
        qed
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1421
        have "u x + (1 - u x) = 1 \<Longrightarrow>
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1422
          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"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1423
          by (rule Suc.prems) (use \<open>x \<in> S\<close> Suc.prems inV in \<open>auto simp: scaleR_right.sum\<close>)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1424
        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)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1425
          by (meson Suc.prems(3) sum.remove \<open>x \<in> S\<close>)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1426
        ultimately show "(\<Sum>x\<in>S. u x *\<^sub>R x) \<in> V"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1427
          by (simp add: x)
45498
2dc373f1867a avoid numeral-representation-specific rules in metis proof
huffman
parents: 45051
diff changeset
  1428
      qed
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1429
    qed (use \<open>S\<noteq>{}\<close> \<open>finite S\<close> in auto)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1430
  qed
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1431
  ultimately show ?thesis
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1432
    unfolding affine_def by meson
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1433
qed
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1434
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1435
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1436
lemma affine_hull_explicit:
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1437
  "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}"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1438
  (is "_ = ?rhs")
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1439
proof (rule hull_unique)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1440
  show "p \<subseteq> ?rhs"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1441
  proof (intro subsetI CollectI exI conjI)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1442
    show "\<And>x. sum (\<lambda>z. 1) {x} = 1"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1443
      by auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1444
  qed auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1445
  show "?rhs \<subseteq> T" if "p \<subseteq> T" "affine T" for T
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1446
    using that unfolding affine by blast
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1447
  show "affine ?rhs"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1448
    unfolding affine_def
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1449
  proof clarify
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1450
    fix u v :: real and sx ux sy uy
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1451
    assume uv: "u + v = 1"
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1452
      and x: "finite sx" "sx \<noteq> {}" "sx \<subseteq> p" "sum ux sx = (1::real)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1453
      and y: "finite sy" "sy \<noteq> {}" "sy \<subseteq> p" "sum uy sy = (1::real)" 
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1454
    have **: "(sx \<union> sy) \<inter> sx = sx" "(sx \<union> sy) \<inter> sy = sy"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1455
      by auto
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1456
    show "\<exists>S w. finite S \<and> S \<noteq> {} \<and> S \<subseteq> p \<and>
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1457
        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)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1458
    proof (intro exI conjI)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1459
      show "finite (sx \<union> sy)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1460
        using x y by auto
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1461
      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"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1462
        using x y uv
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1463
        by (simp add: sum_Un sum.distrib sum.inter_restrict[symmetric] sum_distrib_left [symmetric] **)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1464
      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)
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1465
          = (\<Sum>i\<in>sx. (u * ux i) *\<^sub>R i) + (\<Sum>i\<in>sy. (v * uy i) *\<^sub>R i)"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1466
        using x y
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1467
        unfolding scaleR_left_distrib scaleR_zero_left if_smult
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1468
        by (simp add: sum_Un sum.distrib sum.inter_restrict[symmetric]  **)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1469
      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)"
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1470
        unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] by blast
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1471
      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) 
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1472
                  = u *\<^sub>R (\<Sum>v\<in>sx. ux v *\<^sub>R v) + v *\<^sub>R (\<Sum>v\<in>sy. uy v *\<^sub>R v)" .
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1473
    qed (use x y in auto)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1474
  qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1475
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1476
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1477
lemma affine_hull_finite:
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1478
  assumes "finite S"
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1479
  shows "affine hull S = {y. \<exists>u. sum u S = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) S = y}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1480
proof -
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1481
  have *: "\<exists>h. sum h S = 1 \<and> (\<Sum>v\<in>S. h v *\<^sub>R v) = x" 
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1482
    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
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1483
  proof -
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1484
    have "S \<inter> F = F"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1485
      using that by auto
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1486
    show ?thesis
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1487
    proof (intro exI conjI)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1488
      show "(\<Sum>x\<in>S. if x \<in> F then u x else 0) = 1"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1489
        by (metis (mono_tags, lifting) \<open>S \<inter> F = F\<close> assms sum.inter_restrict sum)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1490
      show "(\<Sum>v\<in>S. (if v \<in> F then u v else 0) *\<^sub>R v) = x"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1491
        by (simp add: if_smult cong: if_cong) (metis (no_types) \<open>S \<inter> F = F\<close> assms sum.inter_restrict x)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1492
    qed
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1493
  qed
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1494
  show ?thesis
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1495
    unfolding affine_hull_explicit using assms
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1496
    by (fastforce dest: *)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1497
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1498
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1499
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1500
subsubsection%unimportant \<open>Stepping theorems and hence small special cases\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1501
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1502
lemma affine_hull_empty[simp]: "affine hull {} = {}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1503
  by simp
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1504
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1505
lemma affine_hull_finite_step:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1506
  fixes y :: "'a::real_vector"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1507
  shows "finite S \<Longrightarrow>
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1508
      (\<exists>u. sum u (insert a S) = w \<and> sum (\<lambda>x. u x *\<^sub>R x) (insert a S) = y) \<longleftrightarrow>
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1509
      (\<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")
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1510
proof -
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1511
  assume fin: "finite S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1512
  show "?lhs = ?rhs"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1513
  proof
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1514
    assume ?lhs
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1515
    then obtain u where u: "sum u (insert a S) = w \<and> (\<Sum>x\<in>insert a S. u x *\<^sub>R x) = y"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1516
      by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1517
    show ?rhs
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1518
    proof (cases "a \<in> S")
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1519
      case True
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1520
      then show ?thesis
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1521
        using u by (simp add: insert_absorb) (metis diff_zero real_vector.scale_zero_left)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1522
    next
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1523
      case False
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1524
      show ?thesis
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1525
        by (rule exI [where x="u a"]) (use u fin False in auto)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1526
    qed
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1527
  next
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1528
    assume ?rhs
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1529
    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"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1530
      by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1531
    have *: "\<And>x M. (if x = a then v else M) *\<^sub>R x = (if x = a then v *\<^sub>R x else M *\<^sub>R x)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1532
      by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1533
    show ?lhs
68024
b5e29bf0aeab tidied some horrid proofs
paulson <lp15@cam.ac.uk>
parents: 67982
diff changeset
  1534
    proof (cases "a \<in> S")
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1535
      case True
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1536
      show ?thesis
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1537
        by (rule exI [where x="\<lambda>x. (if x=a then v else 0) + u x"])
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1538
           (simp add: True scaleR_left_distrib sum.distrib sum_clauses fin vu * cong: if_cong)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1539
    next
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1540
      case False
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1541
      then show ?thesis
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1542
        apply (rule_tac x="\<lambda>x. if x=a then v else u x" in exI) 
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1543
        apply (simp add: vu sum_clauses(2)[OF fin] *)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1544
        by (simp add: sum_delta_notmem(3) vu)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1545
    qed
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1546
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1547
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1548
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1549
lemma affine_hull_2:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1550
  fixes a b :: "'a::real_vector"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1551
  shows "affine hull {a,b} = {u *\<^sub>R a + v *\<^sub>R b| u v. (u + v = 1)}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1552
  (is "?lhs = ?rhs")
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1553
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1554
  have *:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1555
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::real)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1556
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::'a)" by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  1557
  have "?lhs = {y. \<exists>u. sum u {a, b} = 1 \<and> (\<Sum>v\<in>{a, b}. u v *\<^sub>R v) = y}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1558
    using affine_hull_finite[of "{a,b}"] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1559
  also have "\<dots> = {y. \<exists>v u. u b = 1 - v \<and> u b *\<^sub>R b = y - v *\<^sub>R a}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1560
    by (simp add: affine_hull_finite_step[of "{b}" a])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1561
  also have "\<dots> = ?rhs" unfolding * by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1562
  finally show ?thesis by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1563
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1564
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1565
lemma affine_hull_3:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1566
  fixes a b c :: "'a::real_vector"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1567
  shows "affine hull {a,b,c} = { u *\<^sub>R a + v *\<^sub>R b + w *\<^sub>R c| u v w. u + v + w = 1}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1568
proof -
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1569
  have *:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1570
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::real)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1571
    "\<And>x y z. z = x - y \<longleftrightarrow> y + z = (x::'a)" by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1572
  show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1573
    apply (simp add: affine_hull_finite affine_hull_finite_step)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1574
    unfolding *
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1575
    apply safe
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1576
     apply (metis add.assoc)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1577
    apply (rule_tac x=u in exI, force)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1578
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1579
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1580
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1581
lemma mem_affine:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1582
  assumes "affine S" "x \<in> S" "y \<in> S" "u + v = 1"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1583
  shows "u *\<^sub>R x + v *\<^sub>R y \<in> S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1584
  using assms affine_def[of S] by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1585
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1586
lemma mem_affine_3:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1587
  assumes "affine S" "x \<in> S" "y \<in> S" "z \<in> S" "u + v + w = 1"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1588
  shows "u *\<^sub>R x + v *\<^sub>R y + w *\<^sub>R z \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1589
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1590
  have "u *\<^sub>R x + v *\<^sub>R y + w *\<^sub>R z \<in> affine hull {x, y, z}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1591
    using affine_hull_3[of x y z] assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1592
  moreover
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1593
  have "affine hull {x, y, z} \<subseteq> affine hull S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1594
    using hull_mono[of "{x, y, z}" "S"] assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1595
  moreover
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1596
  have "affine hull S = S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1597
    using assms affine_hull_eq[of S] by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1598
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1599
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1600
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1601
lemma mem_affine_3_minus:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1602
  assumes "affine S" "x \<in> S" "y \<in> S" "z \<in> S"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1603
  shows "x + v *\<^sub>R (y-z) \<in> S"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1604
  using mem_affine_3[of S x y z 1 v "-v"] assms
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1605
  by (simp add: algebra_simps)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1606
60307
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  1607
corollary mem_affine_3_minus2:
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  1608
    "\<lbrakk>affine S; x \<in> S; y \<in> S; z \<in> S\<rbrakk> \<Longrightarrow> x - v *\<^sub>R (y-z) \<in> S"
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  1609
  by (metis add_uminus_conv_diff mem_affine_3_minus real_vector.scale_minus_left)
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  1610
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1611
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1612
subsubsection%unimportant \<open>Some relations between affine hull and subspaces\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1613
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1614
lemma affine_hull_insert_subset_span:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1615
  "affine hull (insert a S) \<subseteq> {a + v| v . v \<in> span {x - a | x . x \<in> S}}"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1616
proof -
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1617
  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)"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1618
    if "finite F" "F \<noteq> {}" "F \<subseteq> insert a S" "sum u F = 1" "(\<Sum>v\<in>F. u v *\<^sub>R v) = x"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1619
    for x F u
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1620
  proof -
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1621
    have *: "(\<lambda>x. x - a) ` (F - {a}) \<subseteq> {x - a |x. x \<in> S}"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1622
      using that by auto
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1623
    show ?thesis
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1624
    proof (intro exI conjI)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1625
      show "finite ((\<lambda>x. x - a) ` (F - {a}))"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1626
        by (simp add: that(1))
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1627
      show "(\<Sum>v\<in>(\<lambda>x. x - a) ` (F - {a}). u(v+a) *\<^sub>R v) = x-a"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1628
        by (simp add: sum.reindex[unfolded inj_on_def] algebra_simps
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1629
            sum_subtractf scaleR_left.sum[symmetric] sum_diff1 that)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1630
    qed (use \<open>F \<subseteq> insert a S\<close> in auto)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1631
  qed
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1632
  then show ?thesis
68074
8d50467f7555 fixed HOL-Analysis
immler
parents: 68073
diff changeset
  1633
    unfolding affine_hull_explicit span_explicit by blast
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1634
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1635
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1636
lemma affine_hull_insert_span:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1637
  assumes "a \<notin> S"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1638
  shows "affine hull (insert a S) = {a + v | v . v \<in> span {x - a | x.  x \<in> S}}"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1639
proof -
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1640
  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"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1641
    if "v \<in> span {x - a |x. x \<in> S}" "y = a + v" for y v
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1642
  proof -
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1643
    from that
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1644
    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"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1645
      unfolding span_explicit by auto
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1646
    define F where "F = (\<lambda>x. x + a) ` T"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1647
    have F: "finite F" "F \<subseteq> S" "(\<Sum>v\<in>F. u (v - a) *\<^sub>R (v - a)) = y - a"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1648
      unfolding F_def using u by (auto simp: sum.reindex[unfolded inj_on_def])
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1649
    have *: "F \<inter> {a} = {}" "F \<inter> - {a} = F"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1650
      using F assms by auto
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1651
    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"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1652
      apply (rule_tac x = "insert a F" in exI)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1653
      apply (rule_tac x = "\<lambda>x. if x=a then 1 - sum (\<lambda>x. u (x - a)) F else u (x - a)" in exI)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1654
      using assms F
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1655
      apply (auto simp:  sum_clauses sum.If_cases if_smult sum_subtractf scaleR_left.sum algebra_simps *)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1656
      done
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1657
  qed
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1658
  show ?thesis
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1659
    by (intro subset_antisym affine_hull_insert_subset_span) (auto simp: affine_hull_explicit dest!: *)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1660
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1661
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1662
lemma affine_hull_span:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1663
  assumes "a \<in> S"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1664
  shows "affine hull S = {a + v | v. v \<in> span {x - a | x. x \<in> S - {a}}}"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1665
  using affine_hull_insert_span[of a "S - {a}", unfolded insert_Diff[OF assms]] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1666
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1667
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1668
subsubsection%unimportant \<open>Parallel affine sets\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1669
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1670
definition affine_parallel :: "'a::real_vector set \<Rightarrow> 'a::real_vector set \<Rightarrow> bool"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1671
  where "affine_parallel S T \<longleftrightarrow> (\<exists>a. T = (\<lambda>x. a + x) ` S)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1672
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1673
lemma affine_parallel_expl_aux:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1674
  fixes S T :: "'a::real_vector set"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1675
  assumes "\<And>x. x \<in> S \<longleftrightarrow> a + x \<in> T"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1676
  shows "T = (\<lambda>x. a + x) ` S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1677
proof -
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1678
  have "x \<in> ((\<lambda>x. a + x) ` S)" if "x \<in> T" for x
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1679
    using that
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1680
    by (simp add: image_iff) (metis add.commute diff_add_cancel assms)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1681
  moreover have "T \<ge> (\<lambda>x. a + x) ` S"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1682
    using assms by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1683
  ultimately show ?thesis by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1684
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1685
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1686
lemma affine_parallel_expl: "affine_parallel S T \<longleftrightarrow> (\<exists>a. \<forall>x. x \<in> S \<longleftrightarrow> a + x \<in> T)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1687
  unfolding affine_parallel_def
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1688
  using affine_parallel_expl_aux[of S _ T] by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1689
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1690
lemma affine_parallel_reflex: "affine_parallel S S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1691
  unfolding affine_parallel_def
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  1692
  using image_add_0 by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1693
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1694
lemma affine_parallel_commut:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1695
  assumes "affine_parallel A B"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1696
  shows "affine_parallel B A"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1697
proof -
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  1698
  from assms obtain a where B: "B = (\<lambda>x. a + x) ` A"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1699
    unfolding affine_parallel_def by auto
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  1700
  have [simp]: "(\<lambda>x. x - a) = plus (- a)" by (simp add: fun_eq_iff)
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  1701
  from B show ?thesis
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1702
    using translation_galois [of B a A]
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1703
    unfolding affine_parallel_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1704
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1705
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1706
lemma affine_parallel_assoc:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1707
  assumes "affine_parallel A B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1708
    and "affine_parallel B C"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1709
  shows "affine_parallel A C"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1710
proof -
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1711
  from assms obtain ab where "B = (\<lambda>x. ab + x) ` A"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1712
    unfolding affine_parallel_def by auto
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1713
  moreover
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1714
  from assms obtain bc where "C = (\<lambda>x. bc + x) ` B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1715
    unfolding affine_parallel_def by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1716
  ultimately show ?thesis
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1717
    using translation_assoc[of bc ab A] unfolding affine_parallel_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1718
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1719
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1720
lemma affine_translation_aux:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1721
  fixes a :: "'a::real_vector"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1722
  assumes "affine ((\<lambda>x. a + x) ` S)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1723
  shows "affine S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1724
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1725
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1726
    fix x y u v
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1727
    assume xy: "x \<in> S" "y \<in> S" "(u :: real) + v = 1"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1728
    then have "(a + x) \<in> ((\<lambda>x. a + x) ` S)" "(a + y) \<in> ((\<lambda>x. a + x) ` S)"
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1729
      by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1730
    then have h1: "u *\<^sub>R  (a + x) + v *\<^sub>R (a + y) \<in> (\<lambda>x. a + x) ` S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1731
      using xy assms unfolding affine_def by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1732
    have "u *\<^sub>R (a + x) + v *\<^sub>R (a + y) = (u + v) *\<^sub>R a + (u *\<^sub>R x + v *\<^sub>R y)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1733
      by (simp add: algebra_simps)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1734
    also have "\<dots> = a + (u *\<^sub>R x + v *\<^sub>R y)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1735
      using \<open>u + v = 1\<close> by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1736
    ultimately have "a + (u *\<^sub>R x + v *\<^sub>R y) \<in> (\<lambda>x. a + x) ` S"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1737
      using h1 by auto
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
  1738
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> S" by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1739
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1740
  then show ?thesis unfolding affine_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1741
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1742
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1743
lemma affine_translation:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1744
  fixes a :: "'a::real_vector"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1745
  shows "affine S \<longleftrightarrow> affine ((\<lambda>x. a + x) ` S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1746
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1747
  have "affine S \<Longrightarrow> affine ((\<lambda>x. a + x) ` S)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1748
    using affine_translation_aux[of "-a" "((\<lambda>x. a + x) ` S)"]
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1749
    using translation_assoc[of "-a" a S] by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1750
  then show ?thesis using affine_translation_aux by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1751
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1752
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1753
lemma parallel_is_affine:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1754
  fixes S T :: "'a::real_vector set"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1755
  assumes "affine S" "affine_parallel S T"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1756
  shows "affine T"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1757
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1758
  from assms obtain a where "T = (\<lambda>x. a + x) ` S"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1759
    unfolding affine_parallel_def by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1760
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1761
    using affine_translation assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1762
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1763
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  1764
lemma subspace_imp_affine: "subspace s \<Longrightarrow> affine s"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1765
  unfolding subspace_def affine_def by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1766
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1767
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1768
subsubsection%unimportant \<open>Subspace parallel to an affine set\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1769
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1770
lemma subspace_affine: "subspace S \<longleftrightarrow> affine S \<and> 0 \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1771
proof -
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1772
  have h0: "subspace S \<Longrightarrow> affine S \<and> 0 \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1773
    using subspace_imp_affine[of S] subspace_0 by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1774
  {
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1775
    assume assm: "affine S \<and> 0 \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1776
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1777
      fix c :: real
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1778
      fix x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1779
      assume x: "x \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1780
      have "c *\<^sub>R x = (1-c) *\<^sub>R 0 + c *\<^sub>R x" by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1781
      moreover
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1782
      have "(1 - c) *\<^sub>R 0 + c *\<^sub>R x \<in> S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1783
        using affine_alt[of S] assm x by auto
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1784
      ultimately have "c *\<^sub>R x \<in> S" by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1785
    }
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1786
    then have h1: "\<forall>c. \<forall>x \<in> S. c *\<^sub>R x \<in> S" by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1787
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1788
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1789
      fix x y
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1790
      assume xy: "x \<in> S" "y \<in> S"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  1791
      define u where "u = (1 :: real)/2"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1792
      have "(1/2) *\<^sub>R (x+y) = (1/2) *\<^sub>R (x+y)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1793
        by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1794
      moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1795
      have "(1/2) *\<^sub>R (x+y)=(1/2) *\<^sub>R x + (1-(1/2)) *\<^sub>R y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1796
        by (simp add: algebra_simps)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1797
      moreover
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1798
      have "(1 - u) *\<^sub>R x + u *\<^sub>R y \<in> S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1799
        using affine_alt[of S] assm xy by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1800
      ultimately
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1801
      have "(1/2) *\<^sub>R (x+y) \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1802
        using u_def by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1803
      moreover
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1804
      have "x + y = 2 *\<^sub>R ((1/2) *\<^sub>R (x+y))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1805
        by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1806
      ultimately
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1807
      have "x + y \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1808
        using h1[rule_format, of "(1/2) *\<^sub>R (x+y)" "2"] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1809
    }
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1810
    then have "\<forall>x \<in> S. \<forall>y \<in> S. x + y \<in> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1811
      by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1812
    then have "subspace S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1813
      using h1 assm unfolding subspace_def by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1814
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1815
  then show ?thesis using h0 by metis
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1816
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1817
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1818
lemma affine_diffs_subspace:
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1819
  assumes "affine S" "a \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1820
  shows "subspace ((\<lambda>x. (-a)+x) ` S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1821
proof -
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  1822
  have [simp]: "(\<lambda>x. x - a) = plus (- a)" by (simp add: fun_eq_iff)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1823
  have "affine ((\<lambda>x. (-a)+x) ` S)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1824
    using  affine_translation assms by auto
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
  1825
  moreover have "0 \<in> ((\<lambda>x. (-a)+x) ` S)"
53333
e9dba6602a84 tuned proofs;
wenzelm
parents: 53302
diff changeset
  1826
    using assms exI[of "(\<lambda>x. x\<in>S \<and> -a+x = 0)" a] by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1827
  ultimately show ?thesis using subspace_affine by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1828
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1829
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1830
lemma parallel_subspace_explicit:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1831
  assumes "affine S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1832
    and "a \<in> S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1833
  assumes "L \<equiv> {y. \<exists>x \<in> S. (-a) + x = y}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1834
  shows "subspace L \<and> affine_parallel S L"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1835
proof -
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  1836
  from assms have "L = plus (- a) ` S" by auto
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  1837
  then have par: "affine_parallel S L"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1838
    unfolding affine_parallel_def ..
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1839
  then have "affine L" using assms parallel_is_affine by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1840
  moreover have "0 \<in> L"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  1841
    using assms by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1842
  ultimately show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1843
    using subspace_affine par by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1844
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1845
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1846
lemma parallel_subspace_aux:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1847
  assumes "subspace A"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1848
    and "subspace B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1849
    and "affine_parallel A B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1850
  shows "A \<supseteq> B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1851
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1852
  from assms obtain a where a: "\<forall>x. x \<in> A \<longleftrightarrow> a + x \<in> B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1853
    using affine_parallel_expl[of A B] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1854
  then have "-a \<in> A"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1855
    using assms subspace_0[of B] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1856
  then have "a \<in> A"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1857
    using assms subspace_neg[of A "-a"] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1858
  then show ?thesis
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1859
    using assms a unfolding subspace_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1860
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1861
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1862
lemma parallel_subspace:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1863
  assumes "subspace A"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1864
    and "subspace B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1865
    and "affine_parallel A B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1866
  shows "A = B"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1867
proof
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1868
  show "A \<supseteq> B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1869
    using assms parallel_subspace_aux by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1870
  show "A \<subseteq> B"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1871
    using assms parallel_subspace_aux[of B A] affine_parallel_commut by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1872
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1873
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1874
lemma affine_parallel_subspace:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1875
  assumes "affine S" "S \<noteq> {}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1876
  shows "\<exists>!L. subspace L \<and> affine_parallel S L"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1877
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1878
  have ex: "\<exists>L. subspace L \<and> affine_parallel S L"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  1879
    using assms parallel_subspace_explicit by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1880
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1881
    fix L1 L2
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1882
    assume ass: "subspace L1 \<and> affine_parallel S L1" "subspace L2 \<and> affine_parallel S L2"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1883
    then have "affine_parallel L1 L2"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1884
      using affine_parallel_commut[of S L1] affine_parallel_assoc[of L1 S L2] by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1885
    then have "L1 = L2"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1886
      using ass parallel_subspace by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1887
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1888
  then show ?thesis using ex by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1889
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1890
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1891
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1892
subsection \<open>Cones\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1893
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1894
definition%important cone :: "'a::real_vector set \<Rightarrow> bool"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1895
  where "cone s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>c\<ge>0. c *\<^sub>R x \<in> s)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1896
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1897
lemma cone_empty[intro, simp]: "cone {}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1898
  unfolding cone_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1899
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1900
lemma cone_univ[intro, simp]: "cone UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1901
  unfolding cone_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1902
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  1903
lemma cone_Inter[intro]: "\<forall>s\<in>f. cone s \<Longrightarrow> cone (\<Inter>f)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1904
  unfolding cone_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1905
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  1906
lemma subspace_imp_cone: "subspace S \<Longrightarrow> cone S"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  1907
  by (simp add: cone_def subspace_scale)
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  1908
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1909
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1910
subsubsection \<open>Conic hull\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1911
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1912
lemma cone_cone_hull: "cone (cone hull s)"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  1913
  unfolding hull_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1914
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1915
lemma cone_hull_eq: "cone hull s = s \<longleftrightarrow> cone s"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1916
  apply (rule hull_eq)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1917
  using cone_Inter
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1918
  unfolding subset_eq
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1919
  apply auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1920
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1921
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1922
lemma mem_cone:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1923
  assumes "cone S" "x \<in> S" "c \<ge> 0"
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
  1924
  shows "c *\<^sub>R x \<in> S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1925
  using assms cone_def[of S] by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1926
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1927
lemma cone_contains_0:
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1928
  assumes "cone S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1929
  shows "S \<noteq> {} \<longleftrightarrow> 0 \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1930
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1931
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1932
    assume "S \<noteq> {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1933
    then obtain a where "a \<in> S" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1934
    then have "0 \<in> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1935
      using assms mem_cone[of S a 0] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1936
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1937
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1938
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1939
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  1940
lemma cone_0: "cone {0}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1941
  unfolding cone_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1942
61952
546958347e05 prefer symbols for "Union", "Inter";
wenzelm
parents: 61945
diff changeset
  1943
lemma cone_Union[intro]: "(\<forall>s\<in>f. cone s) \<longrightarrow> cone (\<Union>f)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1944
  unfolding cone_def by blast
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1945
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1946
lemma cone_iff:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1947
  assumes "S \<noteq> {}"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1948
  shows "cone S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (( *\<^sub>R) c) ` S = S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1949
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1950
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1951
    assume "cone S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1952
    {
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1953
      fix c :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1954
      assume "c > 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1955
      {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1956
        fix x
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1957
        assume "x \<in> S"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1958
        then have "x \<in> (( *\<^sub>R) c) ` S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1959
          unfolding image_def
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1960
          using \<open>cone S\<close> \<open>c>0\<close> mem_cone[of S x "1/c"]
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  1961
            exI[of "(\<lambda>t. t \<in> S \<and> x = c *\<^sub>R t)" "(1 / c) *\<^sub>R x"]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1962
          by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1963
      }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1964
      moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1965
      {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1966
        fix x
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1967
        assume "x \<in> (( *\<^sub>R) c) ` S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1968
        then have "x \<in> S"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1969
          using \<open>cone S\<close> \<open>c > 0\<close>
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1970
          unfolding cone_def image_def \<open>c > 0\<close> by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1971
      }
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1972
      ultimately have "(( *\<^sub>R) c) ` S = S" by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1973
    }
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1974
    then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (( *\<^sub>R) c) ` S = S)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1975
      using \<open>cone S\<close> cone_contains_0[of S] assms by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1976
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1977
  moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1978
  {
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  1979
    assume a: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> (( *\<^sub>R) c) ` S = S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1980
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1981
      fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1982
      assume "x \<in> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1983
      fix c1 :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1984
      assume "c1 \<ge> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  1985
      then have "c1 = 0 \<or> c1 > 0" by auto
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1986
      then have "c1 *\<^sub>R x \<in> S" using a \<open>x \<in> S\<close> by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1987
    }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1988
    then have "cone S" unfolding cone_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  1989
  }
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1990
  ultimately show ?thesis by blast
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1991
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1992
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1993
lemma cone_hull_empty: "cone hull {} = {}"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1994
  by (metis cone_empty cone_hull_eq)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1995
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1996
lemma cone_hull_empty_iff: "S = {} \<longleftrightarrow> cone hull S = {}"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1997
  by (metis bot_least cone_hull_empty hull_subset xtrans(5))
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  1998
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1999
lemma cone_hull_contains_0: "S \<noteq> {} \<longleftrightarrow> 0 \<in> cone hull S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2000
  using cone_cone_hull[of S] cone_contains_0[of "cone hull S"] cone_hull_empty_iff[of S]
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2001
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2002
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2003
lemma mem_cone_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2004
  assumes "x \<in> S" "c \<ge> 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2005
  shows "c *\<^sub>R x \<in> cone hull S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2006
  by (metis assms cone_cone_hull hull_inc mem_cone)
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2007
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2008
proposition%important cone_hull_expl: "cone hull S = {c *\<^sub>R x | c x. c \<ge> 0 \<and> x \<in> S}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2009
  (is "?lhs = ?rhs")
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2010
proof%unimportant -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2011
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2012
    fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2013
    assume "x \<in> ?rhs"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2014
    then obtain cx :: real and xx where x: "x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2015
      by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2016
    fix c :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2017
    assume c: "c \<ge> 0"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2018
    then have "c *\<^sub>R x = (c * cx) *\<^sub>R xx"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2019
      using x by (simp add: algebra_simps)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2020
    moreover
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  2021
    have "c * cx \<ge> 0" using c x by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2022
    ultimately
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2023
    have "c *\<^sub>R x \<in> ?rhs" using x by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2024
  }
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2025
  then have "cone ?rhs"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2026
    unfolding cone_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2027
  then have "?rhs \<in> Collect cone"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2028
    unfolding mem_Collect_eq by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2029
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2030
    fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2031
    assume "x \<in> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2032
    then have "1 *\<^sub>R x \<in> ?rhs"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2033
      apply auto
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2034
      apply (rule_tac x = 1 in exI, auto)
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2035
      done
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2036
    then have "x \<in> ?rhs" by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2037
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2038
  then have "S \<subseteq> ?rhs" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2039
  then have "?lhs \<subseteq> ?rhs"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2040
    using \<open>?rhs \<in> Collect cone\<close> hull_minimal[of S "?rhs" "cone"] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2041
  moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2042
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2043
    fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2044
    assume "x \<in> ?rhs"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2045
    then obtain cx :: real and xx where x: "x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2046
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2047
    then have "xx \<in> cone hull S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2048
      using hull_subset[of S] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2049
    then have "x \<in> ?lhs"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2050
      using x cone_cone_hull[of S] cone_def[of "cone hull S"] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2051
  }
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2052
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2053
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2054
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2055
lemma cone_closure:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2056
  fixes S :: "'a::real_normed_vector set"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2057
  assumes "cone S"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2058
  shows "cone (closure S)"
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2059
proof (cases "S = {}")
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2060
  case True
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2061
  then show ?thesis by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2062
next
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2063
  case False
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  2064
  then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ( *\<^sub>R) c ` S = S)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2065
    using cone_iff[of S] assms by auto
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  2066
  then have "0 \<in> closure S \<and> (\<forall>c. c > 0 \<longrightarrow> ( *\<^sub>R) c ` closure S = closure S)"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2067
    using closure_subset by (auto simp: closure_scaleR)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2068
  then show ?thesis
60974
6a6f15d8fbc4 New material and fixes related to the forthcoming Stone-Weierstrass development
paulson <lp15@cam.ac.uk>
parents: 60809
diff changeset
  2069
    using False cone_iff[of "closure S"] by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2070
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2071
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2072
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2073
subsection \<open>Affine dependence and consequential theorems (from Lars Schewe)\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2074
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2075
definition%important affine_dependent :: "'a::real_vector set \<Rightarrow> bool"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2076
  where "affine_dependent s \<longleftrightarrow> (\<exists>x\<in>s. x \<in> affine hull (s - {x}))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2077
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2078
lemma affine_dependent_subset:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2079
   "\<lbrakk>affine_dependent s; s \<subseteq> t\<rbrakk> \<Longrightarrow> affine_dependent t"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2080
apply (simp add: affine_dependent_def Bex_def)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2081
apply (blast dest: hull_mono [OF Diff_mono [OF _ subset_refl]])
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2082
done
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2083
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2084
lemma affine_independent_subset:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2085
  shows "\<lbrakk>~ affine_dependent t; s \<subseteq> t\<rbrakk> \<Longrightarrow> ~ affine_dependent s"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2086
by (metis affine_dependent_subset)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2087
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2088
lemma affine_independent_Diff:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2089
   "~ affine_dependent s \<Longrightarrow> ~ affine_dependent(s - t)"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2090
by (meson Diff_subset affine_dependent_subset)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2091
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2092
proposition%important affine_dependent_explicit:
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2093
  "affine_dependent p \<longleftrightarrow>
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2094
    (\<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)"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2095
proof -
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2096
  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"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2097
    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
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2098
  proof (intro exI conjI)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2099
    have "x \<notin> S" 
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2100
      using that by auto
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2101
    then show "(\<Sum>v \<in> insert x S. if v = x then - 1 else u v) = 0"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2102
      using that by (simp add: sum_delta_notmem)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2103
    show "(\<Sum>w \<in> insert x S. (if w = x then - 1 else u w) *\<^sub>R w) = 0"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2104
      using that \<open>x \<notin> S\<close> by (simp add: if_smult sum_delta_notmem cong: if_cong)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2105
  qed (use that in auto)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2106
  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"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2107
    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
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2108
  proof (intro bexI exI conjI)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2109
    have "S \<noteq> {v}"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2110
      using that by auto
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2111
    then show "S - {v} \<noteq> {}"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2112
      using that by auto
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2113
    show "(\<Sum>x \<in> S - {v}. - (1 / u v) * u x) = 1"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2114
      unfolding sum_distrib_left[symmetric] sum_diff1[OF \<open>finite S\<close>] by (simp add: that)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2115
    show "(\<Sum>x\<in>S - {v}. (- (1 / u v) * u x) *\<^sub>R x) = v"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2116
      unfolding sum_distrib_left [symmetric] scaleR_scaleR[symmetric]
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2117
                scaleR_right.sum [symmetric] sum_diff1[OF \<open>finite S\<close>] 
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2118
      using that by auto
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2119
    show "S - {v} \<subseteq> p - {v}"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2120
      using that by auto
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2121
  qed (use that in auto)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2122
  ultimately show ?thesis
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2123
    unfolding affine_dependent_def affine_hull_explicit by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2124
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2125
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2126
lemma affine_dependent_explicit_finite:
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2127
  fixes S :: "'a::real_vector set"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2128
  assumes "finite S"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2129
  shows "affine_dependent S \<longleftrightarrow>
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2130
    (\<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)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2131
  (is "?lhs = ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2132
proof
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2133
  have *: "\<And>vt u v. (if vt then u v else 0) *\<^sub>R v = (if vt then (u v) *\<^sub>R v else 0::'a)"
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2134
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2135
  assume ?lhs
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2136
  then obtain t u v where
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2137
    "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"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2138
    unfolding affine_dependent_explicit by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2139
  then show ?rhs
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2140
    apply (rule_tac x="\<lambda>x. if x\<in>t then u x else 0" in exI)
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2141
    apply (auto simp: * sum.inter_restrict[OF assms, symmetric] Int_absorb1[OF \<open>t\<subseteq>S\<close>])
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2142
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2143
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2144
  assume ?rhs
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2145
  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"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2146
    by auto
49529
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2147
  then show ?lhs unfolding affine_dependent_explicit
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2148
    using assms by auto
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2149
qed
d523702bdae7 tuned proofs;
wenzelm
parents: 47445
diff changeset
  2150
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2151
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2152
subsection%unimportant \<open>Connectedness of convex sets\<close>
44465
fa56622bb7bc move connected_real_lemma to the one place it is used
huffman
parents: 44457
diff changeset
  2153
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2154
lemma connectedD:
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2155
  "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 = {}"
61426
d53db136e8fd new material on path_component_sets, inside, outside, etc. And more default simprules
paulson <lp15@cam.ac.uk>
parents: 61222
diff changeset
  2156
  by (rule Topological_Spaces.topological_space_class.connectedD)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2157
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2158
lemma convex_connected:
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2159
  fixes S :: "'a::real_normed_vector set"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2160
  assumes "convex S"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2161
  shows "connected S"
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2162
proof (rule connectedI)
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2163
  fix A B
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2164
  assume "open A" "open B" "A \<inter> B \<inter> S = {}" "S \<subseteq> A \<union> B"
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2165
  moreover
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2166
  assume "A \<inter> S \<noteq> {}" "B \<inter> S \<noteq> {}"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2167
  then obtain a b where a: "a \<in> A" "a \<in> S" and b: "b \<in> B" "b \<in> S" by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  2168
  define f where [abs_def]: "f u = u *\<^sub>R a + (1 - u) *\<^sub>R b" for u
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2169
  then have "continuous_on {0 .. 1} f"
56371
fb9ae0727548 extend continuous_intros; remove continuous_on_intros and isCont_intros
hoelzl
parents: 56369
diff changeset
  2170
    by (auto intro!: continuous_intros)
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2171
  then have "connected (f ` {0 .. 1})"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2172
    by (auto intro!: connected_continuous_image)
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2173
  note connectedD[OF this, of A B]
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2174
  moreover have "a \<in> A \<inter> f ` {0 .. 1}"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2175
    using a by (auto intro!: image_eqI[of _ _ 1] simp: f_def)
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2176
  moreover have "b \<in> B \<inter> f ` {0 .. 1}"
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2177
    using b by (auto intro!: image_eqI[of _ _ 0] simp: f_def)
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2178
  moreover have "f ` {0 .. 1} \<subseteq> S"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2179
    using \<open>convex S\<close> a b unfolding convex_def f_def by auto
51480
3793c3a11378 move connected to HOL image; used to show intermediate value theorem
hoelzl
parents: 51475
diff changeset
  2180
  ultimately show False by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2181
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2182
61426
d53db136e8fd new material on path_component_sets, inside, outside, etc. And more default simprules
paulson <lp15@cam.ac.uk>
parents: 61222
diff changeset
  2183
corollary connected_UNIV[intro]: "connected (UNIV :: 'a::real_normed_vector set)"
66939
04678058308f New results in topology, mostly from HOL Light's moretop.ml
paulson <lp15@cam.ac.uk>
parents: 66884
diff changeset
  2184
  by (simp add: convex_connected)
04678058308f New results in topology, mostly from HOL Light's moretop.ml
paulson <lp15@cam.ac.uk>
parents: 66884
diff changeset
  2185
04678058308f New results in topology, mostly from HOL Light's moretop.ml
paulson <lp15@cam.ac.uk>
parents: 66884
diff changeset
  2186
corollary component_complement_connected:
04678058308f New results in topology, mostly from HOL Light's moretop.ml
paulson <lp15@cam.ac.uk>
parents: 66884
diff changeset
  2187
  fixes S :: "'a::real_normed_vector set"
04678058308f New results in topology, mostly from HOL Light's moretop.ml
paulson <lp15@cam.ac.uk>
parents: 66884
diff changeset
  2188
  assumes "connected S" "C \<in> components (-S)"
04678058308f New results in topology, mostly from HOL Light's moretop.ml
paulson <lp15@cam.ac.uk>
parents: 66884
diff changeset
  2189
  shows "connected(-C)"
04678058308f New results in topology, mostly from HOL Light's moretop.ml
paulson <lp15@cam.ac.uk>
parents: 66884
diff changeset
  2190
  using component_diff_connected [of S UNIV] assms
04678058308f New results in topology, mostly from HOL Light's moretop.ml
paulson <lp15@cam.ac.uk>
parents: 66884
diff changeset
  2191
  by (auto simp: Compl_eq_Diff_UNIV)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2192
62131
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62097
diff changeset
  2193
proposition clopen:
66884
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  2194
  fixes S :: "'a :: real_normed_vector set"
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  2195
  shows "closed S \<and> open S \<longleftrightarrow> S = {} \<or> S = UNIV"
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  2196
    by (force intro!: connected_UNIV [unfolded connected_clopen, rule_format])
62131
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62097
diff changeset
  2197
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62097
diff changeset
  2198
corollary compact_open:
66884
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  2199
  fixes S :: "'a :: euclidean_space set"
c2128ab11f61 Switching to inverse image and constant_on, plus some new material
paulson <lp15@cam.ac.uk>
parents: 66827
diff changeset
  2200
  shows "compact S \<and> open S \<longleftrightarrow> S = {}"
62131
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62097
diff changeset
  2201
  by (auto simp: compact_eq_bounded_closed clopen)
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62097
diff changeset
  2202
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  2203
corollary finite_imp_not_open:
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  2204
    fixes S :: "'a::{real_normed_vector, perfect_space} set"
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  2205
    shows "\<lbrakk>finite S; open S\<rbrakk> \<Longrightarrow> S={}"
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  2206
  using clopen [of S] finite_imp_closed not_bounded_UNIV by blast
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  2207
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2208
corollary empty_interior_finite:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2209
    fixes S :: "'a::{real_normed_vector, perfect_space} set"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2210
    shows "finite S \<Longrightarrow> interior S = {}"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2211
  by (metis interior_subset finite_subset open_interior [of S] finite_imp_not_open)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2212
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2213
text \<open>Balls, being convex, are connected.\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2214
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  2215
lemma convex_prod:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2216
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> convex {x. P i x}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2217
  shows "convex {x. \<forall>i\<in>Basis. P i (x\<bullet>i)}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2218
  using assms unfolding convex_def
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2219
  by (auto simp: inner_add_left)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2220
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  2221
lemma convex_positive_orthant: "convex {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i)}"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  2222
  by (rule convex_prod) (simp add: atLeast_def[symmetric] convex_real_interval)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2223
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2224
lemma convex_local_global_minimum:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2225
  fixes s :: "'a::real_normed_vector set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2226
  assumes "e > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2227
    and "convex_on s f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2228
    and "ball x e \<subseteq> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2229
    and "\<forall>y\<in>ball x e. f x \<le> f y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2230
  shows "\<forall>y\<in>s. f x \<le> f y"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2231
proof (rule ccontr)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2232
  have "x \<in> s" using assms(1,3) by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2233
  assume "\<not> ?thesis"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2234
  then obtain y where "y\<in>s" and y: "f x > f y" by auto
62087
44841d07ef1d revisions to limits and derivatives, plus new lemmas
paulson
parents: 61952
diff changeset
  2235
  then have xy: "0 < dist x y"  by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2236
  then obtain u where "0 < u" "u \<le> 1" and u: "u < e / dist x y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2237
    using real_lbound_gt_zero[of 1 "e / dist x y"] xy \<open>e>0\<close> by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2238
  then have "f ((1-u) *\<^sub>R x + u *\<^sub>R y) \<le> (1-u) * f x + u * f y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2239
    using \<open>x\<in>s\<close> \<open>y\<in>s\<close>
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2240
    using assms(2)[unfolded convex_on_def,
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2241
      THEN bspec[where x=x], THEN bspec[where x=y], THEN spec[where x="1-u"]]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2242
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2243
  moreover
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2244
  have *: "x - ((1 - u) *\<^sub>R x + u *\<^sub>R y) = u *\<^sub>R (x - y)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2245
    by (simp add: algebra_simps)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2246
  have "(1 - u) *\<^sub>R x + u *\<^sub>R y \<in> ball x e"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2247
    unfolding mem_ball dist_norm
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2248
    unfolding * and norm_scaleR and abs_of_pos[OF \<open>0<u\<close>]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2249
    unfolding dist_norm[symmetric]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2250
    using u
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2251
    unfolding pos_less_divide_eq[OF xy]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2252
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2253
  then have "f x \<le> f ((1 - u) *\<^sub>R x + u *\<^sub>R y)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2254
    using assms(4) by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2255
  ultimately show False
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2256
    using mult_strict_left_mono[OF y \<open>u>0\<close>]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2257
    unfolding left_diff_distrib
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2258
    by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2259
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2260
60800
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  2261
lemma convex_ball [iff]:
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2262
  fixes x :: "'a::real_normed_vector"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2263
  shows "convex (ball x e)"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2264
proof (auto simp: convex_def)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2265
  fix y z
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2266
  assume yz: "dist x y < e" "dist x z < e"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2267
  fix u v :: real
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2268
  assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2269
  have "dist x (u *\<^sub>R y + v *\<^sub>R z) \<le> u * dist x y + v * dist x z"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2270
    using uv yz
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2271
    using convex_on_dist [of "ball x e" x, unfolded convex_on_def,
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2272
      THEN bspec[where x=y], THEN bspec[where x=z]]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2273
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2274
  then show "dist x (u *\<^sub>R y + v *\<^sub>R z) < e"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2275
    using convex_bound_lt[OF yz uv] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2276
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2277
60800
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  2278
lemma convex_cball [iff]:
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2279
  fixes x :: "'a::real_normed_vector"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2280
  shows "convex (cball x e)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2281
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2282
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2283
    fix y z
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2284
    assume yz: "dist x y \<le> e" "dist x z \<le> e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2285
    fix u v :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2286
    assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2287
    have "dist x (u *\<^sub>R y + v *\<^sub>R z) \<le> u * dist x y + v * dist x z"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2288
      using uv yz
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2289
      using convex_on_dist [of "cball x e" x, unfolded convex_on_def,
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2290
        THEN bspec[where x=y], THEN bspec[where x=z]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2291
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2292
    then have "dist x (u *\<^sub>R y + v *\<^sub>R z) \<le> e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2293
      using convex_bound_le[OF yz uv] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2294
  }
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2295
  then show ?thesis by (auto simp: convex_def Ball_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2296
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2297
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  2298
lemma connected_ball [iff]:
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2299
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2300
  shows "connected (ball x e)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2301
  using convex_connected convex_ball by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2302
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  2303
lemma connected_cball [iff]:
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2304
  fixes x :: "'a::real_normed_vector"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2305
  shows "connected (cball x e)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2306
  using convex_connected convex_cball by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2307
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2308
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2309
subsection \<open>Convex hull\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2310
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60585
diff changeset
  2311
lemma convex_convex_hull [iff]: "convex (convex hull s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2312
  unfolding hull_def
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2313
  using convex_Inter[of "{t. convex t \<and> s \<subseteq> t}"]
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  2314
  by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2315
63016
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  2316
lemma convex_hull_subset:
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  2317
    "s \<subseteq> convex hull t \<Longrightarrow> convex hull s \<subseteq> convex hull t"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  2318
  by (simp add: convex_convex_hull subset_hull)
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  2319
34064
eee04bbbae7e avoid dependency on implicit dest rule predicate1D in proofs
haftmann
parents: 33758
diff changeset
  2320
lemma convex_hull_eq: "convex hull s = s \<longleftrightarrow> convex s"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2321
  by (metis convex_convex_hull hull_same)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2322
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2323
lemma bounded_convex_hull:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2324
  fixes s :: "'a::real_normed_vector set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2325
  assumes "bounded s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2326
  shows "bounded (convex hull s)"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2327
proof -
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2328
  from assms obtain B where B: "\<forall>x\<in>s. norm x \<le> B"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2329
    unfolding bounded_iff by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2330
  show ?thesis
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2331
    apply (rule bounded_subset[OF bounded_cball, of _ 0 B])
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  2332
    unfolding subset_hull[of convex, OF convex_cball]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2333
    unfolding subset_eq mem_cball dist_norm using B
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2334
    apply auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2335
    done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2336
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2337
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2338
lemma finite_imp_bounded_convex_hull:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2339
  fixes s :: "'a::real_normed_vector set"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2340
  shows "finite s \<Longrightarrow> bounded (convex hull s)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2341
  using bounded_convex_hull finite_imp_bounded
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2342
  by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2343
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2344
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2345
subsubsection%unimportant \<open>Convex hull is "preserved" by a linear function\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2346
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2347
lemma convex_hull_linear_image:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2348
  assumes f: "linear f"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2349
  shows "f ` (convex hull s) = convex hull (f ` s)"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2350
proof
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2351
  show "convex hull (f ` s) \<subseteq> f ` (convex hull s)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2352
    by (intro hull_minimal image_mono hull_subset convex_linear_image assms convex_convex_hull)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2353
  show "f ` (convex hull s) \<subseteq> convex hull (f ` s)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2354
  proof (unfold image_subset_iff_subset_vimage, rule hull_minimal)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2355
    show "s \<subseteq> f -` (convex hull (f ` s))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2356
      by (fast intro: hull_inc)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2357
    show "convex (f -` (convex hull (f ` s)))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2358
      by (intro convex_linear_vimage [OF f] convex_convex_hull)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2359
  qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2360
qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2361
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2362
lemma in_convex_hull_linear_image:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2363
  assumes "linear f"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2364
    and "x \<in> convex hull s"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2365
  shows "f x \<in> convex hull (f ` s)"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2366
  using convex_hull_linear_image[OF assms(1)] assms(2) by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2367
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2368
lemma convex_hull_Times:
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2369
  "convex hull (s \<times> t) = (convex hull s) \<times> (convex hull t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2370
proof
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2371
  show "convex hull (s \<times> t) \<subseteq> (convex hull s) \<times> (convex hull t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2372
    by (intro hull_minimal Sigma_mono hull_subset convex_Times convex_convex_hull)
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2373
  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
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2374
  proof (rule hull_induct [OF x], rule hull_induct [OF y])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2375
    fix x y assume "x \<in> s" and "y \<in> t"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2376
    then show "(x, y) \<in> convex hull (s \<times> t)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2377
      by (simp add: hull_inc)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2378
  next
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2379
    fix x let ?S = "((\<lambda>y. (0, y)) -` (\<lambda>p. (- x, 0) + p) ` (convex hull s \<times> t))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2380
    have "convex ?S"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2381
      by (intro convex_linear_vimage convex_translation convex_convex_hull,
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2382
        simp add: linear_iff)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2383
    also have "?S = {y. (x, y) \<in> convex hull (s \<times> t)}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2384
      by (auto simp: image_def Bex_def)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2385
    finally show "convex {y. (x, y) \<in> convex hull (s \<times> t)}" .
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2386
  next
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2387
    show "convex {x. (x, y) \<in> convex hull s \<times> t}"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2388
    proof -
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2389
      fix y let ?S = "((\<lambda>x. (x, 0)) -` (\<lambda>p. (0, - y) + p) ` (convex hull s \<times> t))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2390
      have "convex ?S"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2391
      by (intro convex_linear_vimage convex_translation convex_convex_hull,
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2392
        simp add: linear_iff)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2393
      also have "?S = {x. (x, y) \<in> convex hull (s \<times> t)}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2394
        by (auto simp: image_def Bex_def)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2395
      finally show "convex {x. (x, y) \<in> convex hull (s \<times> t)}" .
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2396
    qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2397
  qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2398
  then show "(convex hull s) \<times> (convex hull t) \<subseteq> convex hull (s \<times> t)"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2399
    unfolding subset_eq split_paired_Ball_Sigma by blast
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2400
qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  2401
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2402
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2403
subsubsection%unimportant \<open>Stepping theorems for convex hulls of finite sets\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2404
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2405
lemma convex_hull_empty[simp]: "convex hull {} = {}"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2406
  by (rule hull_unique) auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2407
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2408
lemma convex_hull_singleton[simp]: "convex hull {a} = {a}"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2409
  by (rule hull_unique) auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2410
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2411
lemma convex_hull_insert:
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2412
  fixes S :: "'a::real_vector set"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2413
  assumes "S \<noteq> {}"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2414
  shows "convex hull (insert a S) =
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2415
         {x. \<exists>u\<ge>0. \<exists>v\<ge>0. \<exists>b. (u + v = 1) \<and> b \<in> (convex hull S) \<and> (x = u *\<^sub>R a + v *\<^sub>R b)}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2416
  (is "_ = ?hull")
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2417
proof (intro equalityI hull_minimal subsetI)
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2418
  fix x
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2419
  assume "x \<in> insert a S"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2420
  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)"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2421
  unfolding insert_iff
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2422
  proof
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2423
    assume "x = a"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2424
    then show ?thesis
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2425
      by (rule_tac x=1 in exI) (use assms hull_subset in fastforce)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2426
  next
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2427
    assume "x \<in> S"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2428
    with hull_subset[of S convex] show ?thesis
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2429
      by force
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2430
  qed
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2431
  then show "x \<in> ?hull"
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2432
    by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2433
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2434
  fix x
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2435
  assume "x \<in> ?hull"
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2436
  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"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2437
    by auto
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2438
  have "a \<in> convex hull insert a S" "b \<in> convex hull insert a S"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2439
    using hull_mono[of S "insert a S" convex] hull_mono[of "{a}" "insert a S" convex] and obt(4)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2440
    by auto
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2441
  then show "x \<in> convex hull insert a S"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  2442
    unfolding obt(5) using obt(1-3)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  2443
    by (rule convexD [OF convex_convex_hull])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2444
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2445
  show "convex ?hull"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  2446
  proof (rule convexI)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2447
    fix x y u v
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2448
    assume as: "(0::real) \<le> u" "0 \<le> v" "u + v = 1" and x: "x \<in> ?hull" and y: "y \<in> ?hull"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2449
    from x obtain u1 v1 b1 where
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2450
      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"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2451
      by auto
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2452
    from y obtain u2 v2 b2 where
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2453
      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"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2454
      by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2455
    have *: "\<And>(x::'a) s1 s2. x - s1 *\<^sub>R x - s2 *\<^sub>R x = ((1::real) - (s1 + s2)) *\<^sub>R x"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2456
      by (auto simp: algebra_simps)
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2457
    have "\<exists>b \<in> convex hull S. u *\<^sub>R x + v *\<^sub>R y =
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2458
      (u * u1) *\<^sub>R a + (v * u2) *\<^sub>R a + (b - (u * u1) *\<^sub>R b - (v * u2) *\<^sub>R b)"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2459
    proof (cases "u * v1 + v * v2 = 0")
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2460
      case True
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2461
      have *: "\<And>(x::'a) s1 s2. x - s1 *\<^sub>R x - s2 *\<^sub>R x = ((1::real) - (s1 + s2)) *\<^sub>R x"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2462
        by (auto simp: algebra_simps)
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2463
      have eq0: "u * v1 = 0" "v * v2 = 0"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2464
        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>]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2465
        by arith+
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2466
      then have "u * u1 + v * u2 = 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2467
        using as(3) obt1(3) obt2(3) by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2468
      then show ?thesis
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2469
        using "*" eq0 as obt1(4) xeq yeq by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2470
    next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2471
      case False
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2472
      have "1 - (u * u1 + v * u2) = (u + v) - (u * u1 + v * u2)"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2473
        using as(3) obt1(3) obt2(3) by (auto simp: field_simps)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2474
      also have "\<dots> = u * (v1 + u1 - u1) + v * (v2 + u2 - u2)"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2475
        using as(3) obt1(3) obt2(3) by (auto simp: field_simps)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2476
      also have "\<dots> = u * v1 + v * v2"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2477
        by simp
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2478
      finally have **:"1 - (u * u1 + v * u2) = u * v1 + v * v2" by auto
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2479
      let ?b = "((u * v1) / (u * v1 + v * v2)) *\<^sub>R b1 + ((v * v2) / (u * v1 + v * v2)) *\<^sub>R b2"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2480
      have zeroes: "0 \<le> u * v1 + v * v2" "0 \<le> u * v1" "0 \<le> u * v1 + v * v2" "0 \<le> v * v2"
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 56480
diff changeset
  2481
        using as(1,2) obt1(1,2) obt2(1,2) by auto
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2482
      show ?thesis
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2483
      proof
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2484
        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)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2485
          unfolding xeq yeq * **
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2486
          using False by (auto simp: scaleR_left_distrib scaleR_right_distrib)
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2487
        show "?b \<in> convex hull S"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2488
          using False zeroes obt1(4) obt2(4)
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2489
          by (auto simp: convexD [OF convex_convex_hull] scaleR_left_distrib scaleR_right_distrib  add_divide_distrib[symmetric]  zero_le_divide_iff)
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2490
      qed
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2491
    qed
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2492
    then obtain b where b: "b \<in> convex hull S" 
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2493
       "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)" ..
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2494
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2495
    have u1: "u1 \<le> 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2496
      unfolding obt1(3)[symmetric] and not_le using obt1(2) by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2497
    have u2: "u2 \<le> 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2498
      unfolding obt2(3)[symmetric] and not_le using obt2(2) by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2499
    have "u1 * u + u2 * v \<le> max u1 u2 * u + max u1 u2 * v"
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2500
    proof (rule add_mono)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2501
      show "u1 * u \<le> max u1 u2 * u" "u2 * v \<le> max u1 u2 * v"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2502
        by (simp_all add: as mult_right_mono)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2503
    qed
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2504
    also have "\<dots> \<le> 1"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2505
      unfolding distrib_left[symmetric] and as(3) using u1 u2 by auto
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2506
    finally have le1: "u1 * u + u2 * v \<le> 1" .    
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2507
    show "u *\<^sub>R x + v *\<^sub>R y \<in> ?hull"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2508
    proof (intro CollectI exI conjI)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2509
      show "0 \<le> u * u1 + v * u2"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2510
        by (simp add: as(1) as(2) obt1(1) obt2(1))
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2511
      show "0 \<le> 1 - u * u1 - v * u2"
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2512
        by (simp add: le1 diff_diff_add mult.commute)
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2513
    qed (use b in \<open>auto simp: algebra_simps\<close>)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2514
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2515
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2516
66287
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2517
lemma convex_hull_insert_alt:
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2518
   "convex hull (insert a S) =
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  2519
     (if S = {} then {a}
66287
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2520
      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})"
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2521
  apply (auto simp: convex_hull_insert)
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2522
  using diff_eq_eq apply fastforce
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2523
  by (metis add.group_left_neutral add_le_imp_le_diff diff_add_cancel)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2524
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2525
subsubsection%unimportant \<open>Explicit expression for convex hull\<close>
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2526
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2527
proposition%important convex_hull_indexed:
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2528
  fixes S :: "'a::real_vector set"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2529
  shows "convex hull S =
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2530
    {y. \<exists>k u x. (\<forall>i\<in>{1::nat .. k}. 0 \<le> u i \<and> x i \<in> S) \<and>
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2531
                (sum u {1..k} = 1) \<and> (\<Sum>i = 1..k. u i *\<^sub>R x i) = y}"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2532
    (is "?xyz = ?hull")
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2533
proof (rule hull_unique [OF _ convexI])
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2534
  show "S \<subseteq> ?hull" 
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2535
    by (clarsimp, rule_tac x=1 in exI, rule_tac x="\<lambda>x. 1" in exI, auto)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2536
next
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2537
  fix T
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2538
  assume "S \<subseteq> T" "convex T"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2539
  then show "?hull \<subseteq> T"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2540
    by (blast intro: convex_sum)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2541
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2542
  fix x y u v
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2543
  assume uv: "0 \<le> u" "0 \<le> v" "u + v = (1::real)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2544
  assume xy: "x \<in> ?hull" "y \<in> ?hull"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2545
  from xy obtain k1 u1 x1 where
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2546
    x [rule_format]: "\<forall>i\<in>{1::nat..k1}. 0\<le>u1 i \<and> x1 i \<in> S" 
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2547
                      "sum u1 {Suc 0..k1} = 1" "(\<Sum>i = Suc 0..k1. u1 i *\<^sub>R x1 i) = x"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2548
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2549
  from xy obtain k2 u2 x2 where
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2550
    y [rule_format]: "\<forall>i\<in>{1::nat..k2}. 0\<le>u2 i \<and> x2 i \<in> S" 
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2551
                     "sum u2 {Suc 0..k2} = 1" "(\<Sum>i = Suc 0..k2. u2 i *\<^sub>R x2 i) = y"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2552
    by auto
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2553
  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)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2554
          "{1..k1 + k2} \<inter> {1..k1} = {1..k1}" "{1..k1 + k2} \<inter> - {1..k1} = (\<lambda>i. i + k1) ` {1..k2}"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2555
    by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2556
  have inj: "inj_on (\<lambda>i. i + k1) {1..k2}"
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2557
    unfolding inj_on_def by auto
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2558
  let ?uu = "\<lambda>i. if i \<in> {1..k1} then u * u1 i else v * u2 (i - k1)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2559
  let ?xx = "\<lambda>i. if i \<in> {1..k1} then x1 i else x2 (i - k1)"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2560
  show "u *\<^sub>R x + v *\<^sub>R y \<in> ?hull"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2561
  proof (intro CollectI exI conjI ballI)
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2562
    show "0 \<le> ?uu i" "?xx i \<in> S" if "i \<in> {1..k1+k2}" for i
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2563
      using that by (auto simp add: le_diff_conv uv(1) x(1) uv(2) y(1))
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2564
    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"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2565
      unfolding * sum.If_cases[OF finite_atLeastAtMost[of 1 "k1 + k2"]]
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2566
        sum.reindex[OF inj] Collect_mem_eq o_def
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2567
      unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] sum_distrib_left[symmetric]
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2568
      by (simp_all add: sum_distrib_left[symmetric]  x(2,3) y(2,3) uv(3))
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2569
  qed 
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2570
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2571
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2572
lemma convex_hull_finite:
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2573
  fixes S :: "'a::real_vector set"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2574
  assumes "finite S"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2575
  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}"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2576
  (is "?HULL = _")
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2577
proof (rule hull_unique [OF _ convexI]; clarify)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2578
  fix x
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2579
  assume "x \<in> S"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2580
  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"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2581
    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])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2582
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2583
  fix u v :: real
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2584
  assume uv: "0 \<le> u" "0 \<le> v" "u + v = 1"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2585
  fix ux assume ux [rule_format]: "\<forall>x\<in>S. 0 \<le> ux x" "sum ux S = (1::real)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2586
  fix uy assume uy [rule_format]: "\<forall>x\<in>S. 0 \<le> uy x" "sum uy S = (1::real)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2587
  have "0 \<le> u * ux x + v * uy x" if "x\<in>S" for x
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2588
    by (simp add: that uv ux(1) uy(1))
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2589
  moreover
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2590
  have "(\<Sum>x\<in>S. u * ux x + v * uy x) = 1"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2591
    unfolding sum.distrib and sum_distrib_left[symmetric] ux(2) uy(2)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2592
    using uv(3) by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2593
  moreover
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2594
  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)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2595
    unfolding scaleR_left_distrib sum.distrib scaleR_scaleR[symmetric] scaleR_right.sum [symmetric]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2596
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2597
  ultimately
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2598
  show "\<exists>uc. (\<forall>x\<in>S. 0 \<le> uc x) \<and> sum uc S = 1 \<and>
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2599
             (\<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)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2600
    by (rule_tac x="\<lambda>x. u * ux x + v * uy x" in exI, auto)
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2601
qed (use assms in \<open>auto simp: convex_explicit\<close>)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2602
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2603
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2604
subsubsection%unimportant \<open>Another formulation from Lars Schewe\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2605
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2606
lemma convex_hull_explicit:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2607
  fixes p :: "'a::real_vector set"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2608
  shows "convex hull p =
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2609
    {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}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2610
  (is "?lhs = ?rhs")
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2611
proof -
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2612
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2613
    fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2614
    assume "x\<in>?lhs"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2615
    then obtain k u y where
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2616
        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"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2617
      unfolding convex_hull_indexed by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2618
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2619
    have fin: "finite {1..k}" by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2620
    have fin': "\<And>v. finite {i \<in> {1..k}. y i = v}" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2621
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2622
      fix j
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2623
      assume "j\<in>{1..k}"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2624
      then have "y j \<in> p" "0 \<le> sum u {i. Suc 0 \<le> i \<and> i \<le> k \<and> y i = y j}"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2625
        using obt(1)[THEN bspec[where x=j]] and obt(2)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2626
        apply simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2627
        apply (rule sum_nonneg)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2628
        using obt(1)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2629
        apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2630
        done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2631
    }
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2632
    moreover
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2633
    have "(\<Sum>v\<in>y ` {1..k}. sum u {i \<in> {1..k}. y i = v}) = 1"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2634
      unfolding sum_image_gen[OF fin, symmetric] using obt(2) by auto
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2635
    moreover have "(\<Sum>v\<in>y ` {1..k}. sum u {i \<in> {1..k}. y i = v} *\<^sub>R v) = x"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2636
      using sum_image_gen[OF fin, of "\<lambda>i. u i *\<^sub>R y i" y, symmetric]
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2637
      unfolding scaleR_left.sum using obt(3) by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2638
    ultimately
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2639
    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"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2640
      apply (rule_tac x="y ` {1..k}" in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2641
      apply (rule_tac x="\<lambda>v. sum u {i\<in>{1..k}. y i = v}" in exI, auto)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2642
      done
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2643
    then have "x\<in>?rhs" by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2644
  }
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2645
  moreover
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2646
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2647
    fix y
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2648
    assume "y\<in>?rhs"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2649
    then obtain S u where
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2650
      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"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2651
      by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2652
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2653
    obtain f where f: "inj_on f {1..card S}" "f ` {1..card S} = S"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2654
      using ex_bij_betw_nat_finite_1[OF obt(1)] unfolding bij_betw_def by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2655
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2656
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2657
      fix i :: nat
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2658
      assume "i\<in>{1..card S}"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2659
      then have "f i \<in> S"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2660
        using f(2) by blast
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2661
      then have "0 \<le> u (f i)" "f i \<in> p" using obt(2,3) by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2662
    }
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2663
    moreover have *: "finite {1..card S}" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2664
    {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2665
      fix y
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2666
      assume "y\<in>S"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2667
      then obtain i where "i\<in>{1..card S}" "f i = y"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2668
        using f using image_iff[of y f "{1..card S}"]
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2669
        by auto
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2670
      then have "{x. Suc 0 \<le> x \<and> x \<le> card S \<and> f x = y} = {i}"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2671
        apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2672
        using f(1)[unfolded inj_on_def]
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2673
        by (metis One_nat_def atLeastAtMost_iff)
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2674
      then have "card {x. Suc 0 \<le> x \<and> x \<le> card S \<and> f x = y} = 1" by auto
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2675
      then have "(\<Sum>x\<in>{x \<in> {1..card S}. f x = y}. u (f x)) = u y"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2676
          "(\<Sum>x\<in>{x \<in> {1..card S}. f x = y}. u (f x) *\<^sub>R f x) = u y *\<^sub>R y"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2677
        by (auto simp: sum_constant_scaleR)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2678
    }
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2679
    then have "(\<Sum>x = 1..card S. u (f x)) = 1" "(\<Sum>i = 1..card S. u (f i) *\<^sub>R f i) = y"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2680
      unfolding sum_image_gen[OF *(1), of "\<lambda>x. u (f x) *\<^sub>R f x" f]
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2681
        and sum_image_gen[OF *(1), of "\<lambda>x. u (f x)" f]
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  2682
      unfolding f
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2683
      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"]
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2684
      using sum.cong [of S S "\<lambda>y. (\<Sum>x\<in>{x \<in> {1..card S}. f x = y}. u (f x))" u]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2685
      unfolding obt(4,5)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2686
      by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2687
    ultimately
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2688
    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>
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2689
        (\<Sum>i::nat = 1..k. u i *\<^sub>R x i) = y"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2690
      apply (rule_tac x="card S" in exI)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2691
      apply (rule_tac x="u \<circ> f" in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2692
      apply (rule_tac x=f in exI, fastforce)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2693
      done
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2694
    then have "y \<in> ?lhs"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2695
      unfolding convex_hull_indexed by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2696
  }
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2697
  ultimately show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2698
    unfolding set_eq_iff by blast
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2699
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2700
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2701
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2702
subsubsection%unimportant \<open>A stepping theorem for that expansion\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2703
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2704
lemma convex_hull_finite_step:
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2705
  fixes S :: "'a::real_vector set"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2706
  assumes "finite S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2707
  shows
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2708
    "(\<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)
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2709
      \<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)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2710
  (is "?lhs = ?rhs")
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2711
proof (rule, case_tac[!] "a\<in>S")
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2712
  assume "a \<in> S"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2713
  then have *: "insert a S = S" by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2714
  assume ?lhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2715
  then show ?rhs
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2716
    unfolding *  by (rule_tac x=0 in exI, auto)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2717
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2718
  assume ?lhs
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2719
  then obtain u where
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2720
      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"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2721
    by auto
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2722
  assume "a \<notin> S"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2723
  then show ?rhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2724
    apply (rule_tac x="u a" in exI)
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2725
    using u(1)[THEN bspec[where x=a]]
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2726
    apply simp
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2727
    apply (rule_tac x=u in exI)
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2728
    using u[unfolded sum_clauses(2)[OF assms]] and \<open>a\<notin>S\<close>
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2729
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2730
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2731
next
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2732
  assume "a \<in> S"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2733
  then have *: "insert a S = S" by auto
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2734
  have fin: "finite (insert a S)" using assms by auto
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2735
  assume ?rhs
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2736
  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"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2737
    by auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2738
  show ?lhs
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2739
    apply (rule_tac x = "\<lambda>x. (if a = x then v else 0) + u x" in exI)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2740
    unfolding scaleR_left_distrib and sum.distrib and sum_delta''[OF fin] and sum.delta'[OF fin]
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2741
    unfolding sum_clauses(2)[OF assms]
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2742
    using uv and uv(2)[THEN bspec[where x=a]] and \<open>a\<in>S\<close>
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2743
    apply auto
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2744
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2745
next
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2746
  assume ?rhs
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2747
  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"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2748
    by auto
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2749
  moreover assume "a \<notin> S"
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2750
  moreover
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2751
  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)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2752
    using \<open>a \<notin> S\<close>
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  2753
    by (auto simp: intro!: sum.cong)
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2754
  ultimately show ?lhs
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2755
    by (rule_tac x="\<lambda>x. if a = x then v else u x" in exI) (auto simp: sum_clauses(2)[OF assms])
50804
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2756
qed
4156a45aeb63 tuned proofs;
wenzelm
parents: 50526
diff changeset
  2757
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2758
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2759
subsubsection%unimportant \<open>Hence some special cases\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2760
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2761
lemma convex_hull_2:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2762
  "convex hull {a,b} = {u *\<^sub>R a + v *\<^sub>R b | u v. 0 \<le> u \<and> 0 \<le> v \<and> u + v = 1}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2763
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2764
  have *: "\<And>u. (\<forall>x\<in>{a, b}. 0 \<le> u x) \<longleftrightarrow> 0 \<le> u a \<and> 0 \<le> u b"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2765
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2766
  have **: "finite {b}" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2767
  show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2768
    apply (simp add: convex_hull_finite)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2769
    unfolding convex_hull_finite_step[OF **, of a 1, unfolded * conj_assoc]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2770
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2771
    apply (rule_tac x=v in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2772
    apply (rule_tac x="1 - v" in exI, simp)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2773
    apply (rule_tac x=u in exI, simp)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2774
    apply (rule_tac x="\<lambda>x. v" in exI, simp)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2775
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2776
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2777
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2778
lemma convex_hull_2_alt: "convex hull {a,b} = {a + u *\<^sub>R (b - a) | u.  0 \<le> u \<and> u \<le> 1}"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44142
diff changeset
  2779
  unfolding convex_hull_2
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2780
proof (rule Collect_cong)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2781
  have *: "\<And>x y ::real. x + y = 1 \<longleftrightarrow> x = 1 - y"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2782
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2783
  fix x
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2784
  show "(\<exists>v u. x = v *\<^sub>R a + u *\<^sub>R b \<and> 0 \<le> v \<and> 0 \<le> u \<and> v + u = 1) \<longleftrightarrow>
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2785
    (\<exists>u. x = a + u *\<^sub>R (b - a) \<and> 0 \<le> u \<and> u \<le> 1)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2786
    unfolding *
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2787
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2788
    apply (rule_tac[!] x=u in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2789
    apply (auto simp: algebra_simps)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2790
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2791
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2792
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2793
lemma convex_hull_3:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2794
  "convex hull {a,b,c} = { u *\<^sub>R a + v *\<^sub>R b + w *\<^sub>R c | u v w. 0 \<le> u \<and> 0 \<le> v \<and> 0 \<le> w \<and> u + v + w = 1}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2795
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2796
  have fin: "finite {a,b,c}" "finite {b,c}" "finite {c}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2797
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2798
  have *: "\<And>x y z ::real. x + y + z = 1 \<longleftrightarrow> x = 1 - y - z"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2799
    by (auto simp: field_simps)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2800
  show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2801
    unfolding convex_hull_finite[OF fin(1)] and convex_hull_finite_step[OF fin(2)] and *
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2802
    unfolding convex_hull_finite_step[OF fin(3)]
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2803
    apply (rule Collect_cong, simp)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2804
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2805
    apply (rule_tac x=va in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2806
    apply (rule_tac x="u c" in exI, simp)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2807
    apply (rule_tac x="1 - v - w" in exI, simp)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2808
    apply (rule_tac x=v in exI, simp)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2809
    apply (rule_tac x="\<lambda>x. w" in exI, simp)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2810
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2811
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2812
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2813
lemma convex_hull_3_alt:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2814
  "convex hull {a,b,c} = {a + u *\<^sub>R (b - a) + v *\<^sub>R (c - a) | u v.  0 \<le> u \<and> 0 \<le> v \<and> u + v \<le> 1}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2815
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2816
  have *: "\<And>x y z ::real. x + y + z = 1 \<longleftrightarrow> x = 1 - y - z"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2817
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2818
  show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2819
    unfolding convex_hull_3
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2820
    apply (auto simp: *)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2821
    apply (rule_tac x=v in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2822
    apply (rule_tac x=w in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2823
    apply (simp add: algebra_simps)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2824
    apply (rule_tac x=u in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2825
    apply (rule_tac x=v in exI)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2826
    apply (simp add: algebra_simps)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2827
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2828
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2829
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2830
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2831
subsection%unimportant \<open>Relations among closure notions and corresponding hulls\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2832
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2833
lemma affine_imp_convex: "affine s \<Longrightarrow> convex s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2834
  unfolding affine_def convex_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2835
64394
141e1ed8d5a0 more new material
paulson <lp15@cam.ac.uk>
parents: 64287
diff changeset
  2836
lemma convex_affine_hull [simp]: "convex (affine hull S)"
141e1ed8d5a0 more new material
paulson <lp15@cam.ac.uk>
parents: 64287
diff changeset
  2837
  by (simp add: affine_imp_convex)
141e1ed8d5a0 more new material
paulson <lp15@cam.ac.uk>
parents: 64287
diff changeset
  2838
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  2839
lemma subspace_imp_convex: "subspace s \<Longrightarrow> convex s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2840
  using subspace_imp_affine affine_imp_convex by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2841
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  2842
lemma affine_hull_subset_span: "(affine hull s) \<subseteq> (span s)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  2843
  by (metis hull_minimal span_superset subspace_imp_affine subspace_span)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2844
44361
75ec83d45303 remove unnecessary euclidean_space class constraints
huffman
parents: 44349
diff changeset
  2845
lemma convex_hull_subset_span: "(convex hull s) \<subseteq> (span s)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  2846
  by (metis hull_minimal span_superset subspace_imp_convex subspace_span)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2847
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2848
lemma convex_hull_subset_affine_hull: "(convex hull s) \<subseteq> (affine hull s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2849
  by (metis affine_affine_hull affine_imp_convex hull_minimal hull_subset)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2850
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2851
lemma affine_dependent_imp_dependent: "affine_dependent s \<Longrightarrow> dependent s"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2852
  unfolding affine_dependent_def dependent_def
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2853
  using affine_hull_subset_span by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2854
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2855
lemma dependent_imp_affine_dependent:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2856
  assumes "dependent {x - a| x . x \<in> s}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2857
    and "a \<notin> s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2858
  shows "affine_dependent (insert a s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2859
proof -
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2860
  from assms(1)[unfolded dependent_explicit] obtain S u v
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2861
    where obt: "finite S" "S \<subseteq> {x - a |x. x \<in> s}" "v\<in>S" "u v  \<noteq> 0" "(\<Sum>v\<in>S. u v *\<^sub>R v) = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2862
    by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  2863
  define t where "t = (\<lambda>x. x + a) ` S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2864
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2865
  have inj: "inj_on (\<lambda>x. x + a) S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2866
    unfolding inj_on_def by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2867
  have "0 \<notin> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2868
    using obt(2) assms(2) unfolding subset_eq by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2869
  have fin: "finite t" and "t \<subseteq> s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2870
    unfolding t_def using obt(1,2) by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2871
  then have "finite (insert a t)" and "insert a t \<subseteq> insert a s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2872
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2873
  moreover have *: "\<And>P Q. (\<Sum>x\<in>t. (if x = a then P x else Q x)) = (\<Sum>x\<in>t. Q x)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2874
    apply (rule sum.cong)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2875
    using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close>
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2876
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2877
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2878
  have "(\<Sum>x\<in>insert a t. if x = a then - (\<Sum>x\<in>t. u (x - a)) else u (x - a)) = 0"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2879
    unfolding sum_clauses(2)[OF fin] * using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close> by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2880
  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"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2881
    using obt(3,4) \<open>0\<notin>S\<close>
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2882
    by (rule_tac x="v + a" in bexI) (auto simp: t_def)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2883
  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)"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2884
    using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close> by (auto intro!: sum.cong)
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  2885
  have "(\<Sum>x\<in>t. u (x - a)) *\<^sub>R a = (\<Sum>v\<in>t. u (v - a) *\<^sub>R v)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2886
    unfolding scaleR_left.sum
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2887
    unfolding t_def and sum.reindex[OF inj] and o_def
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2888
    using obt(5)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2889
    by (auto simp: sum.distrib scaleR_right_distrib)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2890
  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"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  2891
    unfolding sum_clauses(2)[OF fin]
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2892
    using \<open>a\<notin>s\<close> \<open>t\<subseteq>s\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2893
    by (auto simp: *)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2894
  ultimately show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2895
    unfolding affine_dependent_explicit
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2896
    apply (rule_tac x="insert a t" in exI, auto)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2897
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2898
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2899
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2900
lemma convex_cone:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2901
  "convex s \<and> cone s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. (x + y) \<in> s) \<and> (\<forall>x\<in>s. \<forall>c\<ge>0. (c *\<^sub>R x) \<in> s)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2902
  (is "?lhs = ?rhs")
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2903
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2904
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2905
    fix x y
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2906
    assume "x\<in>s" "y\<in>s" and ?lhs
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2907
    then have "2 *\<^sub>R x \<in>s" "2 *\<^sub>R y \<in> s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2908
      unfolding cone_def by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2909
    then have "x + y \<in> s"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2910
      using \<open>?lhs\<close>[unfolded convex_def, THEN conjunct1]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2911
      apply (erule_tac x="2*\<^sub>R x" in ballE)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2912
      apply (erule_tac x="2*\<^sub>R y" in ballE)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2913
      apply (erule_tac x="1/2" in allE, simp)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2914
      apply (erule_tac x="1/2" in allE, auto)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2915
      done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2916
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2917
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2918
    unfolding convex_def cone_def by blast
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2919
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2920
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2921
lemma affine_dependent_biggerset:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2922
  fixes s :: "'a::euclidean_space set"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  2923
  assumes "finite s" "card s \<ge> DIM('a) + 2"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2924
  shows "affine_dependent s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2925
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2926
  have "s \<noteq> {}" using assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2927
  then obtain a where "a\<in>s" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2928
  have *: "{x - a |x. x \<in> s - {a}} = (\<lambda>x. x - a) ` (s - {a})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2929
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2930
  have "card {x - a |x. x \<in> s - {a}} = card (s - {a})"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2931
    unfolding * by (simp add: card_image inj_on_def)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  2932
  also have "\<dots> > DIM('a)" using assms(2)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2933
    unfolding card_Diff_singleton[OF assms(1) \<open>a\<in>s\<close>] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2934
  finally show ?thesis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  2935
    apply (subst insert_Diff[OF \<open>a\<in>s\<close>, symmetric])
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2936
    apply (rule dependent_imp_affine_dependent)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  2937
    apply (rule dependent_biggerset, auto)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2938
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2939
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2940
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2941
lemma affine_dependent_biggerset_general:
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2942
  assumes "finite (S :: 'a::euclidean_space set)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2943
    and "card S \<ge> dim S + 2"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2944
  shows "affine_dependent S"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2945
proof -
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2946
  from assms(2) have "S \<noteq> {}" by auto
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2947
  then obtain a where "a\<in>S" by auto
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2948
  have *: "{x - a |x. x \<in> S - {a}} = (\<lambda>x. x - a) ` (S - {a})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2949
    by auto
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2950
  have **: "card {x - a |x. x \<in> S - {a}} = card (S - {a})"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2951
    by (metis (no_types, lifting) "*" card_image diff_add_cancel inj_on_def)
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2952
  have "dim {x - a |x. x \<in> S - {a}} \<le> dim S"
68074
8d50467f7555 fixed HOL-Analysis
immler
parents: 68073
diff changeset
  2953
    using \<open>a\<in>S\<close> by (auto simp: span_base span_diff intro: subset_le_dim)
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2954
  also have "\<dots> < dim S + 1" by auto
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2955
  also have "\<dots> \<le> card (S - {a})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2956
    using assms
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2957
    using card_Diff_singleton[OF assms(1) \<open>a\<in>S\<close>]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2958
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2959
  finally show ?thesis
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  2960
    apply (subst insert_Diff[OF \<open>a\<in>S\<close>, symmetric])
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2961
    apply (rule dependent_imp_affine_dependent)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2962
    apply (rule dependent_biggerset_general)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2963
    unfolding **
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2964
    apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2965
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2966
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2967
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2968
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  2969
subsection%unimportant \<open>Some Properties of Affine Dependent Sets\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2970
66287
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2971
lemma affine_independent_0 [simp]: "\<not> affine_dependent {}"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2972
  by (simp add: affine_dependent_def)
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2973
66287
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2974
lemma affine_independent_1 [simp]: "\<not> affine_dependent {a}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2975
  by (simp add: affine_dependent_def)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2976
66287
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65719
diff changeset
  2977
lemma affine_independent_2 [simp]: "\<not> affine_dependent {a,b}"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2978
  by (simp add: affine_dependent_def insert_Diff_if hull_same)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  2979
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2980
lemma affine_hull_translation: "affine hull ((\<lambda>x. a + x) `  S) = (\<lambda>x. a + x) ` (affine hull S)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2981
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2982
  have "affine ((\<lambda>x. a + x) ` (affine hull S))"
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  2983
    using affine_translation affine_affine_hull by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2984
  moreover have "(\<lambda>x. a + x) `  S \<subseteq> (\<lambda>x. a + x) ` (affine hull S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2985
    using hull_subset[of S] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2986
  ultimately have h1: "affine hull ((\<lambda>x. a + x) `  S) \<subseteq> (\<lambda>x. a + x) ` (affine hull S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2987
    by (metis hull_minimal)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2988
  have "affine((\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S)))"
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  2989
    using affine_translation affine_affine_hull by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2990
  moreover have "(\<lambda>x. -a + x) ` (\<lambda>x. a + x) `  S \<subseteq> (\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2991
    using hull_subset[of "(\<lambda>x. a + x) `  S"] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  2992
  moreover have "S = (\<lambda>x. -a + x) ` (\<lambda>x. a + x) `  S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2993
    using translation_assoc[of "-a" a] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2994
  ultimately have "(\<lambda>x. -a + x) ` (affine hull ((\<lambda>x. a + x) `  S)) >= (affine hull S)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2995
    by (metis hull_minimal)
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2996
  then have "affine hull ((\<lambda>x. a + x) ` S) >= (\<lambda>x. a + x) ` (affine hull S)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2997
    by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  2998
  then show ?thesis using h1 by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  2999
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3000
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3001
lemma affine_dependent_translation:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3002
  assumes "affine_dependent S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3003
  shows "affine_dependent ((\<lambda>x. a + x) ` S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3004
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3005
  obtain x where x: "x \<in> S \<and> x \<in> affine hull (S - {x})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3006
    using assms affine_dependent_def by auto
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  3007
  have "(+) a ` (S - {x}) = (+) a ` S - {a + x}"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3008
    by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3009
  then have "a + x \<in> affine hull ((\<lambda>x. a + x) ` S - {a + x})"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3010
    using affine_hull_translation[of a "S - {x}"] x by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3011
  moreover have "a + x \<in> (\<lambda>x. a + x) ` S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3012
    using x by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3013
  ultimately show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3014
    unfolding affine_dependent_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3015
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3016
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3017
lemma affine_dependent_translation_eq:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3018
  "affine_dependent S \<longleftrightarrow> affine_dependent ((\<lambda>x. a + x) ` S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3019
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3020
  {
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3021
    assume "affine_dependent ((\<lambda>x. a + x) ` S)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3022
    then have "affine_dependent S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3023
      using affine_dependent_translation[of "((\<lambda>x. a + x) ` S)" "-a"] translation_assoc[of "-a" a]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3024
      by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3025
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3026
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3027
    using affine_dependent_translation by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3028
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3029
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3030
lemma affine_hull_0_dependent:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3031
  assumes "0 \<in> affine hull S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3032
  shows "dependent S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3033
proof -
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3034
  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"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3035
    using assms affine_hull_explicit[of S] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3036
  then have "\<exists>v\<in>s. u v \<noteq> 0"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3037
    using sum_not_0[of "u" "s"] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3038
  then have "finite s \<and> s \<subseteq> S \<and> (\<exists>v\<in>s. u v \<noteq> 0 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = 0)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3039
    using s_u by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3040
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3041
    unfolding dependent_explicit[of S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3042
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3043
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3044
lemma affine_dependent_imp_dependent2:
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3045
  assumes "affine_dependent (insert 0 S)"
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3046
  shows "dependent S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3047
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3048
  obtain x where x: "x \<in> insert 0 S \<and> x \<in> affine hull (insert 0 S - {x})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3049
    using affine_dependent_def[of "(insert 0 S)"] assms by blast
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3050
  then have "x \<in> span (insert 0 S - {x})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3051
    using affine_hull_subset_span by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3052
  moreover have "span (insert 0 S - {x}) = span (S - {x})"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3053
    using insert_Diff_if[of "0" S "{x}"] span_insert_0[of "S-{x}"] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3054
  ultimately have "x \<in> span (S - {x})" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3055
  then have "x \<noteq> 0 \<Longrightarrow> dependent S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3056
    using x dependent_def by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3057
  moreover
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3058
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3059
    assume "x = 0"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3060
    then have "0 \<in> affine hull S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3061
      using x hull_mono[of "S - {0}" S] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3062
    then have "dependent S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3063
      using affine_hull_0_dependent by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3064
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3065
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3066
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3067
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3068
lemma affine_dependent_iff_dependent:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3069
  assumes "a \<notin> S"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3070
  shows "affine_dependent (insert a S) \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` S)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3071
proof -
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67399
diff changeset
  3072
  have "((+) (- a) ` S) = {x - a| x . x \<in> S}" by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3073
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3074
    using affine_dependent_translation_eq[of "(insert a S)" "-a"]
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3075
      affine_dependent_imp_dependent2 assms
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3076
      dependent_imp_affine_dependent[of a S]
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53676
diff changeset
  3077
    by (auto simp del: uminus_add_conv_diff)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3078
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3079
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3080
lemma affine_dependent_iff_dependent2:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3081
  assumes "a \<in> S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3082
  shows "affine_dependent S \<longleftrightarrow> dependent ((\<lambda>x. -a + x) ` (S-{a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3083
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3084
  have "insert a (S - {a}) = S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3085
    using assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3086
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3087
    using assms affine_dependent_iff_dependent[of a "S-{a}"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3088
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3089
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3090
lemma affine_hull_insert_span_gen:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3091
  "affine hull (insert a s) = (\<lambda>x. a + x) ` span ((\<lambda>x. - a + x) ` s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3092
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3093
  have h1: "{x - a |x. x \<in> s} = ((\<lambda>x. -a+x) ` s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3094
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3095
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3096
    assume "a \<notin> s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3097
    then have ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3098
      using affine_hull_insert_span[of a s] h1 by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3099
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3100
  moreover
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3101
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3102
    assume a1: "a \<in> s"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3103
    have "\<exists>x. x \<in> s \<and> -a+x=0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3104
      apply (rule exI[of _ a])
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3105
      using a1
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3106
      apply auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3107
      done
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3108
    then have "insert 0 ((\<lambda>x. -a+x) ` (s - {a})) = (\<lambda>x. -a+x) ` s"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3109
      by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3110
    then have "span ((\<lambda>x. -a+x) ` (s - {a}))=span ((\<lambda>x. -a+x) ` s)"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  3111
      using span_insert_0[of "(+) (- a) ` (s - {a})"] by (auto simp del: uminus_add_conv_diff)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3112
    moreover have "{x - a |x. x \<in> (s - {a})} = ((\<lambda>x. -a+x) ` (s - {a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3113
      by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3114
    moreover have "insert a (s - {a}) = insert a s"
63092
a949b2a5f51d eliminated use of empty "assms";
wenzelm
parents: 63077
diff changeset
  3115
      by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3116
    ultimately have ?thesis
63092
a949b2a5f51d eliminated use of empty "assms";
wenzelm
parents: 63077
diff changeset
  3117
      using affine_hull_insert_span[of "a" "s-{a}"] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3118
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3119
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3120
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3121
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3122
lemma affine_hull_span2:
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3123
  assumes "a \<in> s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3124
  shows "affine hull s = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` (s-{a}))"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3125
  using affine_hull_insert_span_gen[of a "s - {a}", unfolded insert_Diff[OF assms]]
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3126
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3127
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3128
lemma affine_hull_span_gen:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3129
  assumes "a \<in> affine hull s"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3130
  shows "affine hull s = (\<lambda>x. a+x) ` span ((\<lambda>x. -a+x) ` s)"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3131
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3132
  have "affine hull (insert a s) = affine hull s"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3133
    using hull_redundant[of a affine s] assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3134
  then show ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3135
    using affine_hull_insert_span_gen[of a "s"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3136
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3137
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3138
lemma affine_hull_span_0:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3139
  assumes "0 \<in> affine hull S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3140
  shows "affine hull S = span S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3141
  using affine_hull_span_gen[of "0" S] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3142
63016
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3143
lemma extend_to_affine_basis_nonempty:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3144
  fixes S V :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3145
  assumes "\<not> affine_dependent S" "S \<subseteq> V" "S \<noteq> {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3146
  shows "\<exists>T. \<not> affine_dependent T \<and> S \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3147
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3148
  obtain a where a: "a \<in> S"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3149
    using assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3150
  then have h0: "independent  ((\<lambda>x. -a + x) ` (S-{a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3151
    using affine_dependent_iff_dependent2 assms by auto
68069
36209dfb981e tidying up and using real induction methods
paulson <lp15@cam.ac.uk>
parents: 68058
diff changeset
  3152
  obtain B where B:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3153
    "(\<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"
68069
36209dfb981e tidying up and using real induction methods
paulson <lp15@cam.ac.uk>
parents: 68058
diff changeset
  3154
    using assms
36209dfb981e tidying up and using real induction methods
paulson <lp15@cam.ac.uk>
parents: 68058
diff changeset
  3155
    by (blast intro: maximal_independent_subset_extend[OF _ h0, of "(\<lambda>x. -a + x) ` V"])
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  3156
  define T where "T = (\<lambda>x. a+x) ` insert 0 B"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3157
  then have "T = insert a ((\<lambda>x. a+x) ` B)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3158
    by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3159
  then have "affine hull T = (\<lambda>x. a+x) ` span B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3160
    using affine_hull_insert_span_gen[of a "((\<lambda>x. a+x) ` B)"] translation_assoc[of "-a" a B]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3161
    by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3162
  then have "V \<subseteq> affine hull T"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3163
    using B assms translation_inverse_subset[of a V "span B"]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3164
    by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3165
  moreover have "T \<subseteq> V"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3166
    using T_def B a assms by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3167
  ultimately have "affine hull T = affine hull V"
44457
d366fa5551ef declare euclidean_simps [simp] at the point they are proved;
huffman
parents: 44365
diff changeset
  3168
    by (metis Int_absorb1 Int_absorb2 hull_hull hull_mono)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3169
  moreover have "S \<subseteq> T"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3170
    using T_def B translation_inverse_subset[of a "S-{a}" B]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3171
    by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3172
  moreover have "\<not> affine_dependent T"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3173
    using T_def affine_dependent_translation_eq[of "insert 0 B"]
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3174
      affine_dependent_imp_dependent2 B
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3175
    by auto
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3176
  ultimately show ?thesis using \<open>T \<subseteq> V\<close> by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3177
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3178
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3179
lemma affine_basis_exists:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3180
  fixes V :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3181
  shows "\<exists>B. B \<subseteq> V \<and> \<not> affine_dependent B \<and> affine hull V = affine hull B"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3182
proof (cases "V = {}")
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3183
  case True
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3184
  then show ?thesis
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3185
    using affine_independent_0 by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3186
next
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3187
  case False
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3188
  then obtain x where "x \<in> V" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3189
  then show ?thesis
63016
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3190
    using affine_dependent_def[of "{x}"] extend_to_affine_basis_nonempty[of "{x}" V]
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3191
    by auto
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3192
qed
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3193
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3194
proposition extend_to_affine_basis:
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3195
  fixes S V :: "'n::euclidean_space set"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3196
  assumes "\<not> affine_dependent S" "S \<subseteq> V"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3197
  obtains T where "\<not> affine_dependent T" "S \<subseteq> T" "T \<subseteq> V" "affine hull T = affine hull V"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3198
proof (cases "S = {}")
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3199
  case True then show ?thesis
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3200
    using affine_basis_exists by (metis empty_subsetI that)
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3201
next
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3202
  case False
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3203
  then show ?thesis by (metis assms extend_to_affine_basis_nonempty that)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3204
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3205
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3206
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3207
subsection \<open>Affine Dimension of a Set\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3208
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  3209
definition%important aff_dim :: "('a::euclidean_space) set \<Rightarrow> int"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3210
  where "aff_dim V =
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3211
  (SOME d :: int.
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3212
    \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = d + 1)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3213
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3214
lemma aff_dim_basis_exists:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3215
  fixes V :: "('n::euclidean_space) set"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3216
  shows "\<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3217
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3218
  obtain B where "\<not> affine_dependent B \<and> affine hull B = affine hull V"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3219
    using affine_basis_exists[of V] by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3220
  then show ?thesis
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3221
    unfolding aff_dim_def
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3222
      some_eq_ex[of "\<lambda>d. \<exists>B. affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> of_nat (card B) = d + 1"]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3223
    apply auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3224
    apply (rule exI[of _ "int (card B) - (1 :: int)"])
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3225
    apply (rule exI[of _ "B"], auto)
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3226
    done
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3227
qed
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3228
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3229
lemma affine_hull_nonempty: "S \<noteq> {} \<longleftrightarrow> affine hull S \<noteq> {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3230
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3231
  have "S = {} \<Longrightarrow> affine hull S = {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3232
    using affine_hull_empty by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3233
  moreover have "affine hull S = {} \<Longrightarrow> S = {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3234
    unfolding hull_def by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3235
  ultimately show ?thesis by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3236
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3237
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3238
lemma aff_dim_parallel_subspace_aux:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3239
  fixes B :: "'n::euclidean_space set"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3240
  assumes "\<not> affine_dependent B" "a \<in> B"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3241
  shows "finite B \<and> ((card B) - 1 = dim (span ((\<lambda>x. -a+x) ` (B-{a}))))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3242
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3243
  have "independent ((\<lambda>x. -a + x) ` (B-{a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3244
    using affine_dependent_iff_dependent2 assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3245
  then have fin: "dim (span ((\<lambda>x. -a+x) ` (B-{a}))) = card ((\<lambda>x. -a + x) ` (B-{a}))"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3246
    "finite ((\<lambda>x. -a + x) ` (B - {a}))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3247
    using indep_card_eq_dim_span[of "(\<lambda>x. -a+x) ` (B-{a})"] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3248
  show ?thesis
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3249
  proof (cases "(\<lambda>x. -a + x) ` (B - {a}) = {}")
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3250
    case True
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3251
    have "B = insert a ((\<lambda>x. a + x) ` (\<lambda>x. -a + x) ` (B - {a}))"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3252
      using translation_assoc[of "a" "-a" "(B - {a})"] assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3253
    then have "B = {a}" using True by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3254
    then show ?thesis using assms fin by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3255
  next
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3256
    case False
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3257
    then have "card ((\<lambda>x. -a + x) ` (B - {a})) > 0"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3258
      using fin by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3259
    moreover have h1: "card ((\<lambda>x. -a + x) ` (B-{a})) = card (B-{a})"
68069
36209dfb981e tidying up and using real induction methods
paulson <lp15@cam.ac.uk>
parents: 68058
diff changeset
  3260
      by (rule card_image) (use translate_inj_on in blast)
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3261
    ultimately have "card (B-{a}) > 0" by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3262
    then have *: "finite (B - {a})"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3263
      using card_gt_0_iff[of "(B - {a})"] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3264
    then have "card (B - {a}) = card B - 1"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3265
      using card_Diff_singleton assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3266
    with * show ?thesis using fin h1 by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3267
  qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3268
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3269
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3270
lemma aff_dim_parallel_subspace:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3271
  fixes V L :: "'n::euclidean_space set"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3272
  assumes "V \<noteq> {}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3273
    and "subspace L"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3274
    and "affine_parallel (affine hull V) L"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3275
  shows "aff_dim V = int (dim L)"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3276
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3277
  obtain B where
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3278
    B: "affine hull B = affine hull V \<and> \<not> affine_dependent B \<and> int (card B) = aff_dim V + 1"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3279
    using aff_dim_basis_exists by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3280
  then have "B \<noteq> {}"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3281
    using assms B affine_hull_nonempty[of V] affine_hull_nonempty[of B]
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3282
    by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3283
  then obtain a where a: "a \<in> B" by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  3284
  define Lb where "Lb = span ((\<lambda>x. -a+x) ` (B-{a}))"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3285
  moreover have "affine_parallel (affine hull B) Lb"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3286
    using Lb_def B assms affine_hull_span2[of a B] a
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3287
      affine_parallel_commut[of "Lb" "(affine hull B)"]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3288
    unfolding affine_parallel_def
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3289
    by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3290
  moreover have "subspace Lb"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3291
    using Lb_def subspace_span by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3292
  moreover have "affine hull B \<noteq> {}"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3293
    using assms B affine_hull_nonempty[of V] by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3294
  ultimately have "L = Lb"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3295
    using assms affine_parallel_subspace[of "affine hull B"] affine_affine_hull[of B] B
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3296
    by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3297
  then have "dim L = dim Lb"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3298
    by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3299
  moreover have "card B - 1 = dim Lb" and "finite B"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3300
    using Lb_def aff_dim_parallel_subspace_aux a B by auto
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3301
  ultimately show ?thesis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3302
    using B \<open>B \<noteq> {}\<close> card_gt_0_iff[of B] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3303
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3304
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3305
lemma aff_independent_finite:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3306
  fixes B :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3307
  assumes "\<not> affine_dependent B"
53302
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3308
  shows "finite B"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3309
proof -
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3310
  {
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3311
    assume "B \<noteq> {}"
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3312
    then obtain a where "a \<in> B" by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3313
    then have ?thesis
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3314
      using aff_dim_parallel_subspace_aux assms by auto
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3315
  }
98fdf6c34142 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3316
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3317
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3318
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  3319
lemmas independent_finite = independent_imp_finite
63075
60a42a4166af lemmas about dimension, hyperplanes, span, etc.
paulson <lp15@cam.ac.uk>
parents: 63072
diff changeset
  3320
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  3321
lemma span_substd_basis:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  3322
  assumes d: "d \<subseteq> Basis"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3323
  shows "span d = {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3324
  (is "_ = ?B")
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3325
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3326
  have "d \<subseteq> ?B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3327
    using d by (auto simp: inner_Basis)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3328
  moreover have s: "subspace ?B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3329
    using subspace_substandard[of "\<lambda>i. i \<notin> d"] .
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3330
  ultimately have "span d \<subseteq> ?B"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  3331
    using span_mono[of d "?B"] span_eq_iff[of "?B"] by blast
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53348
diff changeset
  3332
  moreover have *: "card d \<le> dim (span d)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  3333
    using independent_card_le_dim[of d "span d"] independent_substdbasis[OF assms]
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  3334
      span_superset[of d]
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3335
    by auto
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53348
diff changeset
  3336
  moreover from * have "dim ?B \<le> dim (span d)"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3337
    using dim_substandard[OF assms] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3338
  ultimately show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3339
    using s subspace_dim_equal[of "span d" "?B"] subspace_span[of d] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3340
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3341
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3342
lemma basis_to_substdbasis_subspace_isomorphism:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3343
  fixes B :: "'a::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3344
  assumes "independent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3345
  shows "\<exists>f d::'a set. card d = card B \<and> linear f \<and> f ` B = d \<and>
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3346
    f ` span B = {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0} \<and> inj_on f (span B) \<and> d \<subseteq> Basis"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3347
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3348
  have B: "card B = dim B"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  3349
    using dim_unique[of B B "card B"] assms span_superset[of B] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3350
  have "dim B \<le> card (Basis :: 'a set)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3351
    using dim_subset_UNIV[of B] by simp
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3352
  from ex_card[OF this] obtain d :: "'a set" where d: "d \<subseteq> Basis" and t: "card d = dim B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3353
    by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3354
  let ?t = "{x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3355
  have "\<exists>f. linear f \<and> f ` B = d \<and> f ` span B = ?t \<and> inj_on f (span B)"
68074
8d50467f7555 fixed HOL-Analysis
immler
parents: 68073
diff changeset
  3356
  proof (intro basis_to_basis_subspace_isomorphism subspace_span subspace_substandard span_superset)
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  3357
    show "d \<subseteq> {x. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x \<bullet> i = 0}"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  3358
      using d inner_not_same_Basis by blast
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  3359
  qed (auto simp: span_substd_basis independent_substdbasis dim_substandard d t B assms)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3360
  with t \<open>card B = dim B\<close> d show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3361
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3362
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3363
lemma aff_dim_empty:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3364
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3365
  shows "S = {} \<longleftrightarrow> aff_dim S = -1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3366
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3367
  obtain B where *: "affine hull B = affine hull S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3368
    and "\<not> affine_dependent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3369
    and "int (card B) = aff_dim S + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3370
    using aff_dim_basis_exists by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3371
  moreover
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3372
  from * have "S = {} \<longleftrightarrow> B = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3373
    using affine_hull_nonempty[of B] affine_hull_nonempty[of S] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3374
  ultimately show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3375
    using aff_independent_finite[of B] card_gt_0_iff[of B] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3376
qed
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3377
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3378
lemma aff_dim_empty_eq [simp]: "aff_dim ({}::'a::euclidean_space set) = -1"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3379
  by (simp add: aff_dim_empty [symmetric])
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3380
63075
60a42a4166af lemmas about dimension, hyperplanes, span, etc.
paulson <lp15@cam.ac.uk>
parents: 63072
diff changeset
  3381
lemma aff_dim_affine_hull [simp]: "aff_dim (affine hull S) = aff_dim S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3382
  unfolding aff_dim_def using hull_hull[of _ S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3383
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3384
lemma aff_dim_affine_hull2:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3385
  assumes "affine hull S = affine hull T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3386
  shows "aff_dim S = aff_dim T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3387
  unfolding aff_dim_def using assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3388
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3389
lemma aff_dim_unique:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3390
  fixes B V :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3391
  assumes "affine hull B = affine hull V \<and> \<not> affine_dependent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3392
  shows "of_nat (card B) = aff_dim V + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3393
proof (cases "B = {}")
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3394
  case True
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3395
  then have "V = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3396
    using affine_hull_nonempty[of V] affine_hull_nonempty[of B] assms
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3397
    by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3398
  then have "aff_dim V = (-1::int)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3399
    using aff_dim_empty by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3400
  then show ?thesis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3401
    using \<open>B = {}\<close> by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3402
next
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3403
  case False
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3404
  then obtain a where a: "a \<in> B" by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  3405
  define Lb where "Lb = span ((\<lambda>x. -a+x) ` (B-{a}))"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3406
  have "affine_parallel (affine hull B) Lb"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3407
    using Lb_def affine_hull_span2[of a B] a
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3408
      affine_parallel_commut[of "Lb" "(affine hull B)"]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3409
    unfolding affine_parallel_def by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3410
  moreover have "subspace Lb"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3411
    using Lb_def subspace_span by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3412
  ultimately have "aff_dim B = int(dim Lb)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3413
    using aff_dim_parallel_subspace[of B Lb] \<open>B \<noteq> {}\<close> by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3414
  moreover have "(card B) - 1 = dim Lb" "finite B"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  3415
    using Lb_def aff_dim_parallel_subspace_aux a assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3416
  ultimately have "of_nat (card B) = aff_dim B + 1"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3417
    using \<open>B \<noteq> {}\<close> card_gt_0_iff[of B] by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3418
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3419
    using aff_dim_affine_hull2 assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3420
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3421
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3422
lemma aff_dim_affine_independent:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3423
  fixes B :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3424
  assumes "\<not> affine_dependent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3425
  shows "of_nat (card B) = aff_dim B + 1"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3426
  using aff_dim_unique[of B B] assms by auto
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3427
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3428
lemma affine_independent_iff_card:
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3429
    fixes s :: "'a::euclidean_space set"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3430
    shows "~ affine_dependent s \<longleftrightarrow> finite s \<and> aff_dim s = int(card s) - 1"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3431
  apply (rule iffI)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3432
  apply (simp add: aff_dim_affine_independent aff_independent_finite)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3433
  by (metis affine_basis_exists [of s] aff_dim_unique card_subset_eq diff_add_cancel of_nat_eq_iff)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3434
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  3435
lemma aff_dim_sing [simp]:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3436
  fixes a :: "'n::euclidean_space"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3437
  shows "aff_dim {a} = 0"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3438
  using aff_dim_affine_independent[of "{a}"] affine_independent_1 by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3439
63881
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3440
lemma aff_dim_2 [simp]: "aff_dim {a,b} = (if a = b then 0 else 1)"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3441
proof (clarsimp)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3442
  assume "a \<noteq> b"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3443
  then have "aff_dim{a,b} = card{a,b} - 1"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3444
    using affine_independent_2 [of a b] aff_dim_affine_independent by fastforce
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3445
  also have "\<dots> = 1"
63881
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3446
    using \<open>a \<noteq> b\<close> by simp
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3447
  finally show "aff_dim {a, b} = 1" .
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3448
qed
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3449
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3450
lemma aff_dim_inner_basis_exists:
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3451
  fixes V :: "('n::euclidean_space) set"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3452
  shows "\<exists>B. B \<subseteq> V \<and> affine hull B = affine hull V \<and>
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3453
    \<not> affine_dependent B \<and> of_nat (card B) = aff_dim V + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3454
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3455
  obtain B where B: "\<not> affine_dependent B" "B \<subseteq> V" "affine hull B = affine hull V"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3456
    using affine_basis_exists[of V] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3457
  then have "of_nat(card B) = aff_dim V+1" using aff_dim_unique by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3458
  with B show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3459
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3460
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3461
lemma aff_dim_le_card:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3462
  fixes V :: "'n::euclidean_space set"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3463
  assumes "finite V"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3464
  shows "aff_dim V \<le> of_nat (card V) - 1"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3465
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3466
  obtain B where B: "B \<subseteq> V" "of_nat (card B) = aff_dim V + 1"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3467
    using aff_dim_inner_basis_exists[of V] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3468
  then have "card B \<le> card V"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3469
    using assms card_mono by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3470
  with B show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3471
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3472
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3473
lemma aff_dim_parallel_eq:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3474
  fixes S T :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3475
  assumes "affine_parallel (affine hull S) (affine hull T)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3476
  shows "aff_dim S = aff_dim T"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3477
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3478
  {
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3479
    assume "T \<noteq> {}" "S \<noteq> {}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3480
    then obtain L where L: "subspace L \<and> affine_parallel (affine hull T) L"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3481
      using affine_parallel_subspace[of "affine hull T"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3482
        affine_affine_hull[of T] affine_hull_nonempty
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3483
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3484
    then have "aff_dim T = int (dim L)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3485
      using aff_dim_parallel_subspace \<open>T \<noteq> {}\<close> by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3486
    moreover have *: "subspace L \<and> affine_parallel (affine hull S) L"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3487
       using L affine_parallel_assoc[of "affine hull S" "affine hull T" L] assms by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3488
    moreover from * have "aff_dim S = int (dim L)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3489
      using aff_dim_parallel_subspace \<open>S \<noteq> {}\<close> by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3490
    ultimately have ?thesis by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3491
  }
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3492
  moreover
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3493
  {
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3494
    assume "S = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3495
    then have "S = {}" and "T = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3496
      using assms affine_hull_nonempty
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3497
      unfolding affine_parallel_def
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3498
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3499
    then have ?thesis using aff_dim_empty by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3500
  }
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3501
  moreover
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3502
  {
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3503
    assume "T = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3504
    then have "S = {}" and "T = {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3505
      using assms affine_hull_nonempty
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3506
      unfolding affine_parallel_def
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3507
      by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3508
    then have ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3509
      using aff_dim_empty by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3510
  }
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3511
  ultimately show ?thesis by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3512
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3513
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3514
lemma aff_dim_translation_eq:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3515
  fixes a :: "'n::euclidean_space"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3516
  shows "aff_dim ((\<lambda>x. a + x) ` S) = aff_dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3517
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3518
  have "affine_parallel (affine hull S) (affine hull ((\<lambda>x. a + x) ` S))"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3519
    unfolding affine_parallel_def
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3520
    apply (rule exI[of _ "a"])
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3521
    using affine_hull_translation[of a S]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3522
    apply auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3523
    done
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3524
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3525
    using aff_dim_parallel_eq[of S "(\<lambda>x. a + x) ` S"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3526
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3527
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3528
lemma aff_dim_affine:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3529
  fixes S L :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3530
  assumes "S \<noteq> {}"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3531
    and "affine S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3532
    and "subspace L"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3533
    and "affine_parallel S L"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3534
  shows "aff_dim S = int (dim L)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3535
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3536
  have *: "affine hull S = S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3537
    using assms affine_hull_eq[of S] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3538
  then have "affine_parallel (affine hull S) L"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3539
    using assms by (simp add: *)
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3540
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3541
    using assms aff_dim_parallel_subspace[of S L] by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3542
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3543
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3544
lemma dim_affine_hull:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3545
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3546
  shows "dim (affine hull S) = dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3547
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3548
  have "dim (affine hull S) \<ge> dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3549
    using dim_subset by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3550
  moreover have "dim (span S) \<ge> dim (affine hull S)"
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  3551
    using dim_subset affine_hull_subset_span by blast
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3552
  moreover have "dim (span S) = dim S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3553
    using dim_span by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3554
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3555
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3556
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3557
lemma aff_dim_subspace:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3558
  fixes S :: "'n::euclidean_space set"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3559
  assumes "subspace S"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3560
  shows "aff_dim S = int (dim S)"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3561
proof (cases "S={}")
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3562
  case True with assms show ?thesis
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3563
    by (simp add: subspace_affine)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3564
next
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3565
  case False
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3566
  with aff_dim_affine[of S S] assms subspace_imp_affine[of S] affine_parallel_reflex[of S] subspace_affine
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3567
  show ?thesis by auto
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3568
qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3569
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3570
lemma aff_dim_zero:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3571
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3572
  assumes "0 \<in> affine hull S"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3573
  shows "aff_dim S = int (dim S)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3574
proof -
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3575
  have "subspace (affine hull S)"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3576
    using subspace_affine[of "affine hull S"] affine_affine_hull assms
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3577
    by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3578
  then have "aff_dim (affine hull S) = int (dim (affine hull S))"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3579
    using assms aff_dim_subspace[of "affine hull S"] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3580
  then show ?thesis
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3581
    using aff_dim_affine_hull[of S] dim_affine_hull[of S]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3582
    by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3583
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3584
63016
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3585
lemma aff_dim_eq_dim:
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3586
  fixes S :: "'n::euclidean_space set"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3587
  assumes "a \<in> affine hull S"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3588
  shows "aff_dim S = int (dim ((\<lambda>x. -a+x) ` S))"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3589
proof -
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3590
  have "0 \<in> affine hull ((\<lambda>x. -a+x) ` S)"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3591
    unfolding Convex_Euclidean_Space.affine_hull_translation
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3592
    using assms by (simp add: ab_group_add_class.ab_left_minus image_iff)
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3593
  with aff_dim_zero show ?thesis
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3594
    by (metis aff_dim_translation_eq)
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3595
qed
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3596
63072
eb5d493a9e03 renamings and refinements
paulson <lp15@cam.ac.uk>
parents: 63040
diff changeset
  3597
lemma aff_dim_UNIV [simp]: "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3598
  using aff_dim_subspace[of "(UNIV :: 'n::euclidean_space set)"]
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3599
    dim_UNIV[where 'a="'n::euclidean_space"]
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3600
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3601
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3602
lemma aff_dim_geq:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3603
  fixes V :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3604
  shows "aff_dim V \<ge> -1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3605
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3606
  obtain B where "affine hull B = affine hull V"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3607
    and "\<not> affine_dependent B"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3608
    and "int (card B) = aff_dim V + 1"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3609
    using aff_dim_basis_exists by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3610
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3611
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3612
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  3613
lemma aff_dim_negative_iff [simp]:
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  3614
  fixes S :: "'n::euclidean_space set"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  3615
  shows "aff_dim S < 0 \<longleftrightarrow>S = {}"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  3616
by (metis aff_dim_empty aff_dim_geq diff_0 eq_iff zle_diff1_eq)
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  3617
66641
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3618
lemma aff_lowdim_subset_hyperplane:
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3619
  fixes S :: "'a::euclidean_space set"
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3620
  assumes "aff_dim S < DIM('a)"
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3621
  obtains a b where "a \<noteq> 0" "S \<subseteq> {x. a \<bullet> x = b}"
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3622
proof (cases "S={}")
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3623
  case True
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3624
  moreover
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3625
  have "(SOME b. b \<in> Basis) \<noteq> 0"
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3626
    by (metis norm_some_Basis norm_zero zero_neq_one)
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3627
  ultimately show ?thesis
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3628
    using that by blast
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3629
next
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3630
  case False
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3631
  then obtain c S' where "c \<notin> S'" "S = insert c S'"
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3632
    by (meson equals0I mk_disjoint_insert)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  3633
  have "dim ((+) (-c) ` S) < DIM('a)"
66641
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3634
    by (metis \<open>S = insert c S'\<close> aff_dim_eq_dim assms hull_inc insertI1 of_nat_less_imp_less)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  3635
  then obtain a where "a \<noteq> 0" "span ((+) (-c) ` S) \<subseteq> {x. a \<bullet> x = 0}"
66641
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3636
    using lowdim_subset_hyperplane by blast
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3637
  moreover
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  3638
  have "a \<bullet> w = a \<bullet> c" if "span ((+) (- c) ` S) \<subseteq> {x. a \<bullet> x = 0}" "w \<in> S" for w
66641
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3639
  proof -
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  3640
    have "w-c \<in> span ((+) (- c) ` S)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  3641
      by (simp add: span_base \<open>w \<in> S\<close>)
66641
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3642
    with that have "w-c \<in> {x. a \<bullet> x = 0}"
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3643
      by blast
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3644
    then show ?thesis
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3645
      by (auto simp: algebra_simps)
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3646
  qed
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3647
  ultimately have "S \<subseteq> {x. a \<bullet> x = a \<bullet> c}"
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3648
    by blast
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3649
  then show ?thesis
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3650
    by (rule that[OF \<open>a \<noteq> 0\<close>])
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3651
qed
ff2e0115fea4 Simplicial complexes and triangulations; Baire Category Theorem
paulson <lp15@cam.ac.uk>
parents: 66453
diff changeset
  3652
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3653
lemma affine_independent_card_dim_diffs:
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3654
  fixes S :: "'a :: euclidean_space set"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3655
  assumes "~ affine_dependent S" "a \<in> S"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3656
    shows "card S = dim {x - a|x. x \<in> S} + 1"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3657
proof -
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3658
  have 1: "{b - a|b. b \<in> (S - {a})} \<subseteq> {x - a|x. x \<in> S}" by auto
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3659
  have 2: "x - a \<in> span {b - a |b. b \<in> S - {a}}" if "x \<in> S" for x
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3660
  proof (cases "x = a")
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  3661
    case True then show ?thesis by (simp add: span_clauses)
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3662
  next
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3663
    case False then show ?thesis
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  3664
      using assms by (blast intro: span_base that)
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3665
  qed
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3666
  have "\<not> affine_dependent (insert a S)"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3667
    by (simp add: assms insert_absorb)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3668
  then have 3: "independent {b - a |b. b \<in> S - {a}}"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3669
      using dependent_imp_affine_dependent by fastforce
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3670
  have "{b - a |b. b \<in> S - {a}} = (\<lambda>b. b-a) ` (S - {a})"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3671
    by blast
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3672
  then have "card {b - a |b. b \<in> S - {a}} = card ((\<lambda>b. b-a) ` (S - {a}))"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3673
    by simp
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3674
  also have "\<dots> = card (S - {a})"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3675
    by (metis (no_types, lifting) card_image diff_add_cancel inj_onI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3676
  also have "\<dots> = card S - 1"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3677
    by (simp add: aff_independent_finite assms)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3678
  finally have 4: "card {b - a |b. b \<in> S - {a}} = card S - 1" .
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3679
  have "finite S"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3680
    by (meson assms aff_independent_finite)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3681
  with \<open>a \<in> S\<close> have "card S \<noteq> 0" by auto
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3682
  moreover have "dim {x - a |x. x \<in> S} = card S - 1"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3683
    using 2 by (blast intro: dim_unique [OF 1 _ 3 4])
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3684
  ultimately show ?thesis
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3685
    by auto
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3686
qed
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  3687
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3688
lemma independent_card_le_aff_dim:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3689
  fixes B :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3690
  assumes "B \<subseteq> V"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3691
  assumes "\<not> affine_dependent B"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3692
  shows "int (card B) \<le> aff_dim V + 1"
63016
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3693
proof -
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3694
  obtain T where T: "\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3695
    by (metis assms extend_to_affine_basis[of B V])
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3696
  then have "of_nat (card T) = aff_dim V + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3697
    using aff_dim_unique by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3698
  then show ?thesis
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3699
    using T card_mono[of T B] aff_independent_finite[of T] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3700
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3701
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3702
lemma aff_dim_subset:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3703
  fixes S T :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3704
  assumes "S \<subseteq> T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3705
  shows "aff_dim S \<le> aff_dim T"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3706
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3707
  obtain B where B: "\<not> affine_dependent B" "B \<subseteq> S" "affine hull B = affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3708
    "of_nat (card B) = aff_dim S + 1"
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3709
    using aff_dim_inner_basis_exists[of S] by auto
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3710
  then have "int (card B) \<le> aff_dim T + 1"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3711
    using assms independent_card_le_aff_dim[of B T] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3712
  with B show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3713
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3714
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3715
lemma aff_dim_le_DIM:
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3716
  fixes S :: "'n::euclidean_space set"
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3717
  shows "aff_dim S \<le> int (DIM('n))"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3718
proof -
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3719
  have "aff_dim (UNIV :: 'n::euclidean_space set) = int(DIM('n))"
63072
eb5d493a9e03 renamings and refinements
paulson <lp15@cam.ac.uk>
parents: 63040
diff changeset
  3720
    using aff_dim_UNIV by auto
53339
0dc28fd72c7d tuned proofs;
wenzelm
parents: 53333
diff changeset
  3721
  then show "aff_dim (S:: 'n::euclidean_space set) \<le> int(DIM('n))"
63092
a949b2a5f51d eliminated use of empty "assms";
wenzelm
parents: 63077
diff changeset
  3722
    using aff_dim_subset[of S "(UNIV :: ('n::euclidean_space) set)"] subset_UNIV by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3723
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3724
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3725
lemma affine_dim_equal:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3726
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3727
  assumes "affine S" "affine T" "S \<noteq> {}" "S \<subseteq> T" "aff_dim S = aff_dim T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3728
  shows "S = T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3729
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3730
  obtain a where "a \<in> S" using assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3731
  then have "a \<in> T" using assms by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  3732
  define LS where "LS = {y. \<exists>x \<in> S. (-a) + x = y}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3733
  then have ls: "subspace LS" "affine_parallel S LS"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3734
    using assms parallel_subspace_explicit[of S a LS] \<open>a \<in> S\<close> by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3735
  then have h1: "int(dim LS) = aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3736
    using assms aff_dim_affine[of S LS] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3737
  have "T \<noteq> {}" using assms by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  3738
  define LT where "LT = {y. \<exists>x \<in> T. (-a) + x = y}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3739
  then have lt: "subspace LT \<and> affine_parallel T LT"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3740
    using assms parallel_subspace_explicit[of T a LT] \<open>a \<in> T\<close> by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3741
  then have "int(dim LT) = aff_dim T"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3742
    using assms aff_dim_affine[of T LT] \<open>T \<noteq> {}\<close> by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3743
  then have "dim LS = dim LT"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3744
    using h1 assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3745
  moreover have "LS \<le> LT"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3746
    using LS_def LT_def assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3747
  ultimately have "LS = LT"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3748
    using subspace_dim_equal[of LS LT] ls lt by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3749
  moreover have "S = {x. \<exists>y \<in> LS. a+y=x}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3750
    using LS_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3751
  moreover have "T = {x. \<exists>y \<in> LT. a+y=x}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3752
    using LT_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3753
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3754
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3755
63881
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3756
lemma aff_dim_eq_0:
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3757
  fixes S :: "'a::euclidean_space set"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3758
  shows "aff_dim S = 0 \<longleftrightarrow> (\<exists>a. S = {a})"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3759
proof (cases "S = {}")
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3760
  case True
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3761
  then show ?thesis
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3762
    by auto
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3763
next
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3764
  case False
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3765
  then obtain a where "a \<in> S" by auto
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3766
  show ?thesis
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3767
  proof safe
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3768
    assume 0: "aff_dim S = 0"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3769
    have "~ {a,b} \<subseteq> S" if "b \<noteq> a" for b
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3770
      by (metis "0" aff_dim_2 aff_dim_subset not_one_le_zero that)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3771
    then show "\<exists>a. S = {a}"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3772
      using \<open>a \<in> S\<close> by blast
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3773
  qed auto
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3774
qed
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3775
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3776
lemma affine_hull_UNIV:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3777
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3778
  assumes "aff_dim S = int(DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3779
  shows "affine hull S = (UNIV :: ('n::euclidean_space) set)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3780
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3781
  have "S \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3782
    using assms aff_dim_empty[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3783
  have h0: "S \<subseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3784
    using hull_subset[of S _] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3785
  have h1: "aff_dim (UNIV :: ('n::euclidean_space) set) = aff_dim S"
63072
eb5d493a9e03 renamings and refinements
paulson <lp15@cam.ac.uk>
parents: 63040
diff changeset
  3786
    using aff_dim_UNIV assms by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3787
  then have h2: "aff_dim (affine hull S) \<le> aff_dim (UNIV :: ('n::euclidean_space) set)"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3788
    using aff_dim_le_DIM[of "affine hull S"] assms h0 by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3789
  have h3: "aff_dim S \<le> aff_dim (affine hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3790
    using h0 aff_dim_subset[of S "affine hull S"] assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3791
  then have h4: "aff_dim (affine hull S) = aff_dim (UNIV :: ('n::euclidean_space) set)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3792
    using h0 h1 h2 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3793
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3794
    using affine_dim_equal[of "affine hull S" "(UNIV :: ('n::euclidean_space) set)"]
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  3795
      affine_affine_hull[of S] affine_UNIV assms h4 h0 \<open>S \<noteq> {}\<close>
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3796
    by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3797
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3798
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3799
lemma disjoint_affine_hull:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3800
  fixes s :: "'n::euclidean_space set"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3801
  assumes "~ affine_dependent s" "t \<subseteq> s" "u \<subseteq> s" "t \<inter> u = {}"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3802
    shows "(affine hull t) \<inter> (affine hull u) = {}"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3803
proof -
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3804
  have "finite s" using assms by (simp add: aff_independent_finite)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3805
  then have "finite t" "finite u" using assms finite_subset by blast+
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3806
  { fix y
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3807
    assume yt: "y \<in> affine hull t" and yu: "y \<in> affine hull u"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3808
    then obtain a b
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3809
           where a1 [simp]: "sum a t = 1" and [simp]: "sum (\<lambda>v. a v *\<^sub>R v) t = y"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3810
             and [simp]: "sum b u = 1" "sum (\<lambda>v. b v *\<^sub>R v) u = y"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3811
      by (auto simp: affine_hull_finite \<open>finite t\<close> \<open>finite u\<close>)
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  3812
    define c where "c x = (if x \<in> t then a x else if x \<in> u then -(b x) else 0)" for x
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3813
    have [simp]: "s \<inter> t = t" "s \<inter> - t \<inter> u = u" using assms by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3814
    have "sum c s = 0"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3815
      by (simp add: c_def comm_monoid_add_class.sum.If_cases \<open>finite s\<close> sum_negf)
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3816
    moreover have "~ (\<forall>v\<in>s. c v = 0)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3817
      by (metis (no_types) IntD1 \<open>s \<inter> t = t\<close> a1 c_def sum_not_0 zero_neq_one)
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3818
    moreover have "(\<Sum>v\<in>s. c v *\<^sub>R v) = 0"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3819
      by (simp add: c_def if_smult sum_negf
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3820
             comm_monoid_add_class.sum.If_cases \<open>finite s\<close>)
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3821
    ultimately have False
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3822
      using assms \<open>finite s\<close> by (auto simp: affine_dependent_explicit)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3823
  }
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3824
  then show ?thesis by blast
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3825
qed
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3826
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3827
lemma aff_dim_convex_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3828
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3829
  shows "aff_dim (convex hull S) = aff_dim S"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  3830
  using aff_dim_affine_hull[of S] convex_hull_subset_affine_hull[of S]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3831
    hull_subset[of S "convex"] aff_dim_subset[of S "convex hull S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3832
    aff_dim_subset[of "convex hull S" "affine hull S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3833
  by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3834
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3835
lemma aff_dim_cball:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3836
  fixes a :: "'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3837
  assumes "e > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3838
  shows "aff_dim (cball a e) = int (DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3839
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3840
  have "(\<lambda>x. a + x) ` (cball 0 e) \<subseteq> cball a e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3841
    unfolding cball_def dist_norm by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3842
  then have "aff_dim (cball (0 :: 'n::euclidean_space) e) \<le> aff_dim (cball a e)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3843
    using aff_dim_translation_eq[of a "cball 0 e"]
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  3844
          aff_dim_subset[of "(+) a ` cball 0 e" "cball a e"]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3845
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3846
  moreover have "aff_dim (cball (0 :: 'n::euclidean_space) e) = int (DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3847
    using hull_inc[of "(0 :: 'n::euclidean_space)" "cball 0 e"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3848
      centre_in_cball[of "(0 :: 'n::euclidean_space)"] assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3849
    by (simp add: dim_cball[of e] aff_dim_zero[of "cball 0 e"])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3850
  ultimately show ?thesis
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3851
    using aff_dim_le_DIM[of "cball a e"] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3852
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3853
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3854
lemma aff_dim_open:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3855
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3856
  assumes "open S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3857
    and "S \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3858
  shows "aff_dim S = int (DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3859
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3860
  obtain x where "x \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3861
    using assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3862
  then obtain e where e: "e > 0" "cball x e \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3863
    using open_contains_cball[of S] assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3864
  then have "aff_dim (cball x e) \<le> aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3865
    using aff_dim_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3866
  with e show ?thesis
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3867
    using aff_dim_cball[of e x] aff_dim_le_DIM[of S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3868
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3869
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3870
lemma low_dim_interior:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3871
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3872
  assumes "\<not> aff_dim S = int (DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3873
  shows "interior S = {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3874
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3875
  have "aff_dim(interior S) \<le> aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3876
    using interior_subset aff_dim_subset[of "interior S" S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  3877
  then show ?thesis
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3878
    using aff_dim_open[of "interior S"] aff_dim_le_DIM[of S] assms by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3879
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  3880
60307
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  3881
corollary empty_interior_lowdim:
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  3882
  fixes S :: "'n::euclidean_space set"
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  3883
  shows "dim S < DIM ('n) \<Longrightarrow> interior S = {}"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  3884
by (metis low_dim_interior affine_hull_UNIV dim_affine_hull less_not_refl dim_UNIV)
60307
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  3885
63016
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3886
corollary aff_dim_nonempty_interior:
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3887
  fixes S :: "'a::euclidean_space set"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3888
  shows "interior S \<noteq> {} \<Longrightarrow> aff_dim S = DIM('a)"
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3889
by (metis low_dim_interior)
3590590699b1 numerous theorems about affine hulls, hyperplanes, etc.
paulson <lp15@cam.ac.uk>
parents: 63007
diff changeset
  3890
63881
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  3891
67968
a5ad4c015d1c removed dots at the end of (sub)titles
nipkow
parents: 67962
diff changeset
  3892
subsection \<open>Caratheodory's theorem\<close>
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3893
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3894
lemma convex_hull_caratheodory_aff_dim:
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3895
  fixes p :: "('a::euclidean_space) set"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3896
  shows "convex hull p =
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3897
    {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> aff_dim p + 1 \<and>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3898
      (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) s = y}"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3899
  unfolding convex_hull_explicit set_eq_iff mem_Collect_eq
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3900
proof (intro allI iffI)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3901
  fix y
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3902
  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>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3903
    sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3904
  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"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3905
  then obtain N where "?P N" by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3906
  then have "\<exists>n\<le>N. (\<forall>k<n. \<not> ?P k) \<and> ?P n"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3907
    apply (rule_tac ex_least_nat_le, auto)
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3908
    done
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3909
  then obtain n where "?P n" and smallest: "\<forall>k<n. \<not> ?P k"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3910
    by blast
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3911
  then obtain s u where obt: "finite s" "card s = n" "s\<subseteq>p" "\<forall>x\<in>s. 0 \<le> u x"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3912
    "sum u s = 1"  "(\<Sum>v\<in>s. u v *\<^sub>R v) = y" by auto
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3913
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3914
  have "card s \<le> aff_dim p + 1"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3915
  proof (rule ccontr, simp only: not_le)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3916
    assume "aff_dim p + 1 < card s"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3917
    then have "affine_dependent s"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3918
      using affine_dependent_biggerset[OF obt(1)] independent_card_le_aff_dim not_less obt(3)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3919
      by blast
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3920
    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"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3921
      using affine_dependent_explicit_finite[OF obt(1)] by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  3922
    define i where "i = (\<lambda>v. (u v) / (- w v)) ` {v\<in>s. w v < 0}"
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  3923
    define t where "t = Min i"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3924
    have "\<exists>x\<in>s. w x < 0"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3925
    proof (rule ccontr, simp add: not_less)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3926
      assume as:"\<forall>x\<in>s. 0 \<le> w x"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3927
      then have "sum w (s - {v}) \<ge> 0"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3928
        apply (rule_tac sum_nonneg, auto)
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3929
        done
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3930
      then have "sum w s > 0"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3931
        unfolding sum.remove[OF obt(1) \<open>v\<in>s\<close>]
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3932
        using as[THEN bspec[where x=v]]  \<open>v\<in>s\<close>  \<open>w v \<noteq> 0\<close> by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3933
      then show False using wv(1) by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3934
    qed
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3935
    then have "i \<noteq> {}" unfolding i_def by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3936
    then have "t \<ge> 0"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3937
      using Min_ge_iff[of i 0 ] and obt(1)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3938
      unfolding t_def i_def
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3939
      using obt(4)[unfolded le_less]
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3940
      by (auto simp: divide_le_0_iff)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3941
    have t: "\<forall>v\<in>s. u v + t * w v \<ge> 0"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3942
    proof
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3943
      fix v
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3944
      assume "v \<in> s"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3945
      then have v: "0 \<le> u v"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3946
        using obt(4)[THEN bspec[where x=v]] by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3947
      show "0 \<le> u v + t * w v"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3948
      proof (cases "w v < 0")
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3949
        case False
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3950
        thus ?thesis using v \<open>t\<ge>0\<close> by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3951
      next
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3952
        case True
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3953
        then have "t \<le> u v / (- w v)"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3954
          using \<open>v\<in>s\<close> unfolding t_def i_def
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3955
          apply (rule_tac Min_le)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3956
          using obt(1) apply auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3957
          done
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3958
        then show ?thesis
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3959
          unfolding real_0_le_add_iff
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3960
          using pos_le_divide_eq[OF True[unfolded neg_0_less_iff_less[symmetric]]]
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3961
          by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3962
      qed
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3963
    qed
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3964
    obtain a where "a \<in> s" and "t = (\<lambda>v. (u v) / (- w v)) a" and "w a < 0"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3965
      using Min_in[OF _ \<open>i\<noteq>{}\<close>] and obt(1) unfolding i_def t_def by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3966
    then have a: "a \<in> s" "u a + t * w a = 0" by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3967
    have *: "\<And>f. sum f (s - {a}) = sum f s - ((f a)::'b::ab_group_add)"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3968
      unfolding sum.remove[OF obt(1) \<open>a\<in>s\<close>] by auto
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3969
    have "(\<Sum>v\<in>s. u v + t * w v) = 1"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3970
      unfolding sum.distrib wv(1) sum_distrib_left[symmetric] obt(5) by auto
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3971
    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"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3972
      unfolding sum.distrib obt(6) scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] wv(4)
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3973
      using a(2) [THEN eq_neg_iff_add_eq_0 [THEN iffD2]] by simp
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3974
    ultimately have "?P (n - 1)"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3975
      apply (rule_tac x="(s - {a})" in exI)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3976
      apply (rule_tac x="\<lambda>v. u v + t * w v" in exI)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3977
      using obt(1-3) and t and a
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3978
      apply (auto simp: * scaleR_left_distrib)
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3979
      done
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3980
    then show False
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3981
      using smallest[THEN spec[where x="n - 1"]] by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3982
  qed
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3983
  then show "\<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> aff_dim p + 1 \<and>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  3984
      (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> (\<Sum>v\<in>s. u v *\<^sub>R v) = y"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3985
    using obt by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3986
qed auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3987
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3988
lemma caratheodory_aff_dim:
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3989
  fixes p :: "('a::euclidean_space) set"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3990
  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}"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3991
        (is "?lhs = ?rhs")
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3992
proof
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3993
  show "?lhs \<subseteq> ?rhs"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3994
    apply (subst convex_hull_caratheodory_aff_dim, clarify)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  3995
    apply (rule_tac x=s in exI)
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3996
    apply (simp add: hull_subset convex_explicit [THEN iffD1, OF convex_convex_hull])
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3997
    done
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3998
next
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  3999
  show "?rhs \<subseteq> ?lhs"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4000
    using hull_mono by blast
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4001
qed
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4002
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4003
lemma convex_hull_caratheodory:
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4004
  fixes p :: "('a::euclidean_space) set"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4005
  shows "convex hull p =
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4006
            {y. \<exists>s u. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  4007
              (\<forall>x\<in>s. 0 \<le> u x) \<and> sum u s = 1 \<and> sum (\<lambda>v. u v *\<^sub>R v) s = y}"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4008
        (is "?lhs = ?rhs")
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4009
proof (intro set_eqI iffI)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4010
  fix x
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4011
  assume "x \<in> ?lhs" then show "x \<in> ?rhs"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4012
    apply (simp only: convex_hull_caratheodory_aff_dim Set.mem_Collect_eq)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4013
    apply (erule ex_forward)+
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4014
    using aff_dim_le_DIM [of p]
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4015
    apply simp
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4016
    done
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4017
next
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4018
  fix x
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4019
  assume "x \<in> ?rhs" then show "x \<in> ?lhs"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4020
    by (auto simp: convex_hull_explicit)
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4021
qed
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4022
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  4023
theorem%important caratheodory:
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4024
  "convex hull p =
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4025
    {x::'a::euclidean_space. \<exists>s. finite s \<and> s \<subseteq> p \<and>
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4026
      card s \<le> DIM('a) + 1 \<and> x \<in> convex hull s}"
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  4027
proof%unimportant safe
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4028
  fix x
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4029
  assume "x \<in> convex hull p"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4030
  then obtain s u where "finite s" "s \<subseteq> p" "card s \<le> DIM('a) + 1"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  4031
    "\<forall>x\<in>s. 0 \<le> u x" "sum u s = 1" "(\<Sum>v\<in>s. u v *\<^sub>R v) = x"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4032
    unfolding convex_hull_caratheodory by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4033
  then show "\<exists>s. finite s \<and> s \<subseteq> p \<and> card s \<le> DIM('a) + 1 \<and> x \<in> convex hull s"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4034
    apply (rule_tac x=s in exI)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4035
    using hull_subset[of s convex]
63170
eae6549dbea2 tuned proofs, to allow unfold_abs_def;
wenzelm
parents: 63148
diff changeset
  4036
    using convex_convex_hull[simplified convex_explicit, of s,
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4037
      THEN spec[where x=s], THEN spec[where x=u]]
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4038
    apply auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4039
    done
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4040
next
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4041
  fix x s
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4042
  assume  "finite s" "s \<subseteq> p" "card s \<le> DIM('a) + 1" "x \<in> convex hull s"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4043
  then show "x \<in> convex hull p"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4044
    using hull_mono[OF \<open>s\<subseteq>p\<close>] by auto
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4045
qed
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4046
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  4047
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4048
subsection \<open>Relative interior of a set\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4049
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  4050
definition%important "rel_interior S =
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4051
  {x. \<exists>T. openin (subtopology euclidean (affine hull S)) T \<and> x \<in> T \<and> T \<subseteq> S}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4052
64287
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4053
lemma rel_interior_mono:
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4054
   "\<lbrakk>S \<subseteq> T; affine hull S = affine hull T\<rbrakk>
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4055
   \<Longrightarrow> (rel_interior S) \<subseteq> (rel_interior T)"
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4056
  by (auto simp: rel_interior_def)
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4057
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4058
lemma rel_interior_maximal:
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4059
   "\<lbrakk>T \<subseteq> S; openin(subtopology euclidean (affine hull S)) T\<rbrakk> \<Longrightarrow> T \<subseteq> (rel_interior S)"
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4060
  by (auto simp: rel_interior_def)
d85d88722745 more from moretop.ml
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
  4061
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4062
lemma rel_interior:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4063
  "rel_interior S = {x \<in> S. \<exists>T. open T \<and> x \<in> T \<and> T \<inter> affine hull S \<subseteq> S}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4064
  unfolding rel_interior_def[of S] openin_open[of "affine hull S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4065
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4066
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4067
  fix x T
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4068
  assume *: "x \<in> S" "open T" "x \<in> T" "T \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4069
  then have **: "x \<in> T \<inter> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4070
    using hull_inc by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  4071
  show "\<exists>Tb. (\<exists>Ta. open Ta \<and> Tb = affine hull S \<inter> Ta) \<and> x \<in> Tb \<and> Tb \<subseteq> S"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  4072
    apply (rule_tac x = "T \<inter> (affine hull S)" in exI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4073
    using * **
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4074
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4075
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4076
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4077
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4078
lemma mem_rel_interior: "x \<in> rel_interior S \<longleftrightarrow> (\<exists>T. open T \<and> x \<in> T \<inter> S \<and> T \<inter> affine hull S \<subseteq> S)"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4079
  by (auto simp: rel_interior)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4080
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4081
lemma mem_rel_interior_ball:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4082
  "x \<in> rel_interior S \<longleftrightarrow> x \<in> S \<and> (\<exists>e. e > 0 \<and> ball x e \<inter> affine hull S \<subseteq> S)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4083
  apply (simp add: rel_interior, safe)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4084
  apply (force simp: open_contains_ball)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4085
  apply (rule_tac x = "ball x e" in exI, simp)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4086
  done
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4087
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4088
lemma rel_interior_ball:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4089
  "rel_interior S = {x \<in> S. \<exists>e. e > 0 \<and> ball x e \<inter> affine hull S \<subseteq> S}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4090
  using mem_rel_interior_ball [of _ S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4091
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4092
lemma mem_rel_interior_cball:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4093
  "x \<in> rel_interior S \<longleftrightarrow> x \<in> S \<and> (\<exists>e. e > 0 \<and> cball x e \<inter> affine hull S \<subseteq> S)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4094
  apply (simp add: rel_interior, safe)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4095
  apply (force simp: open_contains_cball)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4096
  apply (rule_tac x = "ball x e" in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4097
  apply (simp add: subset_trans [OF ball_subset_cball], auto)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4098
  done
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4099
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4100
lemma rel_interior_cball:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4101
  "rel_interior S = {x \<in> S. \<exists>e. e > 0 \<and> cball x e \<inter> affine hull S \<subseteq> S}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4102
  using mem_rel_interior_cball [of _ S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4103
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4104
lemma rel_interior_empty [simp]: "rel_interior {} = {}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4105
   by (auto simp: rel_interior_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4106
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4107
lemma affine_hull_sing [simp]: "affine hull {a :: 'n::euclidean_space} = {a}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4108
  by (metis affine_hull_eq affine_sing)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4109
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  4110
lemma rel_interior_sing [simp]:
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  4111
    fixes a :: "'n::euclidean_space"  shows "rel_interior {a} = {a}"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  4112
  apply (auto simp: rel_interior_ball)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4113
  apply (rule_tac x=1 in exI, force)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4114
  done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4115
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4116
lemma subset_rel_interior:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4117
  fixes S T :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4118
  assumes "S \<subseteq> T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4119
    and "affine hull S = affine hull T"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4120
  shows "rel_interior S \<subseteq> rel_interior T"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4121
  using assms by (auto simp: rel_interior_def)
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4122
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4123
lemma rel_interior_subset: "rel_interior S \<subseteq> S"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4124
  by (auto simp: rel_interior_def)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4125
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4126
lemma rel_interior_subset_closure: "rel_interior S \<subseteq> closure S"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4127
  using rel_interior_subset by (auto simp: closure_def)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4128
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4129
lemma interior_subset_rel_interior: "interior S \<subseteq> rel_interior S"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4130
  by (auto simp: rel_interior interior_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4131
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4132
lemma interior_rel_interior:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4133
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4134
  assumes "aff_dim S = int(DIM('n))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4135
  shows "rel_interior S = interior S"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4136
proof -
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4137
  have "affine hull S = UNIV"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4138
    using assms affine_hull_UNIV[of S] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4139
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4140
    unfolding rel_interior interior_def by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4141
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4142
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4143
lemma rel_interior_interior:
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4144
  fixes S :: "'n::euclidean_space set"
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4145
  assumes "affine hull S = UNIV"
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4146
  shows "rel_interior S = interior S"
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4147
  using assms unfolding rel_interior interior_def by auto
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4148
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4149
lemma rel_interior_open:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4150
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4151
  assumes "open S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4152
  shows "rel_interior S = S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4153
  by (metis assms interior_eq interior_subset_rel_interior rel_interior_subset set_eq_subset)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4154
60800
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  4155
lemma interior_ball [simp]: "interior (ball x e) = ball x e"
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  4156
  by (simp add: interior_open)
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  4157
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4158
lemma interior_rel_interior_gen:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4159
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4160
  shows "interior S = (if aff_dim S = int(DIM('n)) then rel_interior S else {})"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4161
  by (metis interior_rel_interior low_dim_interior)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4162
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4163
lemma rel_interior_nonempty_interior:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4164
  fixes S :: "'n::euclidean_space set"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4165
  shows "interior S \<noteq> {} \<Longrightarrow> rel_interior S = interior S"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4166
by (metis interior_rel_interior_gen)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4167
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4168
lemma affine_hull_nonempty_interior:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4169
  fixes S :: "'n::euclidean_space set"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4170
  shows "interior S \<noteq> {} \<Longrightarrow> affine hull S = UNIV"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4171
by (metis affine_hull_UNIV interior_rel_interior_gen)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4172
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4173
lemma rel_interior_affine_hull [simp]:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4174
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4175
  shows "rel_interior (affine hull S) = affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4176
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4177
  have *: "rel_interior (affine hull S) \<subseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4178
    using rel_interior_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4179
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4180
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4181
    assume x: "x \<in> affine hull S"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  4182
    define e :: real where "e = 1"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4183
    then have "e > 0" "ball x e \<inter> affine hull (affine hull S) \<subseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4184
      using hull_hull[of _ S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4185
    then have "x \<in> rel_interior (affine hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4186
      using x rel_interior_ball[of "affine hull S"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4187
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4188
  then show ?thesis using * by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4189
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4190
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4191
lemma rel_interior_UNIV [simp]: "rel_interior (UNIV :: ('n::euclidean_space) set) = UNIV"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4192
  by (metis open_UNIV rel_interior_open)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4193
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4194
lemma rel_interior_convex_shrink:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4195
  fixes S :: "'a::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4196
  assumes "convex S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4197
    and "c \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4198
    and "x \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4199
    and "0 < e"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4200
    and "e \<le> 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4201
  shows "x - e *\<^sub>R (x - c) \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4202
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  4203
  obtain d where "d > 0" and d: "ball c d \<inter> affine hull S \<subseteq> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4204
    using assms(2) unfolding  mem_rel_interior_ball by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4205
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4206
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4207
    assume as: "dist (x - e *\<^sub>R (x - c)) y < e * d" "y \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4208
    have *: "y = (1 - (1 - e)) *\<^sub>R ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) + (1 - e) *\<^sub>R x"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4209
      using \<open>e > 0\<close> by (auto simp: scaleR_left_diff_distrib scaleR_right_diff_distrib)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4210
    have "x \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4211
      using assms hull_subset[of S] by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4212
    moreover have "1 / e + - ((1 - e) / e) = 1"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4213
      using \<open>e > 0\<close> left_diff_distrib[of "1" "(1-e)" "1/e"] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4214
    ultimately have **: "(1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4215
      using as affine_affine_hull[of S] mem_affine[of "affine hull S" y x "(1 / e)" "-((1 - e) / e)"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4216
      by (simp add: algebra_simps)
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61880
diff changeset
  4217
    have "dist c ((1 / e) *\<^sub>R y - ((1 - e) / e) *\<^sub>R x) = \<bar>1/e\<bar> * norm (e *\<^sub>R c - y + (1 - e) *\<^sub>R x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4218
      unfolding dist_norm norm_scaleR[symmetric]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4219
      apply (rule arg_cong[where f=norm])
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4220
      using \<open>e > 0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4221
      apply (auto simp: euclidean_eq_iff[where 'a='a] field_simps inner_simps)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4222
      done
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61880
diff changeset
  4223
    also have "\<dots> = \<bar>1/e\<bar> * norm (x - e *\<^sub>R (x - c) - y)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4224
      by (auto intro!:arg_cong[where f=norm] simp add: algebra_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4225
    also have "\<dots> < d"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4226
      using as[unfolded dist_norm] and \<open>e > 0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4227
      by (auto simp:pos_divide_less_eq[OF \<open>e > 0\<close>] mult.commute)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4228
    finally have "y \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4229
      apply (subst *)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4230
      apply (rule assms(1)[unfolded convex_alt,rule_format])
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  4231
      apply (rule d[THEN subsetD])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4232
      unfolding mem_ball
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4233
      using assms(3-5) **
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4234
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4235
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4236
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4237
  then have "ball (x - e *\<^sub>R (x - c)) (e*d) \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4238
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4239
  moreover have "e * d > 0"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4240
    using \<open>e > 0\<close> \<open>d > 0\<close> by simp
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4241
  moreover have c: "c \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4242
    using assms rel_interior_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4243
  moreover from c have "x - e *\<^sub>R (x - c) \<in> S"
61426
d53db136e8fd new material on path_component_sets, inside, outside, etc. And more default simprules
paulson <lp15@cam.ac.uk>
parents: 61222
diff changeset
  4244
    using convexD_alt[of S x c e]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4245
    apply (simp add: algebra_simps)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4246
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4247
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4248
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4249
  ultimately show ?thesis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4250
    using mem_rel_interior_ball[of "x - e *\<^sub>R (x - c)" S] \<open>e > 0\<close> by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4251
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4252
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4253
lemma interior_real_semiline:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4254
  fixes a :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4255
  shows "interior {a..} = {a<..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4256
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4257
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4258
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4259
    assume "a < y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4260
    then have "y \<in> interior {a..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4261
      apply (simp add: mem_interior)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4262
      apply (rule_tac x="(y-a)" in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4263
      apply (auto simp: dist_norm)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4264
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4265
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4266
  moreover
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4267
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4268
    fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4269
    assume "y \<in> interior {a..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4270
    then obtain e where e: "e > 0" "cball y e \<subseteq> {a..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4271
      using mem_interior_cball[of y "{a..}"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4272
    moreover from e have "y - e \<in> cball y e"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4273
      by (auto simp: cball_def dist_norm)
60307
75e1aa7a450e Convex hulls: theorems about interior, etc. And a few simple lemmas.
paulson <lp15@cam.ac.uk>
parents: 60303
diff changeset
  4274
    ultimately have "a \<le> y - e" by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4275
    then have "a < y" using e by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4276
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4277
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4278
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4279
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4280
lemma continuous_ge_on_Ioo:
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4281
  assumes "continuous_on {c..d} g" "\<And>x. x \<in> {c<..<d} \<Longrightarrow> g x \<ge> a" "c < d" "x \<in> {c..d}"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4282
  shows "g (x::real) \<ge> (a::real)"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4283
proof-
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4284
  from assms(3) have "{c..d} = closure {c<..<d}" by (rule closure_greaterThanLessThan[symmetric])
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4285
  also from assms(2) have "{c<..<d} \<subseteq> (g -` {a..} \<inter> {c..d})" by auto
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4286
  hence "closure {c<..<d} \<subseteq> closure (g -` {a..} \<inter> {c..d})" by (rule closure_mono)
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4287
  also from assms(1) have "closed (g -` {a..} \<inter> {c..d})"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4288
    by (auto simp: continuous_on_closed_vimage)
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4289
  hence "closure (g -` {a..} \<inter> {c..d}) = g -` {a..} \<inter> {c..d}" by simp
62087
44841d07ef1d revisions to limits and derivatives, plus new lemmas
paulson
parents: 61952
diff changeset
  4290
  finally show ?thesis using \<open>x \<in> {c..d}\<close> by auto
44841d07ef1d revisions to limits and derivatives, plus new lemmas
paulson
parents: 61952
diff changeset
  4291
qed
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4292
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4293
lemma interior_real_semiline':
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4294
  fixes a :: real
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4295
  shows "interior {..a} = {..<a}"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4296
proof -
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4297
  {
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4298
    fix y
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4299
    assume "a > y"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4300
    then have "y \<in> interior {..a}"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4301
      apply (simp add: mem_interior)
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4302
      apply (rule_tac x="(a-y)" in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4303
      apply (auto simp: dist_norm)
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4304
      done
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4305
  }
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4306
  moreover
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4307
  {
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4308
    fix y
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4309
    assume "y \<in> interior {..a}"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4310
    then obtain e where e: "e > 0" "cball y e \<subseteq> {..a}"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4311
      using mem_interior_cball[of y "{..a}"] by auto
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4312
    moreover from e have "y + e \<in> cball y e"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4313
      by (auto simp: cball_def dist_norm)
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4314
    ultimately have "a \<ge> y + e" by auto
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4315
    then have "a > y" using e by auto
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4316
  }
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4317
  ultimately show ?thesis by auto
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4318
qed
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4319
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  4320
lemma interior_atLeastAtMost_real [simp]: "interior {a..b} = {a<..<b :: real}"
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4321
proof-
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4322
  have "{a..b} = {a..} \<inter> {..b}" by auto
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4323
  also have "interior \<dots> = {a<..} \<inter> {..<b}"
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4324
    by (simp add: interior_real_semiline interior_real_semiline')
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4325
  also have "\<dots> = {a<..<b}" by auto
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4326
  finally show ?thesis .
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4327
qed
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4328
66793
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4329
lemma interior_atLeastLessThan [simp]:
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4330
  fixes a::real shows "interior {a..<b} = {a<..<b}"
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4331
  by (metis atLeastLessThan_def greaterThanLessThan_def interior_atLeastAtMost_real interior_Int interior_interior interior_real_semiline)
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4332
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4333
lemma interior_lessThanAtMost [simp]:
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4334
  fixes a::real shows "interior {a<..b} = {a<..<b}"
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4335
  by (metis atLeastAtMost_def greaterThanAtMost_def interior_atLeastAtMost_real interior_Int
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4336
            interior_interior interior_real_semiline)
deabce3ccf1f new material about connectedness, etc.
paulson <lp15@cam.ac.uk>
parents: 66641
diff changeset
  4337
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  4338
lemma interior_greaterThanLessThan_real [simp]: "interior {a<..<b} = {a<..<b :: real}"
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  4339
  by (metis interior_atLeastAtMost_real interior_interior)
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  4340
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  4341
lemma frontier_real_Iic [simp]:
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4342
  fixes a :: real
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4343
  shows "frontier {..a} = {a}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4344
  unfolding frontier_def by (auto simp: interior_real_semiline')
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61848
diff changeset
  4345
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  4346
lemma rel_interior_real_box [simp]:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4347
  fixes a b :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4348
  assumes "a < b"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  4349
  shows "rel_interior {a .. b} = {a <..< b}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4350
proof -
54775
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54465
diff changeset
  4351
  have "box a b \<noteq> {}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4352
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4353
    unfolding set_eq_iff
56189
c4daa97ac57a removed dependencies on theory Ordered_Euclidean_Space
immler
parents: 56188
diff changeset
  4354
    by (auto intro!: exI[of _ "(a + b) / 2"] simp: box_def)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4355
  then show ?thesis
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  4356
    using interior_rel_interior_gen[of "cbox a b", symmetric]
62390
842917225d56 more canonical names
nipkow
parents: 62131
diff changeset
  4357
    by (simp split: if_split_asm del: box_real add: box_real[symmetric] interior_cbox)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4358
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4359
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  4360
lemma rel_interior_real_semiline [simp]:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4361
  fixes a :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4362
  shows "rel_interior {a..} = {a<..}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4363
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4364
  have *: "{a<..} \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4365
    unfolding set_eq_iff by (auto intro!: exI[of _ "a + 1"])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4366
  then show ?thesis using interior_real_semiline interior_rel_interior_gen[of "{a..}"]
62390
842917225d56 more canonical names
nipkow
parents: 62131
diff changeset
  4367
    by (auto split: if_split_asm)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4368
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4369
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4370
subsubsection \<open>Relative open sets\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4371
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  4372
definition%important "rel_open S \<longleftrightarrow> rel_interior S = S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4373
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4374
lemma rel_open: "rel_open S \<longleftrightarrow> openin (subtopology euclidean (affine hull S)) S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4375
  unfolding rel_open_def rel_interior_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4376
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4377
  using openin_subopen[of "subtopology euclidean (affine hull S)" S]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4378
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4379
  done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4380
63072
eb5d493a9e03 renamings and refinements
paulson <lp15@cam.ac.uk>
parents: 63040
diff changeset
  4381
lemma openin_rel_interior: "openin (subtopology euclidean (affine hull S)) (rel_interior S)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4382
  apply (simp add: rel_interior_def)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4383
  apply (subst openin_subopen, blast)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4384
  done
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4385
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4386
lemma openin_set_rel_interior:
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4387
   "openin (subtopology euclidean S) (rel_interior S)"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4388
by (rule openin_subset_trans [OF openin_rel_interior rel_interior_subset hull_subset])
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4389
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4390
lemma affine_rel_open:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4391
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4392
  assumes "affine S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4393
  shows "rel_open S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4394
  unfolding rel_open_def
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  4395
  using assms rel_interior_affine_hull[of S] affine_hull_eq[of S]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4396
  by metis
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4397
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4398
lemma affine_closed:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4399
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4400
  assumes "affine S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4401
  shows "closed S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4402
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4403
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4404
    assume "S \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4405
    then obtain L where L: "subspace L" "affine_parallel S L"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4406
      using assms affine_parallel_subspace[of S] by auto
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  4407
    then obtain a where a: "S = ((+) a ` L)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4408
      using affine_parallel_def[of L S] affine_parallel_commut by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4409
    from L have "closed L" using closed_subspace by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4410
    then have "closed S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4411
      using closed_translation a by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4412
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4413
  then show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4414
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4415
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4416
lemma closure_affine_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4417
  fixes S :: "'n::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4418
  shows "closure S \<subseteq> affine hull S"
44524
04ad69081646 generalize some lemmas
huffman
parents: 44523
diff changeset
  4419
  by (intro closure_minimal hull_subset affine_closed affine_affine_hull)
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4420
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  4421
lemma closure_same_affine_hull [simp]:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4422
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4423
  shows "affine hull (closure S) = affine hull S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4424
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4425
  have "affine hull (closure S) \<subseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4426
    using hull_mono[of "closure S" "affine hull S" "affine"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4427
      closure_affine_hull[of S] hull_hull[of "affine" S]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4428
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4429
  moreover have "affine hull (closure S) \<supseteq> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4430
    using hull_mono[of "S" "closure S" "affine"] closure_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4431
  ultimately show ?thesis by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4432
qed
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4433
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  4434
lemma closure_aff_dim [simp]:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4435
  fixes S :: "'n::euclidean_space set"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4436
  shows "aff_dim (closure S) = aff_dim S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4437
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4438
  have "aff_dim S \<le> aff_dim (closure S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4439
    using aff_dim_subset closure_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4440
  moreover have "aff_dim (closure S) \<le> aff_dim (affine hull S)"
63075
60a42a4166af lemmas about dimension, hyperplanes, span, etc.
paulson <lp15@cam.ac.uk>
parents: 63072
diff changeset
  4441
    using aff_dim_subset closure_affine_hull by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4442
  moreover have "aff_dim (affine hull S) = aff_dim S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4443
    using aff_dim_affine_hull by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4444
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4445
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4446
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4447
lemma rel_interior_closure_convex_shrink:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4448
  fixes S :: "_::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4449
  assumes "convex S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4450
    and "c \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4451
    and "x \<in> closure S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4452
    and "e > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4453
    and "e \<le> 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4454
  shows "x - e *\<^sub>R (x - c) \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4455
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4456
  obtain d where "d > 0" and d: "ball c d \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4457
    using assms(2) unfolding mem_rel_interior_ball by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4458
  have "\<exists>y \<in> S. norm (y - x) * (1 - e) < e * d"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4459
  proof (cases "x \<in> S")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4460
    case True
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4461
    then show ?thesis using \<open>e > 0\<close> \<open>d > 0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4462
      apply (rule_tac bexI[where x=x], auto)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4463
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4464
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4465
    case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4466
    then have x: "x islimpt S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4467
      using assms(3)[unfolded closure_def] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4468
    show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4469
    proof (cases "e = 1")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4470
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4471
      obtain y where "y \<in> S" "y \<noteq> x" "dist y x < 1"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4472
        using x[unfolded islimpt_approachable,THEN spec[where x=1]] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4473
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4474
        apply (rule_tac x=y in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4475
        unfolding True
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4476
        using \<open>d > 0\<close>
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4477
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4478
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4479
    next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4480
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4481
      then have "0 < e * d / (1 - e)" and *: "1 - e > 0"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4482
        using \<open>e \<le> 1\<close> \<open>e > 0\<close> \<open>d > 0\<close> by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4483
      then obtain y where "y \<in> S" "y \<noteq> x" "dist y x < e * d / (1 - e)"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4484
        using x[unfolded islimpt_approachable,THEN spec[where x="e*d / (1 - e)"]] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4485
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4486
        apply (rule_tac x=y in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4487
        unfolding dist_norm
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4488
        using pos_less_divide_eq[OF *]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4489
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4490
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4491
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4492
  qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4493
  then obtain y where "y \<in> S" and y: "norm (y - x) * (1 - e) < e * d"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4494
    by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  4495
  define z where "z = c + ((1 - e) / e) *\<^sub>R (x - y)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4496
  have *: "x - e *\<^sub>R (x - c) = y - e *\<^sub>R (y - z)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4497
    unfolding z_def using \<open>e > 0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4498
    by (auto simp: scaleR_right_diff_distrib scaleR_right_distrib scaleR_left_diff_distrib)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4499
  have zball: "z \<in> ball c d"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4500
    using mem_ball z_def dist_norm[of c]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4501
    using y and assms(4,5)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4502
    by (auto simp:field_simps norm_minus_commute)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4503
  have "x \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4504
    using closure_affine_hull assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4505
  moreover have "y \<in> affine hull S"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4506
    using \<open>y \<in> S\<close> hull_subset[of S] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4507
  moreover have "c \<in> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4508
    using assms rel_interior_subset hull_subset[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4509
  ultimately have "z \<in> affine hull S"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4510
    using z_def affine_affine_hull[of S]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4511
      mem_affine_3_minus [of "affine hull S" c x y "(1 - e) / e"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4512
      assms
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4513
    by (auto simp: field_simps)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4514
  then have "z \<in> S" using d zball by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4515
  obtain d1 where "d1 > 0" and d1: "ball z d1 \<le> ball c d"
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4516
    using zball open_ball[of c d] openE[of "ball c d" z] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4517
  then have "ball z d1 \<inter> affine hull S \<subseteq> ball c d \<inter> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4518
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4519
  then have "ball z d1 \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4520
    using d by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4521
  then have "z \<in> rel_interior S"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4522
    using mem_rel_interior_ball using \<open>d1 > 0\<close> \<open>z \<in> S\<close> by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4523
  then have "y - e *\<^sub>R (y - z) \<in> rel_interior S"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4524
    using rel_interior_convex_shrink[of S z y e] assms \<open>y \<in> S\<close> by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4525
  then show ?thesis using * by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4526
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4527
62620
d21dab28b3f9 New results about paths, segments, etc. The notion of simply_connected.
paulson <lp15@cam.ac.uk>
parents: 62618
diff changeset
  4528
lemma rel_interior_eq:
d21dab28b3f9 New results about paths, segments, etc. The notion of simply_connected.
paulson <lp15@cam.ac.uk>
parents: 62618
diff changeset
  4529
   "rel_interior s = s \<longleftrightarrow> openin(subtopology euclidean (affine hull s)) s"
d21dab28b3f9 New results about paths, segments, etc. The notion of simply_connected.
paulson <lp15@cam.ac.uk>
parents: 62618
diff changeset
  4530
using rel_open rel_open_def by blast
d21dab28b3f9 New results about paths, segments, etc. The notion of simply_connected.
paulson <lp15@cam.ac.uk>
parents: 62618
diff changeset
  4531
d21dab28b3f9 New results about paths, segments, etc. The notion of simply_connected.
paulson <lp15@cam.ac.uk>
parents: 62618
diff changeset
  4532
lemma rel_interior_openin:
d21dab28b3f9 New results about paths, segments, etc. The notion of simply_connected.
paulson <lp15@cam.ac.uk>
parents: 62618
diff changeset
  4533
   "openin(subtopology euclidean (affine hull s)) s \<Longrightarrow> rel_interior s = s"
d21dab28b3f9 New results about paths, segments, etc. The notion of simply_connected.
paulson <lp15@cam.ac.uk>
parents: 62618
diff changeset
  4534
by (simp add: rel_interior_eq)
d21dab28b3f9 New results about paths, segments, etc. The notion of simply_connected.
paulson <lp15@cam.ac.uk>
parents: 62618
diff changeset
  4535
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4536
lemma rel_interior_affine:
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4537
  fixes S :: "'n::euclidean_space set"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4538
  shows  "affine S \<Longrightarrow> rel_interior S = S"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4539
using affine_rel_open rel_open_def by auto
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4540
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4541
lemma rel_interior_eq_closure:
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4542
  fixes S :: "'n::euclidean_space set"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4543
  shows "rel_interior S = closure S \<longleftrightarrow> affine S"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4544
proof (cases "S = {}")
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4545
  case True
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4546
 then show ?thesis
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4547
    by auto
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4548
next
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4549
  case False show ?thesis
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4550
  proof
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4551
    assume eq: "rel_interior S = closure S"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4552
    have "S = {} \<or> S = affine hull S"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4553
      apply (rule connected_clopen [THEN iffD1, rule_format])
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4554
       apply (simp add: affine_imp_convex convex_connected)
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4555
      apply (rule conjI)
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4556
       apply (metis eq closure_subset openin_rel_interior rel_interior_subset subset_antisym)
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4557
      apply (metis closed_subset closure_subset_eq eq hull_subset rel_interior_subset)
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4558
      done
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4559
    with False have "affine hull S = S"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4560
      by auto
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4561
    then show "affine S"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4562
      by (metis affine_hull_eq)
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4563
  next
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4564
    assume "affine S"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4565
    then show "rel_interior S = closure S"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4566
      by (simp add: rel_interior_affine affine_closed)
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4567
  qed
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4568
qed
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4569
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4570
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  4571
subsubsection%unimportant\<open>Relative interior preserves under linear transformations\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4572
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4573
lemma rel_interior_translation_aux:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4574
  fixes a :: "'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4575
  shows "((\<lambda>x. a + x) ` rel_interior S) \<subseteq> rel_interior ((\<lambda>x. a + x) ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4576
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4577
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4578
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4579
    assume x: "x \<in> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4580
    then obtain T where "open T" "x \<in> T \<inter> S" "T \<inter> affine hull S \<subseteq> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4581
      using mem_rel_interior[of x S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4582
    then have "open ((\<lambda>x. a + x) ` T)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4583
      and "a + x \<in> ((\<lambda>x. a + x) ` T) \<inter> ((\<lambda>x. a + x) ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4584
      and "((\<lambda>x. a + x) ` T) \<inter> affine hull ((\<lambda>x. a + x) ` S) \<subseteq> (\<lambda>x. a + x) ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4585
      using affine_hull_translation[of a S] open_translation[of T a] x by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4586
    then have "a + x \<in> rel_interior ((\<lambda>x. a + x) ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4587
      using mem_rel_interior[of "a+x" "((\<lambda>x. a + x) ` S)"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4588
  }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4589
  then show ?thesis by auto
60809
457abb82fb9e the Cauchy integral theorem and related material
paulson <lp15@cam.ac.uk>
parents: 60800
diff changeset
  4590
qed
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4591
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4592
lemma rel_interior_translation:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4593
  fixes a :: "'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4594
  shows "rel_interior ((\<lambda>x. a + x) ` S) = (\<lambda>x. a + x) ` rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4595
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4596
  have "(\<lambda>x. (-a) + x) ` rel_interior ((\<lambda>x. a + x) ` S) \<subseteq> rel_interior S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4597
    using rel_interior_translation_aux[of "-a" "(\<lambda>x. a + x) ` S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4598
      translation_assoc[of "-a" "a"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4599
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4600
  then have "((\<lambda>x. a + x) ` rel_interior S) \<supseteq> rel_interior ((\<lambda>x. a + x) ` S)"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  4601
    using translation_inverse_subset[of a "rel_interior ((+) a ` S)" "rel_interior S"]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4602
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4603
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4604
    using rel_interior_translation_aux[of a S] by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4605
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4606
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4607
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4608
lemma affine_hull_linear_image:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4609
  assumes "bounded_linear f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4610
  shows "f ` (affine hull s) = affine hull f ` s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4611
proof -
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4612
  interpret f: bounded_linear f by fact
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  4613
  have "affine {x. f x \<in> affine hull f ` s}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4614
    unfolding affine_def
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4615
    by (auto simp: f.scaleR f.add affine_affine_hull[unfolded affine_def, rule_format])
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  4616
  moreover have "affine {x. x \<in> f ` (affine hull s)}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4617
    using affine_affine_hull[unfolded affine_def, of s]
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4618
    unfolding affine_def by (auto simp: f.scaleR [symmetric] f.add [symmetric])
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  4619
  ultimately show ?thesis
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  4620
    by (auto simp: hull_inc elim!: hull_induct)
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  4621
qed 
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4622
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4623
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4624
lemma rel_interior_injective_on_span_linear_image:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4625
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4626
    and S :: "'m::euclidean_space set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4627
  assumes "bounded_linear f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4628
    and "inj_on f (span S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4629
  shows "rel_interior (f ` S) = f ` (rel_interior S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4630
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4631
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4632
    fix z
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4633
    assume z: "z \<in> rel_interior (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4634
    then have "z \<in> f ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4635
      using rel_interior_subset[of "f ` S"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4636
    then obtain x where x: "x \<in> S" "f x = z" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4637
    obtain e2 where e2: "e2 > 0" "cball z e2 \<inter> affine hull (f ` S) \<subseteq> (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4638
      using z rel_interior_cball[of "f ` S"] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4639
    obtain K where K: "K > 0" "\<And>x. norm (f x) \<le> norm x * K"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4640
     using assms Real_Vector_Spaces.bounded_linear.pos_bounded[of f] by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  4641
    define e1 where "e1 = 1 / K"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4642
    then have e1: "e1 > 0" "\<And>x. e1 * norm (f x) \<le> norm x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4643
      using K pos_le_divide_eq[of e1] by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  4644
    define e where "e = e1 * e2"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  4645
    then have "e > 0" using e1 e2 by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4646
    {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4647
      fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4648
      assume y: "y \<in> cball x e \<inter> affine hull S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4649
      then have h1: "f y \<in> affine hull (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4650
        using affine_hull_linear_image[of f S] assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4651
      from y have "norm (x-y) \<le> e1 * e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4652
        using cball_def[of x e] dist_norm[of x y] e_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4653
      moreover have "f x - f y = f (x - y)"
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4654
        using assms linear_diff[of f x y] linear_conv_bounded_linear[of f] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4655
      moreover have "e1 * norm (f (x-y)) \<le> norm (x - y)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4656
        using e1 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4657
      ultimately have "e1 * norm ((f x)-(f y)) \<le> e1 * e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4658
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4659
      then have "f y \<in> cball z e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4660
        using cball_def[of "f x" e2] dist_norm[of "f x" "f y"] e1 x by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4661
      then have "f y \<in> f ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4662
        using y e2 h1 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4663
      then have "y \<in> S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4664
        using assms y hull_subset[of S] affine_hull_subset_span
61520
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  4665
          inj_on_image_mem_iff [OF \<open>inj_on f (span S)\<close>]
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  4666
        by (metis Int_iff span_superset subsetCE)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4667
    }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4668
    then have "z \<in> f ` (rel_interior S)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4669
      using mem_rel_interior_cball[of x S] \<open>e > 0\<close> x by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4670
  }
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4671
  moreover
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4672
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4673
    fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4674
    assume x: "x \<in> rel_interior S"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  4675
    then obtain e2 where e2: "e2 > 0" "cball x e2 \<inter> affine hull S \<subseteq> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4676
      using rel_interior_cball[of S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4677
    have "x \<in> S" using x rel_interior_subset by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4678
    then have *: "f x \<in> f ` S" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4679
    have "\<forall>x\<in>span S. f x = 0 \<longrightarrow> x = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4680
      using assms subspace_span linear_conv_bounded_linear[of f]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4681
        linear_injective_on_subspace_0[of f "span S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4682
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4683
    then obtain e1 where e1: "e1 > 0" "\<forall>x \<in> span S. e1 * norm x \<le> norm (f x)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4684
      using assms injective_imp_isometric[of "span S" f]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4685
        subspace_span[of S] closed_subspace[of "span S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4686
      by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  4687
    define e where "e = e1 * e2"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56541
diff changeset
  4688
    hence "e > 0" using e1 e2 by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4689
    {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4690
      fix y
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4691
      assume y: "y \<in> cball (f x) e \<inter> affine hull (f ` S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4692
      then have "y \<in> f ` (affine hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4693
        using affine_hull_linear_image[of f S] assms by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4694
      then obtain xy where xy: "xy \<in> affine hull S" "f xy = y" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4695
      with y have "norm (f x - f xy) \<le> e1 * e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4696
        using cball_def[of "f x" e] dist_norm[of "f x" y] e_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4697
      moreover have "f x - f xy = f (x - xy)"
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63332
diff changeset
  4698
        using assms linear_diff[of f x xy] linear_conv_bounded_linear[of f] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4699
      moreover have *: "x - xy \<in> span S"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63092
diff changeset
  4700
        using subspace_diff[of "span S" x xy] subspace_span \<open>x \<in> S\<close> xy
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  4701
          affine_hull_subset_span[of S] span_superset
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4702
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4703
      moreover from * have "e1 * norm (x - xy) \<le> norm (f (x - xy))"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4704
        using e1 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4705
      ultimately have "e1 * norm (x - xy) \<le> e1 * e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4706
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4707
      then have "xy \<in> cball x e2"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4708
        using cball_def[of x e2] dist_norm[of x xy] e1 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4709
      then have "y \<in> f ` S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4710
        using xy e2 by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4711
    }
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4712
    then have "f x \<in> rel_interior (f ` S)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4713
      using mem_rel_interior_cball[of "(f x)" "(f ` S)"] * \<open>e > 0\<close> by auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  4714
  }
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4715
  ultimately show ?thesis by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4716
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4717
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4718
lemma rel_interior_injective_linear_image:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4719
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4720
  assumes "bounded_linear f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4721
    and "inj f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4722
  shows "rel_interior (f ` S) = f ` (rel_interior S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4723
  using assms rel_interior_injective_on_span_linear_image[of f S]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4724
    subset_inj_on[of f "UNIV" "span S"]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4725
  by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4726
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4727
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  4728
subsection%unimportant\<open>Some Properties of subset of standard basis\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4729
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4730
lemma affine_hull_substd_basis:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4731
  assumes "d \<subseteq> Basis"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4732
  shows "affine hull (insert 0 d) = {x::'a::euclidean_space. \<forall>i\<in>Basis. i \<notin> d \<longrightarrow> x\<bullet>i = 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4733
  (is "affine hull (insert 0 ?A) = ?B")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4734
proof -
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  4735
  have *: "\<And>A. (+) (0::'a) ` A = A" "\<And>A. (+) (- (0::'a)) ` A = A"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4736
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4737
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4738
    unfolding affine_hull_insert_span_gen span_substd_basis[OF assms,symmetric] * ..
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4739
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4740
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60176
diff changeset
  4741
lemma affine_hull_convex_hull [simp]: "affine hull (convex hull S) = affine hull S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4742
  by (metis Int_absorb1 Int_absorb2 convex_hull_subset_affine_hull hull_hull hull_mono hull_subset)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4743
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  4744
67968
a5ad4c015d1c removed dots at the end of (sub)titles
nipkow
parents: 67962
diff changeset
  4745
subsection%unimportant \<open>Openness and compactness are preserved by convex hull operation\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4746
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  4747
lemma open_convex_hull[intro]:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4748
  fixes S :: "'a::real_normed_vector set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4749
  assumes "open S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4750
  shows "open (convex hull S)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4751
proof (clarsimp simp: open_contains_cball convex_hull_explicit)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4752
  fix T and u :: "'a\<Rightarrow>real"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4753
  assume obt: "finite T" "T\<subseteq>S" "\<forall>x\<in>T. 0 \<le> u x" "sum u T = 1" 
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4754
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4755
  from assms[unfolded open_contains_cball] obtain b
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4756
    where b: "\<And>x. x\<in>S \<Longrightarrow> 0 < b x \<and> cball x (b x) \<subseteq> S" by metis
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4757
  have "b ` T \<noteq> {}"
56889
48a745e1bde7 avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
hoelzl
parents: 56571
diff changeset
  4758
    using obt by auto
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4759
  define i where "i = b ` T"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4760
  let ?\<Phi> = "\<lambda>y. \<exists>F. finite F \<and> F \<subseteq> S \<and> (\<exists>u. (\<forall>x\<in>F. 0 \<le> u x) \<and> sum u F = 1 \<and> (\<Sum>v\<in>F. u v *\<^sub>R v) = y)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4761
  let ?a = "\<Sum>v\<in>T. u v *\<^sub>R v"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4762
  show "\<exists>e > 0. cball ?a e \<subseteq> {y. ?\<Phi> y}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4763
  proof (intro exI subsetI conjI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4764
    show "0 < Min i"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4765
      unfolding i_def and Min_gr_iff[OF finite_imageI[OF obt(1)] \<open>b ` T\<noteq>{}\<close>]
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4766
      using b \<open>T\<subseteq>S\<close> by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4767
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4768
    fix y
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4769
    assume "y \<in> cball ?a (Min i)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4770
    then have y: "norm (?a - y) \<le> Min i"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4771
      unfolding dist_norm[symmetric] by auto
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4772
    { fix x
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4773
      assume "x \<in> T"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4774
      then have "Min i \<le> b x"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4775
        by (simp add: i_def obt(1))
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4776
      then have "x + (y - ?a) \<in> cball x (b x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4777
        using y unfolding mem_cball dist_norm by auto
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4778
      moreover have "x \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4779
        using \<open>x\<in>T\<close> \<open>T\<subseteq>S\<close> by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4780
      ultimately have "x + (y - ?a) \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4781
        using y b by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4782
    }
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4783
    moreover
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4784
    have *: "inj_on (\<lambda>v. v + (y - ?a)) T"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4785
      unfolding inj_on_def by auto
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4786
    have "(\<Sum>v\<in>(\<lambda>v. v + (y - ?a)) ` T. u (v - (y - ?a)) *\<^sub>R v) = y"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4787
      unfolding sum.reindex[OF *] o_def using obt(4)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  4788
      by (simp add: sum.distrib sum_subtractf scaleR_left.sum[symmetric] scaleR_right_distrib)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4789
    ultimately show "y \<in> {y. ?\<Phi> y}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4790
    proof (intro CollectI exI conjI)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4791
      show "finite ((\<lambda>v. v + (y - ?a)) ` T)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4792
        by (simp add: obt(1))
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4793
      show "sum (\<lambda>v. u (v - (y - ?a))) ((\<lambda>v. v + (y - ?a)) ` T) = 1"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4794
        unfolding sum.reindex[OF *] o_def using obt(4) by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4795
    qed (use obt(1, 3) in auto)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4796
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4797
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4798
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4799
lemma compact_convex_combinations:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4800
  fixes S T :: "'a::real_normed_vector set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4801
  assumes "compact S" "compact T"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4802
  shows "compact { (1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. 0 \<le> u \<and> u \<le> 1 \<and> x \<in> S \<and> y \<in> T}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4803
proof -
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4804
  let ?X = "{0..1} \<times> S \<times> T"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4805
  let ?h = "(\<lambda>z. (1 - fst z) *\<^sub>R fst (snd z) + fst z *\<^sub>R snd (snd z))"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4806
  have *: "{ (1 - u) *\<^sub>R x + u *\<^sub>R y | x y u. 0 \<le> u \<and> u \<le> 1 \<and> x \<in> S \<and> y \<in> T} = ?h ` ?X"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4807
    by force
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  4808
  have "continuous_on ?X (\<lambda>z. (1 - fst z) *\<^sub>R fst (snd z) + fst z *\<^sub>R snd (snd z))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4809
    unfolding continuous_on by (rule ballI) (intro tendsto_intros)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4810
  with assms show ?thesis
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4811
    by (simp add: * compact_Times compact_continuous_image)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4812
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4813
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4814
lemma finite_imp_compact_convex_hull:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4815
  fixes S :: "'a::real_normed_vector set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4816
  assumes "finite S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4817
  shows "compact (convex hull S)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4818
proof (cases "S = {}")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4819
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4820
  then show ?thesis by simp
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4821
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4822
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4823
  with assms show ?thesis
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4824
  proof (induct rule: finite_ne_induct)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4825
    case (singleton x)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4826
    show ?case by simp
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4827
  next
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4828
    case (insert x A)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4829
    let ?f = "\<lambda>(u, y::'a). u *\<^sub>R x + (1 - u) *\<^sub>R y"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4830
    let ?T = "{0..1::real} \<times> (convex hull A)"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4831
    have "continuous_on ?T ?f"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4832
      unfolding split_def continuous_on by (intro ballI tendsto_intros)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4833
    moreover have "compact ?T"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  4834
      by (intro compact_Times compact_Icc insert)
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4835
    ultimately have "compact (?f ` ?T)"
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4836
      by (rule compact_continuous_image)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4837
    also have "?f ` ?T = convex hull (insert x A)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4838
      unfolding convex_hull_insert [OF \<open>A \<noteq> {}\<close>]
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4839
      apply safe
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4840
      apply (rule_tac x=a in exI, simp)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4841
      apply (rule_tac x="1 - a" in exI, simp, fast)
44525
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4842
      apply (rule_tac x="(u, b)" in image_eqI, simp_all)
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4843
      done
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4844
    finally show "compact (convex hull (insert x A))" .
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4845
  qed
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4846
qed
fbb777aec0d4 generalize lemma finite_imp_compact_convex_hull and related lemmas
huffman
parents: 44524
diff changeset
  4847
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4848
lemma compact_convex_hull:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4849
  fixes S :: "'a::euclidean_space set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4850
  assumes "compact S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4851
  shows "compact (convex hull S)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4852
proof (cases "S = {}")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4853
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4854
  then show ?thesis using compact_empty by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4855
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4856
  case False
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4857
  then obtain w where "w \<in> S" by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4858
  show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4859
    unfolding caratheodory[of S]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4860
  proof (induct ("DIM('a) + 1"))
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4861
    case 0
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4862
    have *: "{x.\<exists>sa. finite sa \<and> sa \<subseteq> S \<and> card sa \<le> 0 \<and> x \<in> convex hull sa} = {}"
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36341
diff changeset
  4863
      using compact_empty by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4864
    from 0 show ?case unfolding * by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4865
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4866
    case (Suc n)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4867
    show ?case
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4868
    proof (cases "n = 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4869
      case True
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4870
      have "{x. \<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> Suc n \<and> x \<in> convex hull T} = S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4871
        unfolding set_eq_iff and mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4872
      proof (rule, rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4873
        fix x
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4874
        assume "\<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> Suc n \<and> x \<in> convex hull T"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4875
        then obtain T where T: "finite T" "T \<subseteq> S" "card T \<le> Suc n" "x \<in> convex hull T"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4876
          by auto
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4877
        show "x \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4878
        proof (cases "card T = 0")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4879
          case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4880
          then show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4881
            using T(4) unfolding card_0_eq[OF T(1)] by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4882
        next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4883
          case False
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4884
          then have "card T = Suc 0" using T(3) \<open>n=0\<close> by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4885
          then obtain a where "T = {a}" unfolding card_Suc_eq by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4886
          then show ?thesis using T(2,4) by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4887
        qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4888
      next
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4889
        fix x assume "x\<in>S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4890
        then show "\<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> Suc n \<and> x \<in> convex hull T"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4891
          apply (rule_tac x="{x}" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4892
          unfolding convex_hull_singleton
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4893
          apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4894
          done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4895
      qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4896
      then show ?thesis using assms by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4897
    next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4898
      case False
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4899
      have "{x. \<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> Suc n \<and> x \<in> convex hull T} =
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4900
        {(1 - u) *\<^sub>R x + u *\<^sub>R y | x y u.
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4901
          0 \<le> u \<and> u \<le> 1 \<and> x \<in> S \<and> y \<in> {x. \<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> n \<and> x \<in> convex hull T}}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4902
        unfolding set_eq_iff and mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4903
      proof (rule, rule)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4904
        fix x
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4905
        assume "\<exists>u v c. x = (1 - c) *\<^sub>R u + c *\<^sub>R v \<and>
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4906
          0 \<le> c \<and> c \<le> 1 \<and> u \<in> S \<and> (\<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> n \<and> v \<in> convex hull T)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4907
        then obtain u v c T where obt: "x = (1 - c) *\<^sub>R u + c *\<^sub>R v"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4908
          "0 \<le> c \<and> c \<le> 1" "u \<in> S" "finite T" "T \<subseteq> S" "card T \<le> n"  "v \<in> convex hull T"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4909
          by auto
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4910
        moreover have "(1 - c) *\<^sub>R u + c *\<^sub>R v \<in> convex hull insert u T"
61426
d53db136e8fd new material on path_component_sets, inside, outside, etc. And more default simprules
paulson <lp15@cam.ac.uk>
parents: 61222
diff changeset
  4911
          apply (rule convexD_alt)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4912
          using obt(2) and convex_convex_hull and hull_subset[of "insert u T" convex]
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4913
          using obt(7) and hull_mono[of T "insert u T"]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4914
          apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4915
          done
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4916
        ultimately show "\<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> Suc n \<and> x \<in> convex hull T"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4917
          apply (rule_tac x="insert u T" in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4918
          apply (auto simp: card_insert_if)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4919
          done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4920
      next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4921
        fix x
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4922
        assume "\<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> Suc n \<and> x \<in> convex hull T"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4923
        then obtain T where T: "finite T" "T \<subseteq> S" "card T \<le> Suc n" "x \<in> convex hull T"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4924
          by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4925
        show "\<exists>u v c. x = (1 - c) *\<^sub>R u + c *\<^sub>R v \<and>
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4926
          0 \<le> c \<and> c \<le> 1 \<and> u \<in> S \<and> (\<exists>T. finite T \<and> T \<subseteq> S \<and> card T \<le> n \<and> v \<in> convex hull T)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4927
        proof (cases "card T = Suc n")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4928
          case False
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4929
          then have "card T \<le> n" using T(3) by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4930
          then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4931
            apply (rule_tac x=w in exI, rule_tac x=x in exI, rule_tac x=1 in exI)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4932
            using \<open>w\<in>S\<close> and T
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4933
            apply (auto intro!: exI[where x=T])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4934
            done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4935
        next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4936
          case True
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4937
          then obtain a u where au: "T = insert a u" "a\<notin>u"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  4938
            apply (drule_tac card_eq_SucD, auto)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4939
            done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4940
          show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4941
          proof (cases "u = {}")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4942
            case True
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4943
            then have "x = a" using T(4)[unfolded au] by auto
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  4944
            show ?thesis unfolding \<open>x = a\<close>
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4945
              apply (rule_tac x=a in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4946
              apply (rule_tac x=a in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4947
              apply (rule_tac x=1 in exI)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4948
              using T and \<open>n \<noteq> 0\<close>
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4949
              unfolding au
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4950
              apply (auto intro!: exI[where x="{a}"])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4951
              done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4952
          next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4953
            case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4954
            obtain ux vx b where obt: "ux\<ge>0" "vx\<ge>0" "ux + vx = 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4955
              "b \<in> convex hull u" "x = ux *\<^sub>R a + vx *\<^sub>R b"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4956
              using T(4)[unfolded au convex_hull_insert[OF False]]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4957
              by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4958
            have *: "1 - vx = ux" using obt(3) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4959
            show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4960
              apply (rule_tac x=a in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4961
              apply (rule_tac x=b in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4962
              apply (rule_tac x=vx in exI)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  4963
              using obt and T(1-3)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4964
              unfolding au and * using card_insert_disjoint[OF _ au(2)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4965
              apply (auto intro!: exI[where x=u])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4966
              done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4967
          qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4968
        qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4969
      qed
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4970
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4971
        using compact_convex_combinations[OF assms Suc] by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4972
    qed
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36341
diff changeset
  4973
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4974
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4975
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4976
67968
a5ad4c015d1c removed dots at the end of (sub)titles
nipkow
parents: 67962
diff changeset
  4977
subsection%unimportant \<open>Extremal points of a simplex are some vertices\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4978
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4979
lemma dist_increases_online:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4980
  fixes a b d :: "'a::real_inner"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4981
  assumes "d \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4982
  shows "dist a (b + d) > dist a b \<or> dist a (b - d) > dist a b"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4983
proof (cases "inner a d - inner b d > 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4984
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4985
  then have "0 < inner d d + (inner a d * 2 - inner b d * 2)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4986
    apply (rule_tac add_pos_pos)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4987
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4988
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4989
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4990
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4991
    apply (rule_tac disjI2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4992
    unfolding dist_norm and norm_eq_sqrt_inner and real_sqrt_less_iff
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4993
    apply  (simp add: algebra_simps inner_commute)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4994
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4995
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4996
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4997
  then have "0 < inner d d + (inner b d * 2 - inner a d * 2)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4998
    apply (rule_tac add_pos_nonneg)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  4999
    using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5000
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5001
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5002
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5003
    apply (rule_tac disjI1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5004
    unfolding dist_norm and norm_eq_sqrt_inner and real_sqrt_less_iff
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5005
    apply (simp add: algebra_simps inner_commute)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5006
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5007
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5008
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5009
lemma norm_increases_online:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5010
  fixes d :: "'a::real_inner"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5011
  shows "d \<noteq> 0 \<Longrightarrow> norm (a + d) > norm a \<or> norm(a - d) > norm a"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5012
  using dist_increases_online[of d a 0] unfolding dist_norm by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5013
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5014
lemma simplex_furthest_lt:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5015
  fixes S :: "'a::real_inner set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5016
  assumes "finite S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5017
  shows "\<forall>x \<in> convex hull S.  x \<notin> S \<longrightarrow> (\<exists>y \<in> convex hull S. norm (x - a) < norm(y - a))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5018
  using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5019
proof induct
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5020
  fix x S
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5021
  assume as: "finite S" "x\<notin>S" "\<forall>x\<in>convex hull S. x \<notin> S \<longrightarrow> (\<exists>y\<in>convex hull S. norm (x - a) < norm (y - a))"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5022
  show "\<forall>xa\<in>convex hull insert x S. xa \<notin> insert x S \<longrightarrow>
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5023
    (\<exists>y\<in>convex hull insert x S. norm (xa - a) < norm (y - a))"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5024
  proof (intro impI ballI, cases "S = {}")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5025
    case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5026
    fix y
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5027
    assume y: "y \<in> convex hull insert x S" "y \<notin> insert x S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5028
    obtain u v b where obt: "u\<ge>0" "v\<ge>0" "u + v = 1" "b \<in> convex hull S" "y = u *\<^sub>R x + v *\<^sub>R b"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5029
      using y(1)[unfolded convex_hull_insert[OF False]] by auto
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5030
    show "\<exists>z\<in>convex hull insert x S. norm (y - a) < norm (z - a)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5031
    proof (cases "y \<in> convex hull S")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5032
      case True
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5033
      then obtain z where "z \<in> convex hull S" "norm (y - a) < norm (z - a)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5034
        using as(3)[THEN bspec[where x=y]] and y(2) by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5035
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5036
        apply (rule_tac x=z in bexI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5037
        unfolding convex_hull_insert[OF False]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5038
        apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5039
        done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5040
    next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5041
      case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5042
      show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5043
        using obt(3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5044
      proof (cases "u = 0", case_tac[!] "v = 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5045
        assume "u = 0" "v \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5046
        then have "y = b" using obt by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5047
        then show ?thesis using False and obt(4) by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5048
      next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5049
        assume "u \<noteq> 0" "v = 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5050
        then have "y = x" using obt by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5051
        then show ?thesis using y(2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5052
      next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5053
        assume "u \<noteq> 0" "v \<noteq> 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5054
        then obtain w where w: "w>0" "w<u" "w<v"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5055
          using real_lbound_gt_zero[of u v] and obt(1,2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5056
        have "x \<noteq> b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5057
        proof
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5058
          assume "x = b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5059
          then have "y = b" unfolding obt(5)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5060
            using obt(3) by (auto simp: scaleR_left_distrib[symmetric])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5061
          then show False using obt(4) and False by simp
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5062
        qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5063
        then have *: "w *\<^sub>R (x - b) \<noteq> 0" using w(1) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5064
        show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5065
          using dist_increases_online[OF *, of a y]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5066
        proof (elim disjE)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5067
          assume "dist a y < dist a (y + w *\<^sub>R (x - b))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5068
          then have "norm (y - a) < norm ((u + w) *\<^sub>R x + (v - w) *\<^sub>R b - a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5069
            unfolding dist_commute[of a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5070
            unfolding dist_norm obt(5)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5071
            by (simp add: algebra_simps)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5072
          moreover have "(u + w) *\<^sub>R x + (v - w) *\<^sub>R b \<in> convex hull insert x S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5073
            unfolding convex_hull_insert[OF \<open>S\<noteq>{}\<close>]
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5074
          proof (intro CollectI conjI exI)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5075
            show "u + w \<ge> 0" "v - w \<ge> 0"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5076
              using obt(1) w by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5077
          qed (use obt in auto)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5078
          ultimately show ?thesis by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5079
        next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5080
          assume "dist a y < dist a (y - w *\<^sub>R (x - b))"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5081
          then have "norm (y - a) < norm ((u - w) *\<^sub>R x + (v + w) *\<^sub>R b - a)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5082
            unfolding dist_commute[of a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5083
            unfolding dist_norm obt(5)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5084
            by (simp add: algebra_simps)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5085
          moreover have "(u - w) *\<^sub>R x + (v + w) *\<^sub>R b \<in> convex hull insert x S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5086
            unfolding convex_hull_insert[OF \<open>S\<noteq>{}\<close>]
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5087
          proof (intro CollectI conjI exI)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5088
            show "u - w \<ge> 0" "v + w \<ge> 0"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5089
              using obt(1) w by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5090
          qed (use obt in auto)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5091
          ultimately show ?thesis by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5092
        qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5093
      qed auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5094
    qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5095
  qed auto
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5096
qed (auto simp: assms)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5097
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5098
lemma simplex_furthest_le:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5099
  fixes S :: "'a::real_inner set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5100
  assumes "finite S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5101
    and "S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5102
  shows "\<exists>y\<in>S. \<forall>x\<in> convex hull S. norm (x - a) \<le> norm (y - a)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5103
proof -
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5104
  have "convex hull S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5105
    using hull_subset[of S convex] and assms(2) by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5106
  then obtain x where x: "x \<in> convex hull S" "\<forall>y\<in>convex hull S. norm (y - a) \<le> norm (x - a)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5107
    using distance_attains_sup[OF finite_imp_compact_convex_hull[OF \<open>finite S\<close>], of a]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5108
    unfolding dist_commute[of a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5109
    unfolding dist_norm
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5110
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5111
  show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5112
  proof (cases "x \<in> S")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5113
    case False
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5114
    then obtain y where "y \<in> convex hull S" "norm (x - a) < norm (y - a)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5115
      using simplex_furthest_lt[OF assms(1), THEN bspec[where x=x]] and x(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5116
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5117
    then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5118
      using x(2)[THEN bspec[where x=y]] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5119
  next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5120
    case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5121
    with x show ?thesis by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5122
  qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5123
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5124
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5125
lemma simplex_furthest_le_exists:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5126
  fixes S :: "('a::real_inner) set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5127
  shows "finite S \<Longrightarrow> \<forall>x\<in>(convex hull S). \<exists>y\<in>S. norm (x - a) \<le> norm (y - a)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5128
  using simplex_furthest_le[of S] by (cases "S = {}") auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5129
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5130
lemma simplex_extremal_le:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5131
  fixes S :: "'a::real_inner set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5132
  assumes "finite S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5133
    and "S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5134
  shows "\<exists>u\<in>S. \<exists>v\<in>S. \<forall>x\<in>convex hull S. \<forall>y \<in> convex hull S. norm (x - y) \<le> norm (u - v)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5135
proof -
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5136
  have "convex hull S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5137
    using hull_subset[of S convex] and assms(2) by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5138
  then obtain u v where obt: "u \<in> convex hull S" "v \<in> convex hull S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5139
    "\<forall>x\<in>convex hull S. \<forall>y\<in>convex hull S. norm (x - y) \<le> norm (u - v)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5140
    using compact_sup_maxdistance[OF finite_imp_compact_convex_hull[OF assms(1)]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5141
    by (auto simp: dist_norm)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5142
  then show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5143
  proof (cases "u\<notin>S \<or> v\<notin>S", elim disjE)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5144
    assume "u \<notin> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5145
    then obtain y where "y \<in> convex hull S" "norm (u - v) < norm (y - v)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5146
      using simplex_furthest_lt[OF assms(1), THEN bspec[where x=u]] and obt(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5147
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5148
    then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5149
      using obt(3)[THEN bspec[where x=y], THEN bspec[where x=v]] and obt(2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5150
      by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5151
  next
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5152
    assume "v \<notin> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5153
    then obtain y where "y \<in> convex hull S" "norm (v - u) < norm (y - u)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5154
      using simplex_furthest_lt[OF assms(1), THEN bspec[where x=v]] and obt(2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5155
      by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5156
    then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5157
      using obt(3)[THEN bspec[where x=u], THEN bspec[where x=y]] and obt(1)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5158
      by (auto simp: norm_minus_commute)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5159
  qed auto
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  5160
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5161
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5162
lemma simplex_extremal_le_exists:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5163
  fixes S :: "'a::real_inner set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5164
  shows "finite S \<Longrightarrow> x \<in> convex hull S \<Longrightarrow> y \<in> convex hull S \<Longrightarrow>
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5165
    \<exists>u\<in>S. \<exists>v\<in>S. norm (x - y) \<le> norm (u - v)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5166
  using convex_hull_empty simplex_extremal_le[of S]
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5167
  by(cases "S = {}") auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5168
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5169
67968
a5ad4c015d1c removed dots at the end of (sub)titles
nipkow
parents: 67962
diff changeset
  5170
subsection \<open>Closest point of a convex set is unique, with a continuous projection\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5171
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5172
definition%important closest_point :: "'a::{real_inner,heine_borel} set \<Rightarrow> 'a \<Rightarrow> 'a"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5173
  where "closest_point S a = (SOME x. x \<in> S \<and> (\<forall>y\<in>S. dist a x \<le> dist a y))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5174
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5175
lemma closest_point_exists:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5176
  assumes "closed S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5177
    and "S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5178
  shows "closest_point S a \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5179
    and "\<forall>y\<in>S. dist a (closest_point S a) \<le> dist a y"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5180
  unfolding closest_point_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5181
  apply(rule_tac[!] someI2_ex)
62381
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5182
  apply (auto intro: distance_attains_inf[OF assms(1,2), of a])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5183
  done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5184
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5185
lemma closest_point_in_set: "closed S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> closest_point S a \<in> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5186
  by (meson closest_point_exists)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5187
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5188
lemma closest_point_le: "closed S \<Longrightarrow> x \<in> S \<Longrightarrow> dist a (closest_point S a) \<le> dist a x"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5189
  using closest_point_exists[of S] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5190
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5191
lemma closest_point_self:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5192
  assumes "x \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5193
  shows "closest_point S x = x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5194
  unfolding closest_point_def
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5195
  apply (rule some1_equality, rule ex1I[of _ x])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5196
  using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5197
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5198
  done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5199
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5200
lemma closest_point_refl: "closed S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> closest_point S x = x \<longleftrightarrow> x \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5201
  using closest_point_in_set[of S x] closest_point_self[of x S]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5202
  by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5203
36337
87b6c83d7ed7 generalize constant closest_point
huffman
parents: 36071
diff changeset
  5204
lemma closer_points_lemma:
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5205
  assumes "inner y z > 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5206
  shows "\<exists>u>0. \<forall>v>0. v \<le> u \<longrightarrow> norm(v *\<^sub>R z - y) < norm y"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5207
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5208
  have z: "inner z z > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5209
    unfolding inner_gt_zero_iff using assms by auto
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5210
  have "norm (v *\<^sub>R z - y) < norm y"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5211
    if "0 < v" and "v \<le> inner y z / inner z z" for v
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5212
    unfolding norm_lt using z assms that
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5213
    by (simp add: field_simps inner_diff inner_commute mult_strict_left_mono[OF _ \<open>0<v\<close>])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5214
  then show ?thesis
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5215
    using assms z
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5216
    by (rule_tac x = "inner y z / inner z z" in exI) auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5217
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5218
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5219
lemma closer_point_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5220
  assumes "inner (y - x) (z - x) > 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5221
  shows "\<exists>u>0. u \<le> 1 \<and> dist (x + u *\<^sub>R (z - x)) y < dist x y"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5222
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5223
  obtain u where "u > 0"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5224
    and u: "\<forall>v>0. v \<le> u \<longrightarrow> norm (v *\<^sub>R (z - x) - (y - x)) < norm (y - x)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5225
    using closer_points_lemma[OF assms] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5226
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5227
    apply (rule_tac x="min u 1" in exI)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5228
    using u[THEN spec[where x="min u 1"]] and \<open>u > 0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5229
    unfolding dist_norm by (auto simp: norm_minus_commute field_simps)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5230
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5231
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5232
lemma any_closest_point_dot:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5233
  assumes "convex S" "closed S" "x \<in> S" "y \<in> S" "\<forall>z\<in>S. dist a x \<le> dist a z"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5234
  shows "inner (a - x) (y - x) \<le> 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5235
proof (rule ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5236
  assume "\<not> ?thesis"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5237
  then obtain u where u: "u>0" "u\<le>1" "dist (x + u *\<^sub>R (y - x)) a < dist x a"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5238
    using closer_point_lemma[of a x y] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5239
  let ?z = "(1 - u) *\<^sub>R x + u *\<^sub>R y"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5240
  have "?z \<in> S"
61426
d53db136e8fd new material on path_component_sets, inside, outside, etc. And more default simprules
paulson <lp15@cam.ac.uk>
parents: 61222
diff changeset
  5241
    using convexD_alt[OF assms(1,3,4), of u] using u by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5242
  then show False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5243
    using assms(5)[THEN bspec[where x="?z"]] and u(3)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5244
    by (auto simp: dist_commute algebra_simps)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5245
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5246
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5247
lemma any_closest_point_unique:
36337
87b6c83d7ed7 generalize constant closest_point
huffman
parents: 36071
diff changeset
  5248
  fixes x :: "'a::real_inner"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5249
  assumes "convex S" "closed S" "x \<in> S" "y \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5250
    "\<forall>z\<in>S. dist a x \<le> dist a z" "\<forall>z\<in>S. dist a y \<le> dist a z"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5251
  shows "x = y"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5252
  using any_closest_point_dot[OF assms(1-4,5)] and any_closest_point_dot[OF assms(1-2,4,3,6)]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5253
  unfolding norm_pths(1) and norm_le_square
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5254
  by (auto simp: algebra_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5255
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5256
lemma closest_point_unique:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5257
  assumes "convex S" "closed S" "x \<in> S" "\<forall>z\<in>S. dist a x \<le> dist a z"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5258
  shows "x = closest_point S a"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5259
  using any_closest_point_unique[OF assms(1-3) _ assms(4), of "closest_point S a"]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5260
  using closest_point_exists[OF assms(2)] and assms(3) by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5261
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5262
lemma closest_point_dot:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5263
  assumes "convex S" "closed S" "x \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5264
  shows "inner (a - closest_point S a) (x - closest_point S a) \<le> 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5265
  apply (rule any_closest_point_dot[OF assms(1,2) _ assms(3)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5266
  using closest_point_exists[OF assms(2)] and assms(3)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5267
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5268
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5269
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5270
lemma closest_point_lt:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5271
  assumes "convex S" "closed S" "x \<in> S" "x \<noteq> closest_point S a"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5272
  shows "dist a (closest_point S a) < dist a x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5273
  apply (rule ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5274
  apply (rule_tac notE[OF assms(4)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5275
  apply (rule closest_point_unique[OF assms(1-3), of a])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5276
  using closest_point_le[OF assms(2), of _ a]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5277
  apply fastforce
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5278
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5279
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5280
lemma closest_point_lipschitz:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5281
  assumes "convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5282
    and "closed S" "S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5283
  shows "dist (closest_point S x) (closest_point S y) \<le> dist x y"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5284
proof -
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5285
  have "inner (x - closest_point S x) (closest_point S y - closest_point S x) \<le> 0"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5286
    and "inner (y - closest_point S y) (closest_point S x - closest_point S y) \<le> 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5287
    apply (rule_tac[!] any_closest_point_dot[OF assms(1-2)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5288
    using closest_point_exists[OF assms(2-3)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5289
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5290
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5291
  then show ?thesis unfolding dist_norm and norm_le
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5292
    using inner_ge_zero[of "(x - closest_point S x) - (y - closest_point S y)"]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5293
    by (simp add: inner_add inner_diff inner_commute)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5294
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5295
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5296
lemma continuous_at_closest_point:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5297
  assumes "convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5298
    and "closed S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5299
    and "S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5300
  shows "continuous (at x) (closest_point S)"
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  5301
  unfolding continuous_at_eps_delta
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5302
  using le_less_trans[OF closest_point_lipschitz[OF assms]] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5303
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5304
lemma continuous_on_closest_point:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5305
  assumes "convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5306
    and "closed S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5307
    and "S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5308
  shows "continuous_on t (closest_point S)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5309
  by (metis continuous_at_imp_continuous_on continuous_at_closest_point[OF assms])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5310
63881
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5311
proposition closest_point_in_rel_interior:
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5312
  assumes "closed S" "S \<noteq> {}" and x: "x \<in> affine hull S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5313
    shows "closest_point S x \<in> rel_interior S \<longleftrightarrow> x \<in> rel_interior S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5314
proof (cases "x \<in> S")
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5315
  case True
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5316
  then show ?thesis
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5317
    by (simp add: closest_point_self)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5318
next
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5319
  case False
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5320
  then have "False" if asm: "closest_point S x \<in> rel_interior S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5321
  proof -
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5322
    obtain e where "e > 0" and clox: "closest_point S x \<in> S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5323
               and e: "cball (closest_point S x) e \<inter> affine hull S \<subseteq> S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5324
      using asm mem_rel_interior_cball by blast
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5325
    then have clo_notx: "closest_point S x \<noteq> x"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5326
      using \<open>x \<notin> S\<close> by auto
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5327
    define y where "y \<equiv> closest_point S x -
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5328
                        (min 1 (e / norm(closest_point S x - x))) *\<^sub>R (closest_point S x - x)"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5329
    have "x - y = (1 - min 1 (e / norm (closest_point S x - x))) *\<^sub>R (x - closest_point S x)"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5330
      by (simp add: y_def algebra_simps)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5331
    then have "norm (x - y) = abs ((1 - min 1 (e / norm (closest_point S x - x)))) * norm(x - closest_point S x)"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5332
      by simp
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5333
    also have "\<dots> < norm(x - closest_point S x)"
63881
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5334
      using clo_notx \<open>e > 0\<close>
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5335
      by (auto simp: mult_less_cancel_right2 divide_simps)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5336
    finally have no_less: "norm (x - y) < norm (x - closest_point S x)" .
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5337
    have "y \<in> affine hull S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5338
      unfolding y_def
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5339
      by (meson affine_affine_hull clox hull_subset mem_affine_3_minus2 subsetD x)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5340
    moreover have "dist (closest_point S x) y \<le> e"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5341
      using \<open>e > 0\<close> by (auto simp: y_def min_mult_distrib_right)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5342
    ultimately have "y \<in> S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5343
      using subsetD [OF e] by simp
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5344
    then have "dist x (closest_point S x) \<le> dist x y"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5345
      by (simp add: closest_point_le \<open>closed S\<close>)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5346
    with no_less show False
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5347
      by (simp add: dist_norm)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5348
  qed
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5349
  moreover have "x \<notin> rel_interior S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5350
    using rel_interior_subset False by blast
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5351
  ultimately show ?thesis by blast
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5352
qed
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63627
diff changeset
  5353
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5354
67968
a5ad4c015d1c removed dots at the end of (sub)titles
nipkow
parents: 67962
diff changeset
  5355
subsubsection%unimportant \<open>Various point-to-set separating/supporting hyperplane theorems\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5356
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5357
lemma supporting_hyperplane_closed_point:
36337
87b6c83d7ed7 generalize constant closest_point
huffman
parents: 36071
diff changeset
  5358
  fixes z :: "'a::{real_inner,heine_borel}"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5359
  assumes "convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5360
    and "closed S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5361
    and "S \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5362
    and "z \<notin> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5363
  shows "\<exists>a b. \<exists>y\<in>S. inner a z < b \<and> inner a y = b \<and> (\<forall>x\<in>S. inner a x \<ge> b)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5364
proof -
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5365
  obtain y where "y \<in> S" and y: "\<forall>x\<in>S. dist z y \<le> dist z x"
63075
60a42a4166af lemmas about dimension, hyperplanes, span, etc.
paulson <lp15@cam.ac.uk>
parents: 63072
diff changeset
  5366
    by (metis distance_attains_inf[OF assms(2-3)])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5367
  show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5368
  proof (intro exI bexI conjI ballI)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5369
    show "(y - z) \<bullet> z < (y - z) \<bullet> y"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5370
      by (metis \<open>y \<in> S\<close> assms(4) diff_gt_0_iff_gt inner_commute inner_diff_left inner_gt_zero_iff right_minus_eq)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5371
    show "(y - z) \<bullet> y \<le> (y - z) \<bullet> x" if "x \<in> S" for x
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5372
    proof (rule ccontr)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5373
      have *: "\<And>u. 0 \<le> u \<and> u \<le> 1 \<longrightarrow> dist z y \<le> dist z ((1 - u) *\<^sub>R y + u *\<^sub>R x)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5374
        using assms(1)[unfolded convex_alt] and y and \<open>x\<in>S\<close> and \<open>y\<in>S\<close> by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5375
      assume "\<not> (y - z) \<bullet> y \<le> (y - z) \<bullet> x"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5376
      then obtain v where "v > 0" "v \<le> 1" "dist (y + v *\<^sub>R (x - y)) z < dist y z"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5377
        using closer_point_lemma[of z y x] by (auto simp: inner_diff)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5378
      then show False
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5379
        using *[of v] by (auto simp: dist_commute algebra_simps)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5380
    qed
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5381
  qed (use \<open>y \<in> S\<close> in auto)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5382
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5383
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5384
lemma separating_hyperplane_closed_point:
36337
87b6c83d7ed7 generalize constant closest_point
huffman
parents: 36071
diff changeset
  5385
  fixes z :: "'a::{real_inner,heine_borel}"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5386
  assumes "convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5387
    and "closed S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5388
    and "z \<notin> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5389
  shows "\<exists>a b. inner a z < b \<and> (\<forall>x\<in>S. inner a x > b)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5390
proof (cases "S = {}")
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5391
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5392
  then show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5393
    by (simp add: gt_ex)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5394
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5395
  case False
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5396
  obtain y where "y \<in> S" and y: "\<And>x. x \<in> S \<Longrightarrow> dist z y \<le> dist z x"
62381
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5397
    by (metis distance_attains_inf[OF assms(2) False])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5398
  show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5399
  proof (intro exI conjI ballI)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5400
    show "(y - z) \<bullet> z < inner (y - z) z + (norm (y - z))\<^sup>2 / 2"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5401
      using \<open>y\<in>S\<close> \<open>z\<notin>S\<close> by auto
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5402
  next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5403
    fix x
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5404
    assume "x \<in> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5405
    have "False" if *: "0 < inner (z - y) (x - y)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5406
    proof -
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5407
      obtain u where "u > 0" "u \<le> 1" "dist (y + u *\<^sub>R (x - y)) z < dist y z"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5408
        using * closer_point_lemma by blast
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5409
      then show False using y[of "y + u *\<^sub>R (x - y)"] convexD_alt [OF \<open>convex S\<close>]
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5410
        using \<open>x\<in>S\<close> \<open>y\<in>S\<close> by (auto simp: dist_commute algebra_simps)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5411
    qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5412
    moreover have "0 < (norm (y - z))\<^sup>2"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5413
      using \<open>y\<in>S\<close> \<open>z\<notin>S\<close> by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5414
    then have "0 < inner (y - z) (y - z)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5415
      unfolding power2_norm_eq_inner by simp
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5416
    ultimately show "(y - z) \<bullet> z + (norm (y - z))\<^sup>2 / 2 < (y - z) \<bullet> x"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5417
      by (force simp: field_simps power2_norm_eq_inner inner_commute inner_diff)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5418
  qed 
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5419
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5420
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5421
lemma separating_hyperplane_closed_0:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5422
  assumes "convex (S::('a::euclidean_space) set)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5423
    and "closed S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5424
    and "0 \<notin> S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5425
  shows "\<exists>a b. a \<noteq> 0 \<and> 0 < b \<and> (\<forall>x\<in>S. inner a x > b)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5426
proof (cases "S = {}")
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  5427
  case True
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5428
  have "(SOME i. i\<in>Basis) \<noteq> (0::'a)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5429
    by (metis Basis_zero SOME_Basis)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5430
  then show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5431
    using True zero_less_one by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5432
next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5433
  case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5434
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5435
    using False using separating_hyperplane_closed_point[OF assms]
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5436
    by (metis all_not_in_conv inner_zero_left inner_zero_right less_eq_real_def not_le)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5437
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5438
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5439
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5440
subsubsection%unimportant \<open>Now set-to-set for closed/compact sets\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5441
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5442
lemma separating_hyperplane_closed_compact:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5443
  fixes S :: "'a::euclidean_space set"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5444
  assumes "convex S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5445
    and "closed S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5446
    and "convex T"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5447
    and "compact T"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5448
    and "T \<noteq> {}"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5449
    and "S \<inter> T = {}"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5450
  shows "\<exists>a b. (\<forall>x\<in>S. inner a x < b) \<and> (\<forall>x\<in>T. inner a x > b)"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5451
proof (cases "S = {}")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5452
  case True
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5453
  obtain b where b: "b > 0" "\<forall>x\<in>T. norm x \<le> b"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5454
    using compact_imp_bounded[OF assms(4)] unfolding bounded_pos by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5455
  obtain z :: 'a where z: "norm z = b + 1"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5456
    using vector_choose_size[of "b + 1"] and b(1) by auto
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5457
  then have "z \<notin> T" using b(2)[THEN bspec[where x=z]] by auto
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5458
  then obtain a b where ab: "inner a z < b" "\<forall>x\<in>T. b < inner a x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5459
    using separating_hyperplane_closed_point[OF assms(3) compact_imp_closed[OF assms(4)], of z]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5460
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5461
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5462
    using True by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5463
next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5464
  case False
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5465
  then obtain y where "y \<in> S" by auto
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5466
  obtain a b where "0 < b" "\<forall>x \<in> (\<Union>x\<in> S. \<Union>y \<in> T. {x - y}). b < inner a x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5467
    using separating_hyperplane_closed_point[OF convex_differences[OF assms(1,3)], of 0]
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5468
    using closed_compact_differences[OF assms(2,4)]
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5469
    using assms(6) by auto 
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5470
  then have ab: "\<forall>x\<in>S. \<forall>y\<in>T. b + inner a y < inner a x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5471
    apply -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5472
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5473
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5474
    apply (erule_tac x="x - y" in ballE)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5475
    apply (auto simp: inner_diff)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5476
    done
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5477
  define k where "k = (SUP x:T. a \<bullet> x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5478
  show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5479
    apply (rule_tac x="-a" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5480
    apply (rule_tac x="-(k + b / 2)" in exI)
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  5481
    apply (intro conjI ballI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5482
    unfolding inner_minus_left and neg_less_iff_less
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5483
  proof -
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5484
    fix x assume "x \<in> T"
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  5485
    then have "inner a x - b / 2 < k"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5486
      unfolding k_def
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  5487
    proof (subst less_cSUP_iff)
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5488
      show "T \<noteq> {}" by fact
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  5489
      show "bdd_above ((\<bullet>) a ` T)"
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5490
        using ab[rule_format, of y] \<open>y \<in> S\<close>
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  5491
        by (intro bdd_aboveI2[where M="inner a y - b"]) (auto simp: field_simps intro: less_imp_le)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5492
    qed (auto intro!: bexI[of _ x] \<open>0<b\<close>)
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  5493
    then show "inner a x < k + b / 2"
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  5494
      by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5495
  next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5496
    fix x
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5497
    assume "x \<in> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5498
    then have "k \<le> inner a x - b"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5499
      unfolding k_def
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  5500
      apply (rule_tac cSUP_least)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5501
      using assms(5)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5502
      using ab[THEN bspec[where x=x]]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5503
      apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5504
      done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5505
    then show "k + b / 2 < inner a x"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5506
      using \<open>0 < b\<close> by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5507
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5508
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5509
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5510
lemma separating_hyperplane_compact_closed:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5511
  fixes S :: "'a::euclidean_space set"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5512
  assumes "convex S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5513
    and "compact S"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5514
    and "S \<noteq> {}"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5515
    and "convex T"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5516
    and "closed T"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5517
    and "S \<inter> T = {}"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5518
  shows "\<exists>a b. (\<forall>x\<in>S. inner a x < b) \<and> (\<forall>x\<in>T. inner a x > b)"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5519
proof -
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  5520
  obtain a b where "(\<forall>x\<in>T. inner a x < b) \<and> (\<forall>x\<in>S. b < inner a x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5521
    using separating_hyperplane_closed_compact[OF assms(4-5,1-2,3)] and assms(6)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5522
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5523
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5524
    apply (rule_tac x="-a" in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5525
    apply (rule_tac x="-b" in exI, auto)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5526
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5527
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5528
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5529
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5530
subsubsection%unimportant \<open>General case without assuming closure and getting non-strict separation\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5531
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5532
lemma separating_hyperplane_set_0:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5533
  assumes "convex S" "(0::'a::euclidean_space) \<notin> S"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5534
  shows "\<exists>a. a \<noteq> 0 \<and> (\<forall>x\<in>S. 0 \<le> inner a x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5535
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5536
  let ?k = "\<lambda>c. {x::'a. 0 \<le> inner c x}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5537
  have *: "frontier (cball 0 1) \<inter> \<Inter>f \<noteq> {}" if as: "f \<subseteq> ?k ` S" "finite f" for f
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5538
  proof -
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5539
    obtain c where c: "f = ?k ` c" "c \<subseteq> S" "finite c"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5540
      using finite_subset_image[OF as(2,1)] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5541
    then obtain a b where ab: "a \<noteq> 0" "0 < b" "\<forall>x\<in>convex hull c. b < inner a x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5542
      using separating_hyperplane_closed_0[OF convex_convex_hull, of c]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5543
      using finite_imp_compact_convex_hull[OF c(3), THEN compact_imp_closed] and assms(2)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5544
      using subset_hull[of convex, OF assms(1), symmetric, of c]
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61531
diff changeset
  5545
      by force
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5546
    then have "\<exists>x. norm x = 1 \<and> (\<forall>y\<in>c. 0 \<le> inner y x)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5547
      apply (rule_tac x = "inverse(norm a) *\<^sub>R a" in exI)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5548
      using hull_subset[of c convex]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5549
      unfolding subset_eq and inner_scaleR
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5550
      by (auto simp: inner_commute del: ballE elim!: ballE)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5551
    then show "frontier (cball 0 1) \<inter> \<Inter>f \<noteq> {}"
62381
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5552
      unfolding c(1) frontier_cball sphere_def dist_norm by auto
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5553
  qed
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5554
  have "frontier (cball 0 1) \<inter> (\<Inter>(?k ` S)) \<noteq> {}"
62381
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5555
    apply (rule compact_imp_fip)
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5556
    apply (rule compact_frontier[OF compact_cball])
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5557
    using * closed_halfspace_ge
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5558
    by auto
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5559
  then obtain x where "norm x = 1" "\<forall>y\<in>S. x\<in>?k y"
62381
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5560
    unfolding frontier_cball dist_norm sphere_def by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5561
  then show ?thesis
62381
a6479cb85944 New and revised material for (multivariate) analysis
paulson <lp15@cam.ac.uk>
parents: 62131
diff changeset
  5562
    by (metis inner_commute mem_Collect_eq norm_eq_zero zero_neq_one)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5563
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5564
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5565
lemma separating_hyperplane_sets:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5566
  fixes S T :: "'a::euclidean_space set"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5567
  assumes "convex S"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5568
    and "convex T"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5569
    and "S \<noteq> {}"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5570
    and "T \<noteq> {}"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5571
    and "S \<inter> T = {}"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5572
  shows "\<exists>a b. a \<noteq> 0 \<and> (\<forall>x\<in>S. inner a x \<le> b) \<and> (\<forall>x\<in>T. inner a x \<ge> b)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5573
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5574
  from separating_hyperplane_set_0[OF convex_differences[OF assms(2,1)]]
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5575
  obtain a where "a \<noteq> 0" "\<forall>x\<in>{x - y |x y. x \<in> T \<and> y \<in> S}. 0 \<le> inner a x"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5576
    using assms(3-5) by force
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5577
  then have *: "\<And>x y. x \<in> T \<Longrightarrow> y \<in> S \<Longrightarrow> inner a y \<le> inner a x"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5578
    by (force simp: inner_diff)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5579
  then have bdd: "bdd_above (((\<bullet>) a)`S)"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5580
    using \<open>T \<noteq> {}\<close> by (auto intro: bdd_aboveI2[OF *])
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54258
diff changeset
  5581
  show ?thesis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5582
    using \<open>a\<noteq>0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5583
    by (intro exI[of _ a] exI[of _ "SUP x:S. a \<bullet> x"])
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5584
       (auto intro!: cSUP_upper bdd cSUP_least \<open>a \<noteq> 0\<close> \<open>S \<noteq> {}\<close> *)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5585
qed
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5586
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5587
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5588
subsection%unimportant \<open>More convexity generalities\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5589
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  5590
lemma convex_closure [intro,simp]:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5591
  fixes S :: "'a::real_normed_vector set"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5592
  assumes "convex S"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5593
  shows "convex (closure S)"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5594
  apply (rule convexI)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5595
  apply (unfold closure_sequential, elim exE)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5596
  apply (rule_tac x="\<lambda>n. u *\<^sub>R xa n + v *\<^sub>R xb n" in exI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5597
  apply (rule,rule)
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5598
  apply (rule convexD [OF assms])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5599
  apply (auto del: tendsto_const intro!: tendsto_intros)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5600
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5601
62948
7700f467892b lots of new theorems for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 62843
diff changeset
  5602
lemma convex_interior [intro,simp]:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5603
  fixes S :: "'a::real_normed_vector set"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5604
  assumes "convex S"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5605
  shows "convex (interior S)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5606
  unfolding convex_alt Ball_def mem_interior
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5607
proof clarify
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5608
  fix x y u
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5609
  assume u: "0 \<le> u" "u \<le> (1::real)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5610
  fix e d
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5611
  assume ed: "ball x e \<subseteq> S" "ball y d \<subseteq> S" "0<d" "0<e"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5612
  show "\<exists>e>0. ball ((1 - u) *\<^sub>R x + u *\<^sub>R y) e \<subseteq> S"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5613
  proof (intro exI conjI subsetI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5614
    fix z
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5615
    assume "z \<in> ball ((1 - u) *\<^sub>R x + u *\<^sub>R y) (min d e)"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5616
    then have "(1- u) *\<^sub>R (z - u *\<^sub>R (y - x)) + u *\<^sub>R (z + (1 - u) *\<^sub>R (y - x)) \<in> S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5617
      apply (rule_tac assms[unfolded convex_alt, rule_format])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5618
      using ed(1,2) and u
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5619
      unfolding subset_eq mem_ball Ball_def dist_norm
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5620
      apply (auto simp: algebra_simps)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5621
      done
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5622
    then show "z \<in> S"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5623
      using u by (auto simp: algebra_simps)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5624
  qed(insert u ed(3-4), auto)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5625
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5626
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5627
lemma convex_hull_eq_empty[simp]: "convex hull S = {} \<longleftrightarrow> S = {}"
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5628
  using hull_subset[of S convex] convex_hull_empty by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5629
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5630
67968
a5ad4c015d1c removed dots at the end of (sub)titles
nipkow
parents: 67962
diff changeset
  5631
subsection%unimportant \<open>Moving and scaling convex hulls\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5632
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5633
lemma convex_hull_set_plus:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5634
  "convex hull (S + T) = convex hull S + convex hull T"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5635
  unfolding set_plus_image
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5636
  apply (subst convex_hull_linear_image [symmetric])
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5637
  apply (simp add: linear_iff scaleR_right_distrib)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5638
  apply (simp add: convex_hull_Times)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5639
  done
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5640
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5641
lemma translation_eq_singleton_plus: "(\<lambda>x. a + x) ` T = {a} + T"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5642
  unfolding set_plus_def by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5643
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5644
lemma convex_hull_translation:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5645
  "convex hull ((\<lambda>x. a + x) ` S) = (\<lambda>x. a + x) ` (convex hull S)"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5646
  unfolding translation_eq_singleton_plus
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5647
  by (simp only: convex_hull_set_plus convex_hull_singleton)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5648
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5649
lemma convex_hull_scaling:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5650
  "convex hull ((\<lambda>x. c *\<^sub>R x) ` S) = (\<lambda>x. c *\<^sub>R x) ` (convex hull S)"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5651
  using linear_scaleR by (rule convex_hull_linear_image [symmetric])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5652
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5653
lemma convex_hull_affinity:
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5654
  "convex hull ((\<lambda>x. a + c *\<^sub>R x) ` S) = (\<lambda>x. a + c *\<^sub>R x) ` (convex hull S)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5655
  by(simp only: image_image[symmetric] convex_hull_scaling convex_hull_translation)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5656
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5657
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5658
subsection%unimportant \<open>Convexity of cone hulls\<close>
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  5659
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  5660
lemma convex_cone_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5661
  assumes "convex S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5662
  shows "convex (cone hull S)"
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5663
proof (rule convexI)
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5664
  fix x y
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5665
  assume xy: "x \<in> cone hull S" "y \<in> cone hull S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5666
  then have "S \<noteq> {}"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5667
    using cone_hull_empty_iff[of S] by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5668
  fix u v :: real
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5669
  assume uv: "u \<ge> 0" "v \<ge> 0" "u + v = 1"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5670
  then have *: "u *\<^sub>R x \<in> cone hull S" "v *\<^sub>R y \<in> cone hull S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5671
    using cone_cone_hull[of S] xy cone_def[of "cone hull S"] by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5672
  from * obtain cx :: real and xx where x: "u *\<^sub>R x = cx *\<^sub>R xx" "cx \<ge> 0" "xx \<in> S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5673
    using cone_hull_expl[of S] by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5674
  from * obtain cy :: real and yy where y: "v *\<^sub>R y = cy *\<^sub>R yy" "cy \<ge> 0" "yy \<in> S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5675
    using cone_hull_expl[of S] by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5676
  {
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5677
    assume "cx + cy \<le> 0"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5678
    then have "u *\<^sub>R x = 0" and "v *\<^sub>R y = 0"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5679
      using x y by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5680
    then have "u *\<^sub>R x + v *\<^sub>R y = 0"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5681
      by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5682
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5683
      using cone_hull_contains_0[of S] \<open>S \<noteq> {}\<close> by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  5684
  }
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5685
  moreover
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5686
  {
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5687
    assume "cx + cy > 0"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5688
    then have "(cx / (cx + cy)) *\<^sub>R xx + (cy / (cx + cy)) *\<^sub>R yy \<in> S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5689
      using assms mem_convex_alt[of S xx yy cx cy] x y by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5690
    then have "cx *\<^sub>R xx + cy *\<^sub>R yy \<in> cone hull S"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5691
      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>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5692
      by (auto simp: scaleR_right_distrib)
53676
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5693
    then have "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S"
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5694
      using x y by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5695
  }
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5696
  moreover have "cx + cy \<le> 0 \<or> cx + cy > 0" by auto
476ef9b468d2 tuned proofs about 'convex'
huffman
parents: 53620
diff changeset
  5697
  ultimately show "u *\<^sub>R x + v *\<^sub>R y \<in> cone hull S" by blast
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  5698
qed
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  5699
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  5700
lemma cone_convex_hull:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5701
  assumes "cone S"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5702
  shows "cone (convex hull S)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5703
proof (cases "S = {}")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5704
  case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5705
  then show ?thesis by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5706
next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5707
  case False
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  5708
  then have *: "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> ( *\<^sub>R) c ` S = S)"
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5709
    using cone_iff[of S] assms by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5710
  {
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5711
    fix c :: real
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5712
    assume "c > 0"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  5713
    then have "( *\<^sub>R) c ` (convex hull S) = convex hull (( *\<^sub>R) c ` S)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5714
      using convex_hull_scaling[of _ S] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5715
    also have "\<dots> = convex hull S"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5716
      using * \<open>c > 0\<close> by auto
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  5717
    finally have "( *\<^sub>R) c ` (convex hull S) = convex hull S"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5718
      by auto
40377
0e5d48096f58 Extend convex analysis by Bogdan Grechuk
hoelzl
parents: 39302
diff changeset
  5719
  }
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  5720
  then have "0 \<in> convex hull S" "\<And>c. c > 0 \<Longrightarrow> (( *\<^sub>R) c ` (convex hull S)) = (convex hull S)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5721
    using * hull_subset[of S convex] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5722
  then show ?thesis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5723
    using \<open>S \<noteq> {}\<close> cone_iff[of "convex hull S"] by auto
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5724
qed
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5725
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5726
subsection%unimportant \<open>Convex set as intersection of halfspaces\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5727
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5728
lemma convex_halfspace_intersection:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5729
  fixes s :: "('a::euclidean_space) set"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5730
  assumes "closed s" "convex s"
60585
48fdff264eb2 tuned whitespace;
wenzelm
parents: 60420
diff changeset
  5731
  shows "s = \<Inter>{h. s \<subseteq> h \<and> (\<exists>a b. h = {x. inner a x \<le> b})}"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5732
  apply (rule set_eqI, rule)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5733
  unfolding Inter_iff Ball_def mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5734
  apply (rule,rule,erule conjE)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5735
proof -
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  5736
  fix x
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5737
  assume "\<forall>xa. s \<subseteq> xa \<and> (\<exists>a b. xa = {x. inner a x \<le> b}) \<longrightarrow> x \<in> xa"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5738
  then have "\<forall>a b. s \<subseteq> {x. inner a x \<le> b} \<longrightarrow> x \<in> {x. inner a x \<le> b}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5739
    by blast
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5740
  then show "x \<in> s"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5741
    apply (rule_tac ccontr)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5742
    apply (drule separating_hyperplane_closed_point[OF assms(2,1)])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5743
    apply (erule exE)+
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5744
    apply (erule_tac x="-a" in allE)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5745
    apply (erule_tac x="-b" in allE, auto)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5746
    done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5747
qed auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5748
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5749
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5750
subsection \<open>Radon's theorem (from Lars Schewe)\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5751
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5752
lemma radon_ex_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5753
  assumes "finite c" "affine_dependent c"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5754
  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"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5755
proof -
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5756
  from assms(2)[unfolded affine_dependent_explicit]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5757
  obtain s u where
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5758
      "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"
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5759
    by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5760
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5761
    apply (rule_tac x="\<lambda>v. if v\<in>s then u v else 0" in exI)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5762
    unfolding if_smult scaleR_zero_left and sum.inter_restrict[OF assms(1), symmetric]
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5763
    apply (auto simp: Int_absorb1)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5764
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5765
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5766
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5767
lemma radon_s_lemma:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5768
  assumes "finite s"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5769
    and "sum f s = (0::real)"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5770
  shows "sum f {x\<in>s. 0 < f x} = - sum f {x\<in>s. f x < 0}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5771
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5772
  have *: "\<And>x. (if f x < 0 then f x else 0) + (if 0 < f x then f x else 0) = f x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5773
    by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5774
  show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5775
    unfolding add_eq_0_iff[symmetric] and sum.inter_filter[OF assms(1)]
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5776
      and sum.distrib[symmetric] and *
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5777
    using assms(2)
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61531
diff changeset
  5778
    by assumption
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5779
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5780
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5781
lemma radon_v_lemma:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5782
  assumes "finite s"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5783
    and "sum f s = 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5784
    and "\<forall>x. g x = (0::real) \<longrightarrow> f x = (0::'a::euclidean_space)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5785
  shows "(sum f {x\<in>s. 0 < g x}) = - sum f {x\<in>s. g x < 0}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5786
proof -
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5787
  have *: "\<And>x. (if 0 < g x then f x else 0) + (if g x < 0 then f x else 0) = f x"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5788
    using assms(3) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5789
  show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5790
    unfolding eq_neg_iff_add_eq_0 and sum.inter_filter[OF assms(1)]
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5791
      and sum.distrib[symmetric] and *
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5792
    using assms(2)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5793
    apply assumption
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5794
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5795
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5796
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5797
lemma radon_partition:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5798
  assumes "finite c" "affine_dependent c"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5799
  shows "\<exists>m p. m \<inter> p = {} \<and> m \<union> p = c \<and> (convex hull m) \<inter> (convex hull p) \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5800
proof -
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5801
  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"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5802
    using radon_ex_lemma[OF assms] by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5803
  have fin: "finite {x \<in> c. 0 < u x}" "finite {x \<in> c. 0 > u x}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5804
    using assms(1) by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5805
  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}"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5806
  have "sum u {x \<in> c. 0 < u x} \<noteq> 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5807
  proof (cases "u v \<ge> 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5808
    case False
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5809
    then have "u v < 0" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5810
    then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5811
    proof (cases "\<exists>w\<in>{x \<in> c. 0 < u x}. u w > 0")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5812
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5813
      then show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5814
        using sum_nonneg_eq_0_iff[of _ u, OF fin(1)] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5815
    next
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5816
      case False
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5817
      then have "sum u c \<le> sum (\<lambda>x. if x=v then u v else 0) c"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5818
        apply (rule_tac sum_mono, auto)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5819
        done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5820
      then show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5821
        unfolding sum.delta[OF assms(1)] using uv(2) and \<open>u v < 0\<close> and uv(1) by auto
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5822
    qed
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5823
  qed (insert sum_nonneg_eq_0_iff[of _ u, OF fin(1)] uv(2-3), auto)
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5824
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5825
  then have *: "sum u {x\<in>c. u x > 0} > 0"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5826
    unfolding less_le
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5827
    apply (rule_tac conjI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5828
    apply (rule_tac sum_nonneg, auto)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5829
    done
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5830
  moreover have "sum u ({x \<in> c. 0 < u x} \<union> {x \<in> c. u x < 0}) = sum u c"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5831
    "(\<Sum>x\<in>{x \<in> c. 0 < u x} \<union> {x \<in> c. u x < 0}. u x *\<^sub>R x) = (\<Sum>x\<in>c. u x *\<^sub>R x)"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5832
    using assms(1)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5833
    apply (rule_tac[!] sum.mono_neutral_left, auto)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5834
    done
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5835
  then have "sum u {x \<in> c. 0 < u x} = - sum u {x \<in> c. 0 > u x}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5836
    "(\<Sum>x\<in>{x \<in> c. 0 < u x}. u x *\<^sub>R x) = - (\<Sum>x\<in>{x \<in> c. 0 > u x}. u x *\<^sub>R x)"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5837
    unfolding eq_neg_iff_add_eq_0
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5838
    using uv(1,4)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5839
    by (auto simp: sum.union_inter_neutral[OF fin, symmetric])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5840
  moreover have "\<forall>x\<in>{v \<in> c. u v < 0}. 0 \<le> inverse (sum u {x \<in> c. 0 < u x}) * - u x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5841
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5842
    apply (rule mult_nonneg_nonneg)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5843
    using *
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5844
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5845
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5846
  ultimately have "z \<in> convex hull {v \<in> c. u v \<le> 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5847
    unfolding convex_hull_explicit mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5848
    apply (rule_tac x="{v \<in> c. u v < 0}" in exI)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5849
    apply (rule_tac x="\<lambda>y. inverse (sum u {x\<in>c. u x > 0}) * - u y" in exI)
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5850
    using assms(1) unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] and z_def
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5851
    apply (auto simp: sum_negf sum_distrib_left[symmetric])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5852
    done
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5853
  moreover have "\<forall>x\<in>{v \<in> c. 0 < u v}. 0 \<le> inverse (sum u {x \<in> c. 0 < u x}) * u x"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5854
    apply rule
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5855
    apply (rule mult_nonneg_nonneg)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5856
    using *
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5857
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5858
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5859
  then have "z \<in> convex hull {v \<in> c. u v > 0}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5860
    unfolding convex_hull_explicit mem_Collect_eq
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5861
    apply (rule_tac x="{v \<in> c. 0 < u v}" in exI)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5862
    apply (rule_tac x="\<lambda>y. inverse (sum u {x\<in>c. u x > 0}) * u y" in exI)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5863
    using assms(1)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5864
    unfolding scaleR_scaleR[symmetric] scaleR_right.sum [symmetric] and z_def
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5865
    using *
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5866
    apply (auto simp: sum_negf sum_distrib_left[symmetric])
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5867
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5868
  ultimately show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5869
    apply (rule_tac x="{v\<in>c. u v \<le> 0}" in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  5870
    apply (rule_tac x="{v\<in>c. u v > 0}" in exI, auto)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5871
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5872
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5873
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5874
theorem%important radon:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5875
  assumes "affine_dependent c"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5876
  obtains m p where "m \<subseteq> c" "p \<subseteq> c" "m \<inter> p = {}" "(convex hull m) \<inter> (convex hull p) \<noteq> {}"
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5877
proof%unimportant -
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5878
  from assms[unfolded affine_dependent_explicit]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5879
  obtain s u where
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  5880
      "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"
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5881
    by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5882
  then have *: "finite s" "affine_dependent s" and s: "s \<subseteq> c"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5883
    unfolding affine_dependent_explicit by auto
55697
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5884
  from radon_partition[OF *]
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5885
  obtain m p where "m \<inter> p = {}" "m \<union> p = s" "convex hull m \<inter> convex hull p \<noteq> {}"
abec82f4e3e9 tuned proofs;
wenzelm
parents: 54780
diff changeset
  5886
    by blast
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5887
  then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5888
    apply (rule_tac that[of p m])
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5889
    using s
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5890
    apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5891
    done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5892
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5893
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5894
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5895
subsection \<open>Helly's theorem\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5896
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5897
lemma helly_induct:
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5898
  fixes f :: "'a::euclidean_space set set"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5899
  assumes "card f = n"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5900
    and "n \<ge> DIM('a) + 1"
60585
48fdff264eb2 tuned whitespace;
wenzelm
parents: 60420
diff changeset
  5901
    and "\<forall>s\<in>f. convex s" "\<forall>t\<subseteq>f. card t = DIM('a) + 1 \<longrightarrow> \<Inter>t \<noteq> {}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5902
  shows "\<Inter>f \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5903
  using assms
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5904
proof (induction n arbitrary: f)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5905
  case 0
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5906
  then show ?case by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5907
next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5908
  case (Suc n)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5909
  have "finite f"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5910
    using \<open>card f = Suc n\<close> by (auto intro: card_ge_0_finite)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5911
  show "\<Inter>f \<noteq> {}"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5912
  proof (cases "n = DIM('a)")
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5913
    case True
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5914
    then show ?thesis
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5915
      by (simp add: Suc.prems(1) Suc.prems(4))
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5916
  next
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5917
    case False
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5918
    have "\<Inter>(f - {s}) \<noteq> {}" if "s \<in> f" for s
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5919
    proof (rule Suc.IH[rule_format])
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5920
      show "card (f - {s}) = n"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5921
        by (simp add: Suc.prems(1) \<open>finite f\<close> that)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5922
      show "DIM('a) + 1 \<le> n"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5923
        using False Suc.prems(2) by linarith
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5924
      show "\<And>t. \<lbrakk>t \<subseteq> f - {s}; card t = DIM('a) + 1\<rbrakk> \<Longrightarrow> \<Inter>t \<noteq> {}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5925
        by (simp add: Suc.prems(4) subset_Diff_insert)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5926
    qed (use Suc in auto)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5927
    then have "\<forall>s\<in>f. \<exists>x. x \<in> \<Inter>(f - {s})"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5928
      by blast
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5929
    then obtain X where X: "\<And>s. s\<in>f \<Longrightarrow> X s \<in> \<Inter>(f - {s})"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5930
      by metis
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5931
    show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5932
    proof (cases "inj_on X f")
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5933
      case False
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5934
      then obtain s t where "s\<noteq>t" and st: "s\<in>f" "t\<in>f" "X s = X t"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5935
        unfolding inj_on_def by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5936
      then have *: "\<Inter>f = \<Inter>(f - {s}) \<inter> \<Inter>(f - {t})" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5937
      show ?thesis
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5938
        by (metis "*" X disjoint_iff_not_equal st)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5939
    next
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5940
      case True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5941
      then obtain m p where mp: "m \<inter> p = {}" "m \<union> p = X ` f" "convex hull m \<inter> convex hull p \<noteq> {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5942
        using radon_partition[of "X ` f"] and affine_dependent_biggerset[of "X ` f"]
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5943
        unfolding card_image[OF True] and \<open>card f = Suc n\<close>
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5944
        using Suc(3) \<open>finite f\<close> and False
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5945
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5946
      have "m \<subseteq> X ` f" "p \<subseteq> X ` f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5947
        using mp(2) by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5948
      then obtain g h where gh:"m = X ` g" "p = X ` h" "g \<subseteq> f" "h \<subseteq> f"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5949
        unfolding subset_image_iff by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5950
      then have "f \<union> (g \<union> h) = f" by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5951
      then have f: "f = g \<union> h"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5952
        using inj_on_Un_image_eq_iff[of X f "g \<union> h"] and True
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5953
        unfolding mp(2)[unfolded image_Un[symmetric] gh]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5954
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5955
      have *: "g \<inter> h = {}"
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5956
        using mp(1)
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5957
        unfolding gh
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5958
        using inj_on_image_Int[OF True gh(3,4)]
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5959
        by auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5960
      have "convex hull (X ` h) \<subseteq> \<Inter>g" "convex hull (X ` g) \<subseteq> \<Inter>h"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5961
        by (rule hull_minimal; use X * f in \<open>auto simp: Suc.prems(3) convex_Inter\<close>)+
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5962
      then show ?thesis
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5963
        unfolding f using mp(3)[unfolded gh] by blast
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5964
    qed
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5965
  qed 
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5966
qed
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5967
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5968
theorem%important helly:
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5969
  fixes f :: "'a::euclidean_space set set"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  5970
  assumes "card f \<ge> DIM('a) + 1" "\<forall>s\<in>f. convex s"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5971
    and "\<And>t. \<lbrakk>t\<subseteq>f; card t = DIM('a) + 1\<rbrakk> \<Longrightarrow> \<Inter>t \<noteq> {}"
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5972
  shows "\<Inter>f \<noteq> {}"
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  5973
  apply%unimportant (rule helly_induct)
53347
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5974
  using assms
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5975
  apply auto
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5976
  done
547610c26257 tuned proofs;
wenzelm
parents: 53339
diff changeset
  5977
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5978
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  5979
subsection \<open>Epigraphs of convex functions\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5980
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5981
definition%important "epigraph S (f :: _ \<Rightarrow> real) = {xy. fst xy \<in> S \<and> f (fst xy) \<le> snd xy}"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5982
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5983
lemma mem_epigraph: "(x, y) \<in> epigraph S f \<longleftrightarrow> x \<in> S \<and> f x \<le> y"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5984
  unfolding epigraph_def by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  5985
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5986
lemma convex_epigraph: "convex (epigraph S f) \<longleftrightarrow> convex_on S f \<and> convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5987
proof safe
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5988
  assume L: "convex (epigraph S f)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5989
  then show "convex_on S f"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5990
    by (auto simp: convex_def convex_on_def epigraph_def)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5991
  show "convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5992
    using L
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5993
    apply (clarsimp simp: convex_def convex_on_def epigraph_def)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5994
    apply (erule_tac x=x in allE)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5995
    apply (erule_tac x="f x" in allE, safe)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5996
    apply (erule_tac x=y in allE)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5997
    apply (erule_tac x="f y" in allE)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5998
    apply (auto simp: )
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  5999
    done
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6000
next
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6001
  assume "convex_on S f" "convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6002
  then show "convex (epigraph S f)"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6003
    unfolding convex_def convex_on_def epigraph_def
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6004
    apply safe
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6005
     apply (rule_tac [2] y="u * f a + v * f aa" in order_trans)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6006
      apply (auto intro!:mult_left_mono add_mono)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6007
    done
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6008
qed
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6009
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6010
lemma convex_epigraphI: "convex_on S f \<Longrightarrow> convex S \<Longrightarrow> convex (epigraph S f)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6011
  unfolding convex_epigraph by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6012
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6013
lemma convex_epigraph_convex: "convex S \<Longrightarrow> convex_on S f \<longleftrightarrow> convex(epigraph S f)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6014
  by (simp add: convex_epigraph)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6015
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6016
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  6017
subsubsection%unimportant \<open>Use this to derive general bound property of convex function\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6018
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6019
lemma convex_on:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6020
  assumes "convex S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6021
  shows "convex_on S f \<longleftrightarrow>
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6022
    (\<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>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6023
      f (sum (\<lambda>i. u i *\<^sub>R x i) {1..k}) \<le> sum (\<lambda>i. u i * f(x i)) {1..k})"
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6024
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6025
  unfolding convex_epigraph_convex[OF assms] convex epigraph_def Ball_def mem_Collect_eq
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6026
  unfolding fst_sum snd_sum fst_scaleR snd_scaleR
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6027
  apply safe
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6028
    apply (drule_tac x=k in spec)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6029
    apply (drule_tac x=u in spec)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6030
    apply (drule_tac x="\<lambda>i. (x i, f (x i))" in spec)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6031
    apply simp
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6032
  using assms[unfolded convex] apply simp
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6033
  apply (rule_tac y="\<Sum>i = 1..k. u i * f (fst (x i))" in order_trans, force)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6034
   apply (rule sum_mono)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6035
   apply (erule_tac x=i in allE)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6036
  unfolding real_scaleR_def
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6037
   apply (rule mult_left_mono)
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6038
  using assms[unfolded convex] apply auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6039
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6040
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6041
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  6042
subsection%unimportant \<open>Convexity of general and special intervals\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6043
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6044
lemma is_interval_convex:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6045
  fixes S :: "'a::euclidean_space set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6046
  assumes "is_interval S"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6047
  shows "convex S"
37732
6432bf0d7191 generalize type of is_interval to class euclidean_space
huffman
parents: 37673
diff changeset
  6048
proof (rule convexI)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6049
  fix x y and u v :: real
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6050
  assume as: "x \<in> S" "y \<in> S" "0 \<le> u" "0 \<le> v" "u + v = 1"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6051
  then have *: "u = 1 - v" "1 - v \<ge> 0" and **: "v = 1 - u" "1 - u \<ge> 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6052
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6053
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6054
    fix a b
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6055
    assume "\<not> b \<le> u * a + v * b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6056
    then have "u * a < (1 - v) * b"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6057
      unfolding not_le using as(4) by (auto simp: field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6058
    then have "a < b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6059
      unfolding * using as(4) *(2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6060
      apply (rule_tac mult_left_less_imp_less[of "1 - v"])
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6061
      apply (auto simp: field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6062
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6063
    then have "a \<le> u * a + v * b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6064
      unfolding * using as(4)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6065
      by (auto simp: field_simps intro!:mult_right_mono)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6066
  }
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6067
  moreover
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6068
  {
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6069
    fix a b
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6070
    assume "\<not> u * a + v * b \<le> a"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6071
    then have "v * b > (1 - u) * a"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6072
      unfolding not_le using as(4) by (auto simp: field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6073
    then have "a < b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6074
      unfolding * using as(4)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6075
      apply (rule_tac mult_left_less_imp_less)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6076
      apply (auto simp: field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6077
      done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6078
    then have "u * a + v * b \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6079
      unfolding **
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6080
      using **(2) as(3)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6081
      by (auto simp: field_simps intro!:mult_right_mono)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6082
  }
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6083
  ultimately show "u *\<^sub>R x + v *\<^sub>R y \<in> S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6084
    apply -
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6085
    apply (rule assms[unfolded is_interval_def, rule_format, OF as(1,2)])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6086
    using as(3-) DIM_positive[where 'a='a]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6087
    apply (auto simp: inner_simps)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6088
    done
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6089
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6090
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6091
lemma is_interval_connected:
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6092
  fixes S :: "'a::euclidean_space set"
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6093
  shows "is_interval S \<Longrightarrow> connected S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6094
  using is_interval_convex convex_connected by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6095
62618
f7f2467ab854 Refactoring (moving theorems into better locations), plus a bit of new material
paulson <lp15@cam.ac.uk>
parents: 62533
diff changeset
  6096
lemma convex_box [simp]: "convex (cbox a b)" "convex (box a (b::'a::euclidean_space))"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6097
  apply (rule_tac[!] is_interval_convex)+
56189
c4daa97ac57a removed dependencies on theory Ordered_Euclidean_Space
immler
parents: 56188
diff changeset
  6098
  using is_interval_box is_interval_cbox
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6099
  apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6100
  done
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6101
63928
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6102
text\<open>A non-singleton connected set is perfect (i.e. has no isolated points). \<close>
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6103
lemma connected_imp_perfect:
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6104
  fixes a :: "'a::metric_space"
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6105
  assumes "connected S" "a \<in> S" and S: "\<And>x. S \<noteq> {x}"
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6106
  shows "a islimpt S"
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6107
proof -
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6108
  have False if "a \<in> T" "open T" "\<And>y. \<lbrakk>y \<in> S; y \<in> T\<rbrakk> \<Longrightarrow> y = a" for T
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6109
  proof -
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6110
    obtain e where "e > 0" and e: "cball a e \<subseteq> T"
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6111
      using \<open>open T\<close> \<open>a \<in> T\<close> by (auto simp: open_contains_cball)
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6112
    have "openin (subtopology euclidean S) {a}"
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6113
      unfolding openin_open using that \<open>a \<in> S\<close> by blast
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6114
    moreover have "closedin (subtopology euclidean S) {a}"
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6115
      by (simp add: assms)
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6116
    ultimately show "False"
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6117
      using \<open>connected S\<close> connected_clopen S by blast
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6118
  qed
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6119
  then show ?thesis
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6120
    unfolding islimpt_def by blast
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6121
qed
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6122
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6123
lemma connected_imp_perfect_aff_dim:
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6124
     "\<lbrakk>connected S; aff_dim S \<noteq> 0; a \<in> S\<rbrakk> \<Longrightarrow> a islimpt S"
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6125
  using aff_dim_sing connected_imp_perfect by blast
d81fb5b46a5c new material about topological concepts, etc
paulson <lp15@cam.ac.uk>
parents: 63918
diff changeset
  6126
67968
a5ad4c015d1c removed dots at the end of (sub)titles
nipkow
parents: 67962
diff changeset
  6127
subsection%unimportant \<open>On \<open>real\<close>, \<open>is_interval\<close>, \<open>convex\<close> and \<open>connected\<close> are all equivalent\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6128
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6129
lemma mem_is_interval_1_I:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6130
  fixes a b c::real
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6131
  assumes "is_interval S"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6132
  assumes "a \<in> S" "c \<in> S"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6133
  assumes "a \<le> b" "b \<le> c"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6134
  shows "b \<in> S"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6135
  using assms is_interval_1 by blast
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6136
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6137
lemma is_interval_connected_1:
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6138
  fixes s :: "real set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6139
  shows "is_interval s \<longleftrightarrow> connected s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6140
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6141
  apply (rule is_interval_connected, assumption)
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6142
  unfolding is_interval_1
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6143
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6144
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6145
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6146
  apply rule
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6147
  apply (erule conjE)
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  6148
  apply (rule ccontr)       
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6149
proof -
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6150
  fix a b x
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6151
  assume as: "connected s" "a \<in> s" "b \<in> s" "a \<le> x" "x \<le> b" "x \<notin> s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6152
  then have *: "a < x" "x < b"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6153
    unfolding not_le [symmetric] by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6154
  let ?halfl = "{..<x} "
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6155
  let ?halfr = "{x<..}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6156
  {
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6157
    fix y
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6158
    assume "y \<in> s"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6159
    with \<open>x \<notin> s\<close> have "x \<noteq> y" by auto
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6160
    then have "y \<in> ?halfr \<union> ?halfl" by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6161
  }
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6162
  moreover have "a \<in> ?halfl" "b \<in> ?halfr" using * by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6163
  then have "?halfl \<inter> s \<noteq> {}" "?halfr \<inter> s \<noteq> {}"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6164
    using as(2-3) by auto
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6165
  ultimately show False
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6166
    apply (rule_tac notE[OF as(1)[unfolded connected_def]])
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6167
    apply (rule_tac x = ?halfl in exI)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6168
    apply (rule_tac x = ?halfr in exI, rule)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6169
    apply (rule open_lessThan, rule)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6170
    apply (rule open_greaterThan, auto)
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6171
    done
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6172
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6173
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6174
lemma is_interval_convex_1:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6175
  fixes s :: "real set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6176
  shows "is_interval s \<longleftrightarrow> convex s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6177
  by (metis is_interval_convex convex_connected is_interval_connected_1)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6178
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6179
lemma is_interval_ball_real: "is_interval (ball a b)" for a b::real
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6180
  by (metis connected_ball is_interval_connected_1)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6181
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  6182
lemma connected_compact_interval_1:
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  6183
     "connected S \<and> compact S \<longleftrightarrow> (\<exists>a b. S = {a..b::real})"
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  6184
  by (auto simp: is_interval_connected_1 [symmetric] is_interval_compact)
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64394
diff changeset
  6185
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6186
lemma connected_convex_1:
54465
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6187
  fixes s :: "real set"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6188
  shows "connected s \<longleftrightarrow> convex s"
2f7867850cc3 tuned proofs;
wenzelm
parents: 54263
diff changeset
  6189
  by (metis is_interval_convex convex_connected is_interval_connected_1)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6190
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6191
lemma connected_convex_1_gen:
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6192
  fixes s :: "'a :: euclidean_space set"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6193
  assumes "DIM('a) = 1"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6194
  shows "connected s \<longleftrightarrow> convex s"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6195
proof -
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6196
  obtain f:: "'a \<Rightarrow> real" where linf: "linear f" and "inj f"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  6197
    using subspace_isomorphism[OF subspace_UNIV subspace_UNIV,
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  6198
        where 'a='a and 'b=real]
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  6199
    unfolding Euclidean_Space.dim_UNIV
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  6200
    by (auto simp: assms)
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6201
  then have "f -` (f ` s) = s"
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6202
    by (simp add: inj_vimage_image_eq)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6203
  then show ?thesis
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6204
    by (metis connected_convex_1 convex_linear_vimage linf convex_connected connected_linear_image)
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6205
qed
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6206
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6207
lemma is_interval_cball_1[intro, simp]: "is_interval (cball a b)" for a b::real
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  6208
  by (simp add: is_interval_convex_1)
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6209
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 67613
diff changeset
  6210
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  6211
subsection%unimportant \<open>Another intermediate value theorem formulation\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6212
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6213
lemma ivt_increasing_component_on_1:
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61531
diff changeset
  6214
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6215
  assumes "a \<le> b"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6216
    and "continuous_on {a..b} f"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6217
    and "(f a)\<bullet>k \<le> y" "y \<le> (f b)\<bullet>k"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6218
  shows "\<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6219
proof -
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6220
  have "f a \<in> f ` cbox a b" "f b \<in> f ` cbox a b"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6221
    apply (rule_tac[!] imageI)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6222
    using assms(1)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6223
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6224
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6225
  then show ?thesis
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6226
    using connected_ivt_component[of "f ` cbox a b" "f a" "f b" k y]
66827
c94531b5007d Divided Topology_Euclidean_Space in two, creating new theory Connected. Also deleted some duplicate / variant theorems
paulson <lp15@cam.ac.uk>
parents: 66793
diff changeset
  6227
    by (simp add: connected_continuous_image assms)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6228
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6229
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6230
lemma ivt_increasing_component_1:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6231
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6232
  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>{a..b}. continuous (at x) f \<Longrightarrow>
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6233
    f a\<bullet>k \<le> y \<Longrightarrow> y \<le> f b\<bullet>k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6234
  by (rule ivt_increasing_component_on_1) (auto simp: continuous_at_imp_continuous_on)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6235
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6236
lemma ivt_decreasing_component_on_1:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6237
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6238
  assumes "a \<le> b"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6239
    and "continuous_on {a..b} f"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6240
    and "(f b)\<bullet>k \<le> y"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6241
    and "y \<le> (f a)\<bullet>k"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6242
  shows "\<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6243
  apply (subst neg_equal_iff_equal[symmetric])
44531
1d477a2b1572 replace some continuous_on lemmas with more general versions
huffman
parents: 44525
diff changeset
  6244
  using ivt_increasing_component_on_1[of a b "\<lambda>x. - f x" k "- y"]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6245
  using assms using continuous_on_minus
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6246
  apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6247
  done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6248
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6249
lemma ivt_decreasing_component_1:
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6250
  fixes f :: "real \<Rightarrow> 'a::euclidean_space"
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6251
  shows "a \<le> b \<Longrightarrow> \<forall>x\<in>{a..b}. continuous (at x) f \<Longrightarrow>
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61426
diff changeset
  6252
    f b\<bullet>k \<le> y \<Longrightarrow> y \<le> f a\<bullet>k \<Longrightarrow> \<exists>x\<in>{a..b}. (f x)\<bullet>k = y"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6253
  by (rule ivt_decreasing_component_on_1) (auto simp: continuous_at_imp_continuous_on)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6254
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6255
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  6256
subsection%unimportant \<open>A bound within a convex hull, and so an interval\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6257
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6258
lemma convex_on_convex_hull_bound:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6259
  assumes "convex_on (convex hull s) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6260
    and "\<forall>x\<in>s. f x \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6261
  shows "\<forall>x\<in> convex hull s. f x \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6262
proof
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6263
  fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6264
  assume "x \<in> convex hull s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6265
  then obtain k u v where
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6266
    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"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6267
    unfolding convex_hull_indexed mem_Collect_eq by auto
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6268
  have "(\<Sum>i = 1..k. u i * f (v i)) \<le> b"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6269
    using sum_mono[of "{1..k}" "\<lambda>i. u i * f (v i)" "\<lambda>i. u i * b"]
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6270
    unfolding sum_distrib_right[symmetric] obt(2) mult_1
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6271
    apply (drule_tac meta_mp)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6272
    apply (rule mult_left_mono)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6273
    using assms(2) obt(1)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6274
    apply auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6275
    done
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6276
  then show "f x \<le> b"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6277
    using assms(1)[unfolded convex_on[OF convex_convex_hull], rule_format, of k u v]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6278
    unfolding obt(2-3)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6279
    using obt(1) and hull_subset[unfolded subset_eq, rule_format, of _ s]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6280
    by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6281
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6282
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6283
lemma inner_sum_Basis[simp]: "i \<in> Basis \<Longrightarrow> (\<Sum>Basis) \<bullet> i = 1"
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6284
  by (simp add: inner_sum_left sum.If_cases inner_Basis)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6285
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6286
lemma convex_set_plus:
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  6287
  assumes "convex S" and "convex T" shows "convex (S + T)"
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  6288
proof -
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  6289
  have "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6290
    using assms by (rule convex_sums)
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  6291
  moreover have "(\<Union>x\<in> S. \<Union>y \<in> T. {x + y}) = S + T"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6292
    unfolding set_plus_def by auto
65038
9391ea7daa17 new lemmas about segments, etc. Also recast some theorems to use Union rather than general set comprehensions
paulson <lp15@cam.ac.uk>
parents: 65036
diff changeset
  6293
  finally show "convex (S + T)" .
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6294
qed
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6295
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6296
lemma convex_set_sum:
55929
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  6297
  assumes "\<And>i. i \<in> A \<Longrightarrow> convex (B i)"
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  6298
  shows "convex (\<Sum>i\<in>A. B i)"
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  6299
proof (cases "finite A")
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  6300
  case True then show ?thesis using assms
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  6301
    by induct (auto simp: convex_set_plus)
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  6302
qed auto
91f245c23bc5 remove lemmas in favor of more general ones: convex(_hull)_set_{plus,setsum}
huffman
parents: 55928
diff changeset
  6303
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6304
lemma finite_set_sum:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6305
  assumes "finite A" and "\<forall>i\<in>A. finite (B i)" shows "finite (\<Sum>i\<in>A. B i)"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6306
  using assms by (induct set: finite, simp, simp add: finite_set_plus)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6307
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6308
lemma box_eq_set_sum_Basis:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6309
  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))"
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  6310
  apply (subst set_sum_alt [OF finite_Basis], safe)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6311
  apply (fast intro: euclidean_representation [symmetric])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6312
  apply (subst inner_sum_left)
68041
d45b78cb86cf more messy proofs redone, and new material
paulson <lp15@cam.ac.uk>
parents: 68031
diff changeset
  6313
apply (rename_tac f)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6314
  apply (subgoal_tac "(\<Sum>x\<in>Basis. f x \<bullet> i) = f i \<bullet> i")
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6315
  apply (drule (1) bspec)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6316
  apply clarsimp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6317
  apply (frule sum.remove [OF finite_Basis])
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6318
  apply (erule trans, simp)
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6319
  apply (rule sum.neutral, clarsimp)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6320
  apply (frule_tac x=i in bspec, assumption)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6321
  apply (drule_tac x=x in bspec, assumption, clarsimp)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6322
  apply (cut_tac u=x and v=i in inner_Basis, assumption+)
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6323
  apply (rule ccontr, simp)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6324
  done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6325
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6326
lemma convex_hull_set_sum:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6327
  "convex hull (\<Sum>i\<in>A. B i) = (\<Sum>i\<in>A. convex hull (B i))"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6328
proof (cases "finite A")
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6329
  assume "finite A" then show ?thesis
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6330
    by (induct set: finite, simp, simp add: convex_hull_set_plus)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6331
qed simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6332
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6333
lemma convex_hull_eq_real_cbox:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6334
  fixes x y :: real assumes "x \<le> y"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6335
  shows "convex hull {x, y} = cbox x y"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6336
proof (rule hull_unique)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6337
  show "{x, y} \<subseteq> cbox x y" using \<open>x \<le> y\<close> by auto
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6338
  show "convex (cbox x y)"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6339
    by (rule convex_box)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6340
next
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6341
  fix S assume "{x, y} \<subseteq> S" and "convex S"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6342
  then show "cbox x y \<subseteq> S"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6343
    unfolding is_interval_convex_1 [symmetric] is_interval_def Basis_real_def
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6344
    by - (clarify, simp (no_asm_use), fast)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6345
qed
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6346
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6347
lemma unit_interval_convex_hull:
57447
87429bdecad5 import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents: 57418
diff changeset
  6348
  "cbox (0::'a::euclidean_space) One = convex hull {x. \<forall>i\<in>Basis. (x\<bullet>i = 0) \<or> (x\<bullet>i = 1)}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  6349
  (is "?int = convex hull ?points")
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6350
proof -
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6351
  have One[simp]: "\<And>i. i \<in> Basis \<Longrightarrow> One \<bullet> i = 1"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6352
    by (simp add: inner_sum_left sum.If_cases inner_Basis)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6353
  have "?int = {x. \<forall>i\<in>Basis. x \<bullet> i \<in> cbox 0 1}"
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6354
    by (auto simp: cbox_def)
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6355
  also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` cbox 0 1)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6356
    by (simp only: box_eq_set_sum_Basis)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6357
  also have "\<dots> = (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` (convex hull {0, 1}))"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6358
    by (simp only: convex_hull_eq_real_cbox zero_le_one)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6359
  also have "\<dots> = (\<Sum>i\<in>Basis. convex hull ((\<lambda>x. x *\<^sub>R i) ` {0, 1}))"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  6360
    by (simp add: convex_hull_linear_image)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6361
  also have "\<dots> = convex hull (\<Sum>i\<in>Basis. (\<lambda>x. x *\<^sub>R i) ` {0, 1})"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6362
    by (simp only: convex_hull_set_sum)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6363
  also have "\<dots> = convex hull {x. \<forall>i\<in>Basis. x\<bullet>i \<in> {0, 1}}"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6364
    by (simp only: box_eq_set_sum_Basis)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6365
  also have "convex hull {x. \<forall>i\<in>Basis. x\<bullet>i \<in> {0, 1}} = convex hull ?points"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6366
    by simp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6367
  finally show ?thesis .
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6368
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6369
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6370
text \<open>And this is a finite set of vertices.\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6371
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6372
lemma unit_cube_convex_hull:
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6373
  obtains S :: "'a::euclidean_space set"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6374
  where "finite S" and "cbox 0 (\<Sum>Basis) = convex hull S"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6375
proof
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6376
  show "finite {x::'a. \<forall>i\<in>Basis. x \<bullet> i = 0 \<or> x \<bullet> i = 1}"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6377
  proof (rule finite_subset, clarify)
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6378
    show "finite ((\<lambda>S. \<Sum>i\<in>Basis. (if i \<in> S then 1 else 0) *\<^sub>R i) ` Pow Basis)"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6379
      using finite_Basis by blast
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6380
    fix x :: 'a
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6381
    assume as: "\<forall>i\<in>Basis. x \<bullet> i = 0 \<or> x \<bullet> i = 1"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6382
    show "x \<in> (\<lambda>S. \<Sum>i\<in>Basis. (if i\<in>S then 1 else 0) *\<^sub>R i) ` Pow Basis"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6383
      apply (rule image_eqI[where x="{i. i\<in>Basis \<and> x\<bullet>i = 1}"])
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6384
      using as
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6385
       apply (subst euclidean_eq_iff, auto)
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6386
      done
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6387
  qed
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6388
  show "cbox 0 One = convex hull {x. \<forall>i\<in>Basis. x \<bullet> i = 0 \<or> x \<bullet> i = 1}"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6389
    using unit_interval_convex_hull by blast
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6390
qed 
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6391
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6392
text \<open>Hence any cube (could do any nonempty interval).\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6393
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6394
lemma cube_convex_hull:
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6395
  assumes "d > 0"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6396
  obtains S :: "'a::euclidean_space set" where
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6397
    "finite S" and "cbox (x - (\<Sum>i\<in>Basis. d*\<^sub>Ri)) (x + (\<Sum>i\<in>Basis. d*\<^sub>Ri)) = convex hull S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6398
proof -
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6399
  let ?d = "(\<Sum>i\<in>Basis. d *\<^sub>R i)::'a"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6400
  have *: "cbox (x - ?d) (x + ?d) = (\<lambda>y. x - ?d + (2 * d) *\<^sub>R y) ` cbox 0 (\<Sum>Basis)"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6401
  proof (intro set_eqI iffI)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6402
    fix y
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6403
    assume "y \<in> cbox (x - ?d) (x + ?d)"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6404
    then have "inverse (2 * d) *\<^sub>R (y - (x - ?d)) \<in> cbox 0 (\<Sum>Basis)"
58776
95e58e04e534 use NO_MATCH-simproc for distribution rules in field_simps, otherwise field_simps on '(a / (c + d)) * (e + f)' can be non-terminating
hoelzl
parents: 57865
diff changeset
  6405
      using assms by (simp add: mem_box field_simps inner_simps)
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6406
    with \<open>0 < d\<close> show "y \<in> (\<lambda>y. x - sum (( *\<^sub>R) d) Basis + (2 * d) *\<^sub>R y) ` cbox 0 One"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6407
      by (auto intro: image_eqI[where x= "inverse (2 * d) *\<^sub>R (y - (x - ?d))"])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6408
  next
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6409
    fix y
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6410
    assume "y \<in> (\<lambda>y. x - ?d + (2 * d) *\<^sub>R y) ` cbox 0 One"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6411
    then obtain z where z: "z \<in> cbox 0 One" "y = x - ?d + (2*d) *\<^sub>R z"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6412
      by auto
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6413
    then show "y \<in> cbox (x - ?d) (x + ?d)"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6414
      using z assms by (auto simp: mem_box inner_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6415
  qed
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6416
  obtain S where "finite S" "cbox 0 (\<Sum>Basis::'a) = convex hull S"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6417
    using unit_cube_convex_hull by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6418
  then show ?thesis
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6419
    by (rule_tac that[of "(\<lambda>y. x - ?d + (2 * d) *\<^sub>R y)` S"]) (auto simp: convex_hull_affinity *)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6420
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6421
67982
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67968
diff changeset
  6422
subsection%unimportant\<open>Representation of any interval as a finite convex hull\<close>
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6423
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6424
lemma image_stretch_interval:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6425
  "(\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k)) *\<^sub>R k) ` cbox a (b::'a::euclidean_space) =
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6426
  (if (cbox a b) = {} then {} else
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6427
    cbox (\<Sum>k\<in>Basis. (min (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k::'a)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6428
     (\<Sum>k\<in>Basis. (max (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k))"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6429
proof cases
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6430
  assume *: "cbox a b \<noteq> {}"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6431
  show ?thesis
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6432
    unfolding box_ne_empty if_not_P[OF *]
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6433
    apply (simp add: cbox_def image_Collect set_eq_iff euclidean_eq_iff[where 'a='a] ball_conj_distrib[symmetric])
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6434
    apply (subst choice_Basis_iff[symmetric])
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6435
  proof (intro allI ball_cong refl)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6436
    fix x i :: 'a assume "i \<in> Basis"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6437
    with * have a_le_b: "a \<bullet> i \<le> b \<bullet> i"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6438
      unfolding box_ne_empty by auto
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6439
    show "(\<exists>xa. x \<bullet> i = m i * xa \<and> a \<bullet> i \<le> xa \<and> xa \<le> b \<bullet> i) \<longleftrightarrow>
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6440
        min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) \<le> x \<bullet> i \<and> x \<bullet> i \<le> max (m i * (a \<bullet> i)) (m i * (b \<bullet> i))"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6441
    proof (cases "m i = 0")
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6442
      case True
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6443
      with a_le_b show ?thesis by auto
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6444
    next
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6445
      case False
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6446
      then have *: "\<And>a b. a = m i * b \<longleftrightarrow> b = a / m i"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6447
        by (auto simp: field_simps)
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6448
      from False have
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6449
          "min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) = (if 0 < m i then m i * (a \<bullet> i) else m i * (b \<bullet> i))"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6450
          "max (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) = (if 0 < m i then m i * (b \<bullet> i) else m i * (a \<bullet> i))"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6451
        using a_le_b by (auto simp: min_def max_def mult_le_cancel_left)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6452
      with False show ?thesis using a_le_b
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6453
        unfolding * by (auto simp: le_divide_eq divide_le_eq ac_simps)
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6454
    qed
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6455
  qed
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6456
qed simp
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6457
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6458
lemma interval_image_stretch_interval:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6459
  "\<exists>u v. (\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k) ` cbox a (b::'a::euclidean_space) = cbox u (v::'a::euclidean_space)"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6460
  unfolding image_stretch_interval by auto
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6461
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6462
lemma cbox_translation: "cbox (c + a) (c + b) = image (\<lambda>x. c + x) (cbox a b)"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6463
  using image_affinity_cbox [of 1 c a b]
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6464
  using box_ne_empty [of "a+c" "b+c"]  box_ne_empty [of a b]
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6465
  by (auto simp: inner_left_distrib add.commute)
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6466
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6467
lemma cbox_image_unit_interval:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6468
  fixes a :: "'a::euclidean_space"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6469
  assumes "cbox a b \<noteq> {}"
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6470
    shows "cbox a b =
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67155
diff changeset
  6471
           (+) a ` (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k) ` cbox 0 One"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6472
using assms
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6473
apply (simp add: box_ne_empty image_stretch_interval cbox_translation [symmetric])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6474
apply (simp add: min_def max_def algebra_simps sum_subtractf euclidean_representation)
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6475
done
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6476
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6477
lemma closed_interval_as_convex_hull:
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6478
  fixes a :: "'a::euclidean_space"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6479
  obtains S where "finite S" "cbox a b = convex hull S"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6480
proof (cases "cbox a b = {}")
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6481
  case True with convex_hull_empty that show ?thesis
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6482
    by blast
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6483
next
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6484
  case False
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6485
  obtain S::"'a set" where "finite S" and eq: "cbox 0 One = convex hull S"
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6486
    by (blast intro: unit_cube_convex_hull)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6487
  have lin: "linear (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6488
    by (rule linear_compose_sum) (auto simp: algebra_simps linearI)
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6489
  have "finite ((+) a ` (\<lambda>x. \<Sum>k\<in>Basis. ((b \<bullet> k - a \<bullet> k) * (x \<bullet> k)) *\<^sub>R k) ` S)"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6490
    by (rule finite_imageI \<open>finite S\<close>)+
63007
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6491
  then show ?thesis
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6492
    apply (rule that)
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6493
    apply (simp add: convex_hull_translation convex_hull_linear_image [OF lin, symmetric])
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6494
    apply (simp add: eq [symmetric] cbox_image_unit_interval [OF False])
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6495
    done
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6496
qed
aa894a49f77d new theorems about convex hulls, etc.; also, renamed some theorems
paulson <lp15@cam.ac.uk>
parents: 62950
diff changeset
  6497
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6498
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  6499
subsection%unimportant \<open>Bounded convex function on open set is continuous\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6500
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6501
lemma convex_on_bounded_continuous:
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6502
  fixes S :: "('a::real_normed_vector) set"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6503
  assumes "open S"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6504
    and "convex_on S f"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6505
    and "\<forall>x\<in>S. \<bar>f x\<bar> \<le> b"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6506
  shows "continuous_on S f"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6507
  apply (rule continuous_at_imp_continuous_on)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6508
  unfolding continuous_at_real_range
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6509
proof (rule,rule,rule)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6510
  fix x and e :: real
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6511
  assume "x \<in> S" "e > 0"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  6512
  define B where "B = \<bar>b\<bar> + 1"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6513
  then have B:  "0 < B""\<And>x. x\<in>S \<Longrightarrow> \<bar>f x\<bar> \<le> B"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6514
    using assms(3) by auto 
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6515
  obtain k where "k > 0" and k: "cball x k \<subseteq> S"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6516
    using \<open>x \<in> S\<close> assms(1) open_contains_cball_eq by blast
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6517
  show "\<exists>d>0. \<forall>x'. norm (x' - x) < d \<longrightarrow> \<bar>f x' - f x\<bar> < e"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6518
  proof (intro exI conjI allI impI)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6519
    fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6520
    assume as: "norm (y - x) < min (k / 2) (e / (2 * B) * k)"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6521
    show "\<bar>f y - f x\<bar> < e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6522
    proof (cases "y = x")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6523
      case False
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  6524
      define t where "t = k / norm (y - x)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6525
      have "2 < t" "0<t"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6526
        unfolding t_def using as False and \<open>k>0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6527
        by (auto simp:field_simps)
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6528
      have "y \<in> S"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6529
        apply (rule k[THEN subsetD])
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6530
        unfolding mem_cball dist_norm
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6531
        apply (rule order_trans[of _ "2 * norm (x - y)"])
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6532
        using as
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6533
        by (auto simp: field_simps norm_minus_commute)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6534
      {
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  6535
        define w where "w = x + t *\<^sub>R (y - x)"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6536
        have "w \<in> S"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6537
          using \<open>k>0\<close> by (auto simp: dist_norm t_def w_def k[THEN subsetD])
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6538
        have "(1 / t) *\<^sub>R x + - x + ((t - 1) / t) *\<^sub>R x = (1 / t - 1 + (t - 1) / t) *\<^sub>R x"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6539
          by (auto simp: algebra_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6540
        also have "\<dots> = 0"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6541
          using \<open>t > 0\<close> by (auto simp:field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6542
        finally have w: "(1 / t) *\<^sub>R w + ((t - 1) / t) *\<^sub>R x = y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6543
          unfolding w_def using False and \<open>t > 0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6544
          by (auto simp: algebra_simps)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6545
        have 2: "2 * B < e * t"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6546
          unfolding t_def using \<open>0 < e\<close> \<open>0 < k\<close> \<open>B > 0\<close> and as and False
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6547
          by (auto simp:field_simps)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6548
        have "f y - f x \<le> (f w - f x) / t"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6549
          using assms(2)[unfolded convex_on_def,rule_format,of w x "1/t" "(t - 1)/t", unfolded w]
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6550
          using \<open>0 < t\<close> \<open>2 < t\<close> and \<open>x \<in> S\<close> \<open>w \<in> S\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6551
          by (auto simp:field_simps)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6552
        also have "... < e"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6553
          using B(2)[OF \<open>w\<in>S\<close>] and B(2)[OF \<open>x\<in>S\<close>] 2 \<open>t > 0\<close> by (auto simp: field_simps)
68052
e98988801fa9 another big cleanup
paulson <lp15@cam.ac.uk>
parents: 68048
diff changeset
  6554
        finally have th1: "f y - f x < e" .
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6555
      }
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  6556
      moreover
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6557
      {
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  6558
        define w where "w = x - t *\<^sub>R (y - x)"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6559
        have "w \<in> S"
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6560
          using \<open>k > 0\<close> by (auto simp: dist_norm t_def w_def k[THEN subsetD])
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6561
        have "(1 / (1 + t)) *\<^sub>R x + (t / (1 + t)) *\<^sub>R x = (1 / (1 + t) + t / (1 + t)) *\<^sub>R x"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6562
          by (auto simp: algebra_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6563
        also have "\<dots> = x"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6564
          using \<open>t > 0\<close> by (auto simp:field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6565
        finally have w: "(1 / (1+t)) *\<^sub>R w + (t / (1 + t)) *\<^sub>R y = x"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6566
          unfolding w_def using False and \<open>t > 0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6567
          by (auto simp: algebra_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6568
        have "2 * B < e * t"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6569
          unfolding t_def
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6570
          using \<open>0 < e\<close> \<open>0 < k\<close> \<open>B > 0\<close> and as and False
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6571
          by (auto simp:field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6572
        then have *: "(f w - f y) / t < e"
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6573
          using B(2)[OF \<open>w\<in>S\<close>] and B(2)[OF \<open>y\<in>S\<close>]
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6574
          using \<open>t > 0\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6575
          by (auto simp:field_simps)
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  6576
        have "f x \<le> 1 / (1 + t) * f w + (t / (1 + t)) * f y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6577
          using assms(2)[unfolded convex_on_def,rule_format,of w y "1/(1+t)" "t / (1+t)",unfolded w]
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6578
          using \<open>0 < t\<close> \<open>2 < t\<close> and \<open>y \<in> S\<close> \<open>w \<in> S\<close>
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6579
          by (auto simp:field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6580
        also have "\<dots> = (f w + t * f y) / (1 + t)"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6581
          using \<open>t > 0\<close> by (auto simp: divide_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6582
        also have "\<dots> < e + f y"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6583
          using \<open>t > 0\<close> * \<open>e > 0\<close> by (auto simp: field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6584
        finally have "f x - f y < e" by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6585
      }
49531
8d68162b7826 tuned whitespace;
wenzelm
parents: 49530
diff changeset
  6586
      ultimately show ?thesis by auto
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6587
    qed (insert \<open>0<e\<close>, auto)
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6588
  qed (insert \<open>0<e\<close> \<open>0<k\<close> \<open>0<B\<close>, auto simp: field_simps)
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6589
qed
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6590
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6591
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  6592
subsection%unimportant \<open>Upper bound on a ball implies upper and lower bounds\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6593
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6594
lemma convex_bounds_lemma:
36338
7808fbc9c3b4 generalize more constants and lemmas
huffman
parents: 36337
diff changeset
  6595
  fixes x :: "'a::real_normed_vector"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6596
  assumes "convex_on (cball x e) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6597
    and "\<forall>y \<in> cball x e. f y \<le> b"
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61880
diff changeset
  6598
  shows "\<forall>y \<in> cball x e. \<bar>f y\<bar> \<le> b + 2 * \<bar>f x\<bar>"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6599
  apply rule
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6600
proof (cases "0 \<le> e")
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6601
  case True
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6602
  fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6603
  assume y: "y \<in> cball x e"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  6604
  define z where "z = 2 *\<^sub>R x - y"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6605
  have *: "x - (2 *\<^sub>R x - y) = y - x"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6606
    by (simp add: scaleR_2)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6607
  have z: "z \<in> cball x e"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6608
    using y unfolding z_def mem_cball dist_norm * by (auto simp: norm_minus_commute)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6609
  have "(1 / 2) *\<^sub>R y + (1 / 2) *\<^sub>R z = x"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6610
    unfolding z_def by (auto simp: algebra_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6611
  then show "\<bar>f y\<bar> \<le> b + 2 * \<bar>f x\<bar>"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6612
    using assms(1)[unfolded convex_on_def,rule_format, OF y z, of "1/2" "1/2"]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6613
    using assms(2)[rule_format,OF y] assms(2)[rule_format,OF z]
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6614
    by (auto simp:field_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6615
next
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6616
  case False
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6617
  fix y
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6618
  assume "y \<in> cball x e"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6619
  then have "dist x y < 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6620
    using False unfolding mem_cball not_le by (auto simp del: dist_not_less_zero)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6621
  then show "\<bar>f y\<bar> \<le> b + 2 * \<bar>f x\<bar>"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6622
    using zero_le_dist[of x y] by auto
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6623
qed
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6624
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6625
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  6626
subsubsection%unimportant \<open>Hence a convex function on an open set is continuous\<close>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6627
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6628
lemma real_of_nat_ge_one_iff: "1 \<le> real (n::nat) \<longleftrightarrow> 1 \<le> n"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6629
  by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6630
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6631
lemma convex_on_continuous:
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6632
  assumes "open (s::('a::euclidean_space) set)" "convex_on s f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6633
  shows "continuous_on s f"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6634
  unfolding continuous_on_eq_continuous_at[OF assms(1)]
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6635
proof
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  6636
  note dimge1 = DIM_positive[where 'a='a]
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6637
  fix x
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6638
  assume "x \<in> s"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6639
  then obtain e where e: "cball x e \<subseteq> s" "e > 0"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6640
    using assms(1) unfolding open_contains_cball by auto
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  6641
  define d where "d = e / real DIM('a)"
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6642
  have "0 < d"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6643
    unfolding d_def using \<open>e > 0\<close> dimge1 by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6644
  let ?d = "(\<Sum>i\<in>Basis. d *\<^sub>R i)::'a"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6645
  obtain c
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6646
    where c: "finite c"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6647
    and c1: "convex hull c \<subseteq> cball x e"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6648
    and c2: "cball x d \<subseteq> convex hull c"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6649
  proof
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  6650
    define c where "c = (\<Sum>i\<in>Basis. (\<lambda>a. a *\<^sub>R i) ` {x\<bullet>i - d, x\<bullet>i + d})"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6651
    show "finite c"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6652
      unfolding c_def by (simp add: finite_set_sum)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6653
    have 1: "convex hull c = {a. \<forall>i\<in>Basis. a \<bullet> i \<in> cbox (x \<bullet> i - d) (x \<bullet> i + d)}"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6654
      unfolding box_eq_set_sum_Basis
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6655
      unfolding c_def convex_hull_set_sum
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6656
      apply (subst convex_hull_linear_image [symmetric])
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6657
      apply (simp add: linear_iff scaleR_add_left)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64240
diff changeset
  6658
      apply (rule sum.cong [OF refl])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6659
      apply (rule image_cong [OF _ refl])
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56154
diff changeset
  6660
      apply (rule convex_hull_eq_real_cbox)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6661
      apply (cut_tac \<open>0 < d\<close>, simp)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6662
      done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6663
    then have 2: "convex hull c = {a. \<forall>i\<in>Basis. a \<bullet> i \<in> cball (x \<bullet> i) d}"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6664
      by (simp add: dist_norm abs_le_iff algebra_simps)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6665
    show "cball x d \<subseteq> convex hull c"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6666
      unfolding 2
68058
69715dfdc286 more general tidying up
paulson <lp15@cam.ac.uk>
parents: 68052
diff changeset
  6667
      by (clarsimp simp: dist_norm) (metis inner_commute inner_diff_right norm_bound_Basis_le)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6668
    have e': "e = (\<Sum>(i::'a)\<in>Basis. d)"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61531
diff changeset
  6669
      by (simp add: d_def DIM_positive)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6670
    show "convex hull c \<subseteq> cball x e"
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6671
      unfolding 2
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6672
      apply clarsimp
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6673
      apply (subst euclidean_dist_l2)
67155
9e5b05d54f9d canonical name
nipkow
parents: 67135
diff changeset
  6674
      apply (rule order_trans [OF L2_set_le_sum])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6675
      apply (rule zero_le_dist)
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6676
      unfolding e'
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6677
      apply (rule sum_mono, simp)
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6678
      done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6679
  qed
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 63018
diff changeset
  6680
  define k where "k = Max (f ` c)"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6681
  have "convex_on (convex hull c) f"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50104
diff changeset
  6682
    apply(rule convex_on_subset[OF assms(2)])
68069
36209dfb981e tidying up and using real induction methods
paulson <lp15@cam.ac.uk>
parents: 68058
diff changeset
  6683
    apply(rule subset_trans[OF c1 e(1)])
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6684
    done
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6685
  then have k: "\<forall>y\<in>convex hull c. f y \<le> k"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6686
    apply (rule_tac convex_on_convex_hull_bound, assumption)
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  6687
    by (simp add: k_def c)
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  6688
  have "e \<le> e * real DIM('a)"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  6689
    using e(2) real_of_nat_ge_one_iff by auto
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  6690
  then have "d \<le> e"
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  6691
    by (simp add: d_def divide_simps)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6692
  then have dsube: "cball x d \<subseteq> cball x e"
53620
3c7f5e7926dc generalized and simplified proofs of several theorems about convex sets
huffman
parents: 53600
diff changeset
  6693
    by (rule subset_cball)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6694
  have conv: "convex_on (cball x d) f"
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6695
    using \<open>convex_on (convex hull c) f\<close> c2 convex_on_subset by blast
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61880
diff changeset
  6696
  then have "\<forall>y\<in>cball x d. \<bar>f y\<bar> \<le> k + 2 * \<bar>f x\<bar>"
68048
0b4fb9fd91b1 more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68041
diff changeset
  6697
    by (rule convex_bounds_lemma) (use c2 k in blast)
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6698
  then have "continuous_on (ball x d) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6699
    apply (rule_tac convex_on_bounded_continuous)
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6700
    apply (rule open_ball, rule convex_on_subset[OF conv])
68031
eda52f4cd4e4 fixing more messy proofs
paulson <lp15@cam.ac.uk>
parents: 68024
diff changeset
  6701
    apply (rule ball_subset_cball, force)
33270
paulson
parents: 33175
diff changeset
  6702
    done
53348
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6703
  then show "continuous (at x) f"
0b467fc4e597 tuned proofs;
wenzelm
parents: 53347
diff changeset
  6704
    unfolding continuous_on_eq_continuous_at[OF open_ball]
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6705
    using \<open>d > 0\<close> by auto
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6706
qed
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  6707
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  6708
end