src/HOL/Hahn_Banach/Subspace.thy
author wenzelm
Sat Nov 04 15:24:40 2017 +0100 (20 months ago)
changeset 67003 49850a679c2c
parent 66453 cc19f7ca2ed6
permissions -rw-r--r--
more robust sorted_entries;
wenzelm@31795
     1
(*  Title:      HOL/Hahn_Banach/Subspace.thy
wenzelm@7566
     2
    Author:     Gertrud Bauer, TU Munich
wenzelm@7566
     3
*)
wenzelm@7535
     4
wenzelm@58889
     5
section \<open>Subspaces\<close>
wenzelm@7808
     6
wenzelm@27612
     7
theory Subspace
wenzelm@66453
     8
imports Vector_Space "HOL-Library.Set_Algebras"
wenzelm@27612
     9
begin
wenzelm@7535
    10
wenzelm@58744
    11
subsection \<open>Definition\<close>
wenzelm@7535
    12
wenzelm@58744
    13
text \<open>
wenzelm@61540
    14
  A non-empty subset \<open>U\<close> of a vector space \<open>V\<close> is a \<^emph>\<open>subspace\<close> of \<open>V\<close>, iff
wenzelm@61540
    15
  \<open>U\<close> is closed under addition and scalar multiplication.
wenzelm@58744
    16
\<close>
wenzelm@7917
    17
ballarin@29234
    18
locale subspace =
wenzelm@61076
    19
  fixes U :: "'a::{minus, plus, zero, uminus} set" and V
wenzelm@13515
    20
  assumes non_empty [iff, intro]: "U \<noteq> {}"
wenzelm@13515
    21
    and subset [iff]: "U \<subseteq> V"
wenzelm@13515
    22
    and add_closed [iff]: "x \<in> U \<Longrightarrow> y \<in> U \<Longrightarrow> x + y \<in> U"
wenzelm@13515
    23
    and mult_closed [iff]: "x \<in> U \<Longrightarrow> a \<cdot> x \<in> U"
wenzelm@7535
    24
wenzelm@21210
    25
notation (symbols)
wenzelm@19736
    26
  subspace  (infix "\<unlhd>" 50)
ballarin@14254
    27
wenzelm@19736
    28
declare vectorspace.intro [intro?] subspace.intro [intro?]
wenzelm@7535
    29
wenzelm@13515
    30
lemma subspace_subset [elim]: "U \<unlhd> V \<Longrightarrow> U \<subseteq> V"
wenzelm@13515
    31
  by (rule subspace.subset)
wenzelm@7566
    32
wenzelm@13515
    33
lemma (in subspace) subsetD [iff]: "x \<in> U \<Longrightarrow> x \<in> V"
wenzelm@13515
    34
  using subset by blast
wenzelm@7566
    35
wenzelm@13515
    36
lemma subspaceD [elim]: "U \<unlhd> V \<Longrightarrow> x \<in> U \<Longrightarrow> x \<in> V"
wenzelm@13515
    37
  by (rule subspace.subsetD)
wenzelm@7535
    38
wenzelm@13515
    39
lemma rev_subspaceD [elim?]: "x \<in> U \<Longrightarrow> U \<unlhd> V \<Longrightarrow> x \<in> V"
wenzelm@13515
    40
  by (rule subspace.subsetD)
wenzelm@13515
    41
wenzelm@13547
    42
lemma (in subspace) diff_closed [iff]:
ballarin@27611
    43
  assumes "vectorspace V"
wenzelm@27612
    44
  assumes x: "x \<in> U" and y: "y \<in> U"
wenzelm@27612
    45
  shows "x - y \<in> U"
ballarin@27611
    46
proof -
ballarin@29234
    47
  interpret vectorspace V by fact
wenzelm@27612
    48
  from x y show ?thesis by (simp add: diff_eq1 negate_eq1)
ballarin@27611
    49
qed
wenzelm@7917
    50
wenzelm@58744
    51
text \<open>
wenzelm@61486
    52
  \<^medskip>
wenzelm@61540
    53
  Similar as for linear spaces, the existence of the zero element in every
wenzelm@61540
    54
  subspace follows from the non-emptiness of the carrier set and by vector
wenzelm@61540
    55
  space laws.
wenzelm@58744
    56
\<close>
wenzelm@13515
    57
wenzelm@13547
    58
lemma (in subspace) zero [intro]:
ballarin@27611
    59
  assumes "vectorspace V"
wenzelm@13547
    60
  shows "0 \<in> U"
wenzelm@10687
    61
proof -
wenzelm@30729
    62
  interpret V: vectorspace V by fact
ballarin@29234
    63
  have "U \<noteq> {}" by (rule non_empty)
wenzelm@13515
    64
  then obtain x where x: "x \<in> U" by blast
wenzelm@27612
    65
  then have "x \<in> V" .. then have "0 = x - x" by simp
wenzelm@58744
    66
  also from \<open>vectorspace V\<close> x x have "\<dots> \<in> U" by (rule diff_closed)
wenzelm@13515
    67
  finally show ?thesis .
wenzelm@9035
    68
qed
wenzelm@7535
    69
wenzelm@13547
    70
lemma (in subspace) neg_closed [iff]:
ballarin@27611
    71
  assumes "vectorspace V"
wenzelm@27612
    72
  assumes x: "x \<in> U"
wenzelm@27612
    73
  shows "- x \<in> U"
ballarin@27611
    74
proof -
ballarin@29234
    75
  interpret vectorspace V by fact
wenzelm@27612
    76
  from x show ?thesis by (simp add: negate_eq1)
ballarin@27611
    77
qed
wenzelm@13515
    78
wenzelm@61486
    79
text \<open>\<^medskip> Further derived laws: every subspace is a vector space.\<close>
wenzelm@7535
    80
wenzelm@13547
    81
lemma (in subspace) vectorspace [iff]:
ballarin@27611
    82
  assumes "vectorspace V"
wenzelm@13547
    83
  shows "vectorspace U"
ballarin@27611
    84
proof -
ballarin@29234
    85
  interpret vectorspace V by fact
wenzelm@27612
    86
  show ?thesis
wenzelm@27612
    87
  proof
ballarin@27611
    88
    show "U \<noteq> {}" ..
ballarin@27611
    89
    fix x y z assume x: "x \<in> U" and y: "y \<in> U" and z: "z \<in> U"
ballarin@27611
    90
    fix a b :: real
ballarin@27611
    91
    from x y show "x + y \<in> U" by simp
ballarin@27611
    92
    from x show "a \<cdot> x \<in> U" by simp
ballarin@27611
    93
    from x y z show "(x + y) + z = x + (y + z)" by (simp add: add_ac)
ballarin@27611
    94
    from x y show "x + y = y + x" by (simp add: add_ac)
ballarin@27611
    95
    from x show "x - x = 0" by simp
ballarin@27611
    96
    from x show "0 + x = x" by simp
ballarin@27611
    97
    from x y show "a \<cdot> (x + y) = a \<cdot> x + a \<cdot> y" by (simp add: distrib)
ballarin@27611
    98
    from x show "(a + b) \<cdot> x = a \<cdot> x + b \<cdot> x" by (simp add: distrib)
ballarin@27611
    99
    from x show "(a * b) \<cdot> x = a \<cdot> b \<cdot> x" by (simp add: mult_assoc)
ballarin@27611
   100
    from x show "1 \<cdot> x = x" by simp
ballarin@27611
   101
    from x show "- x = - 1 \<cdot> x" by (simp add: negate_eq1)
ballarin@27611
   102
    from x y show "x - y = x + - y" by (simp add: diff_eq1)
ballarin@27611
   103
  qed
wenzelm@9035
   104
qed
wenzelm@7535
   105
wenzelm@13515
   106
wenzelm@58744
   107
text \<open>The subspace relation is reflexive.\<close>
wenzelm@7917
   108
wenzelm@13515
   109
lemma (in vectorspace) subspace_refl [intro]: "V \<unlhd> V"
wenzelm@10687
   110
proof
wenzelm@13515
   111
  show "V \<noteq> {}" ..
wenzelm@10687
   112
  show "V \<subseteq> V" ..
wenzelm@44887
   113
next
wenzelm@13515
   114
  fix x y assume x: "x \<in> V" and y: "y \<in> V"
wenzelm@13515
   115
  fix a :: real
wenzelm@13515
   116
  from x y show "x + y \<in> V" by simp
wenzelm@13515
   117
  from x show "a \<cdot> x \<in> V" by simp
wenzelm@9035
   118
qed
wenzelm@7535
   119
wenzelm@58744
   120
text \<open>The subspace relation is transitive.\<close>
wenzelm@7917
   121
wenzelm@13515
   122
lemma (in vectorspace) subspace_trans [trans]:
wenzelm@13515
   123
  "U \<unlhd> V \<Longrightarrow> V \<unlhd> W \<Longrightarrow> U \<unlhd> W"
wenzelm@10687
   124
proof
wenzelm@13515
   125
  assume uv: "U \<unlhd> V" and vw: "V \<unlhd> W"
wenzelm@13515
   126
  from uv show "U \<noteq> {}" by (rule subspace.non_empty)
wenzelm@13515
   127
  show "U \<subseteq> W"
wenzelm@13515
   128
  proof -
wenzelm@13515
   129
    from uv have "U \<subseteq> V" by (rule subspace.subset)
wenzelm@13515
   130
    also from vw have "V \<subseteq> W" by (rule subspace.subset)
wenzelm@13515
   131
    finally show ?thesis .
wenzelm@9035
   132
  qed
wenzelm@13515
   133
  fix x y assume x: "x \<in> U" and y: "y \<in> U"
wenzelm@13515
   134
  from uv and x y show "x + y \<in> U" by (rule subspace.add_closed)
wenzelm@60412
   135
  from uv and x show "a \<cdot> x \<in> U" for a by (rule subspace.mult_closed)
wenzelm@9035
   136
qed
wenzelm@7535
   137
wenzelm@7535
   138
wenzelm@58744
   139
subsection \<open>Linear closure\<close>
wenzelm@7808
   140
wenzelm@58744
   141
text \<open>
wenzelm@61879
   142
  The \<^emph>\<open>linear closure\<close> of a vector \<open>x\<close> is the set of all scalar multiples of
wenzelm@61879
   143
  \<open>x\<close>.
wenzelm@58744
   144
\<close>
wenzelm@7535
   145
wenzelm@58745
   146
definition lin :: "('a::{minus,plus,zero}) \<Rightarrow> 'a set"
wenzelm@44887
   147
  where "lin x = {a \<cdot> x | a. True}"
wenzelm@7535
   148
wenzelm@13515
   149
lemma linI [intro]: "y = a \<cdot> x \<Longrightarrow> y \<in> lin x"
wenzelm@27612
   150
  unfolding lin_def by blast
wenzelm@7535
   151
wenzelm@13515
   152
lemma linI' [iff]: "a \<cdot> x \<in> lin x"
wenzelm@27612
   153
  unfolding lin_def by blast
wenzelm@13515
   154
wenzelm@60412
   155
lemma linE [elim]:
wenzelm@60412
   156
  assumes "x \<in> lin v"
wenzelm@60412
   157
  obtains a :: real where "x = a \<cdot> v"
wenzelm@60412
   158
  using assms unfolding lin_def by blast
wenzelm@13515
   159
wenzelm@7656
   160
wenzelm@58744
   161
text \<open>Every vector is contained in its linear closure.\<close>
wenzelm@7917
   162
wenzelm@13515
   163
lemma (in vectorspace) x_lin_x [iff]: "x \<in> V \<Longrightarrow> x \<in> lin x"
wenzelm@13515
   164
proof -
wenzelm@13515
   165
  assume "x \<in> V"
wenzelm@27612
   166
  then have "x = 1 \<cdot> x" by simp
wenzelm@13515
   167
  also have "\<dots> \<in> lin x" ..
wenzelm@13515
   168
  finally show ?thesis .
wenzelm@13515
   169
qed
wenzelm@13515
   170
wenzelm@13515
   171
lemma (in vectorspace) "0_lin_x" [iff]: "x \<in> V \<Longrightarrow> 0 \<in> lin x"
wenzelm@13515
   172
proof
wenzelm@13515
   173
  assume "x \<in> V"
wenzelm@27612
   174
  then show "0 = 0 \<cdot> x" by simp
wenzelm@13515
   175
qed
wenzelm@7535
   176
wenzelm@58744
   177
text \<open>Any linear closure is a subspace.\<close>
wenzelm@7917
   178
wenzelm@13515
   179
lemma (in vectorspace) lin_subspace [intro]:
wenzelm@44887
   180
  assumes x: "x \<in> V"
wenzelm@44887
   181
  shows "lin x \<unlhd> V"
wenzelm@9035
   182
proof
wenzelm@44887
   183
  from x show "lin x \<noteq> {}" by auto
wenzelm@44887
   184
next
wenzelm@10687
   185
  show "lin x \<subseteq> V"
wenzelm@13515
   186
  proof
wenzelm@13515
   187
    fix x' assume "x' \<in> lin x"
wenzelm@13515
   188
    then obtain a where "x' = a \<cdot> x" ..
wenzelm@13515
   189
    with x show "x' \<in> V" by simp
wenzelm@9035
   190
  qed
wenzelm@44887
   191
next
wenzelm@13515
   192
  fix x' x'' assume x': "x' \<in> lin x" and x'': "x'' \<in> lin x"
wenzelm@13515
   193
  show "x' + x'' \<in> lin x"
wenzelm@13515
   194
  proof -
wenzelm@13515
   195
    from x' obtain a' where "x' = a' \<cdot> x" ..
wenzelm@13515
   196
    moreover from x'' obtain a'' where "x'' = a'' \<cdot> x" ..
wenzelm@13515
   197
    ultimately have "x' + x'' = (a' + a'') \<cdot> x"
wenzelm@13515
   198
      using x by (simp add: distrib)
wenzelm@13515
   199
    also have "\<dots> \<in> lin x" ..
wenzelm@13515
   200
    finally show ?thesis .
wenzelm@9035
   201
  qed
wenzelm@13515
   202
  fix a :: real
wenzelm@13515
   203
  show "a \<cdot> x' \<in> lin x"
wenzelm@13515
   204
  proof -
wenzelm@13515
   205
    from x' obtain a' where "x' = a' \<cdot> x" ..
wenzelm@13515
   206
    with x have "a \<cdot> x' = (a * a') \<cdot> x" by (simp add: mult_assoc)
wenzelm@13515
   207
    also have "\<dots> \<in> lin x" ..
wenzelm@13515
   208
    finally show ?thesis .
wenzelm@10687
   209
  qed
wenzelm@9035
   210
qed
wenzelm@7535
   211
wenzelm@13515
   212
wenzelm@58744
   213
text \<open>Any linear closure is a vector space.\<close>
wenzelm@7917
   214
wenzelm@13515
   215
lemma (in vectorspace) lin_vectorspace [intro]:
wenzelm@23378
   216
  assumes "x \<in> V"
wenzelm@23378
   217
  shows "vectorspace (lin x)"
wenzelm@23378
   218
proof -
wenzelm@58744
   219
  from \<open>x \<in> V\<close> have "subspace (lin x) V"
wenzelm@23378
   220
    by (rule lin_subspace)
wenzelm@26199
   221
  from this and vectorspace_axioms show ?thesis
wenzelm@23378
   222
    by (rule subspace.vectorspace)
wenzelm@23378
   223
qed
wenzelm@7808
   224
wenzelm@7808
   225
wenzelm@58744
   226
subsection \<open>Sum of two vectorspaces\<close>
wenzelm@7808
   227
wenzelm@58744
   228
text \<open>
wenzelm@61540
   229
  The \<^emph>\<open>sum\<close> of two vectorspaces \<open>U\<close> and \<open>V\<close> is the set of all sums of
wenzelm@61540
   230
  elements from \<open>U\<close> and \<open>V\<close>.
wenzelm@58744
   231
\<close>
wenzelm@7535
   232
krauss@47445
   233
lemma sum_def: "U + V = {u + v | u v. u \<in> U \<and> v \<in> V}"
huffman@44190
   234
  unfolding set_plus_def by auto
wenzelm@7917
   235
wenzelm@13515
   236
lemma sumE [elim]:
krauss@47445
   237
    "x \<in> U + V \<Longrightarrow> (\<And>u v. x = u + v \<Longrightarrow> u \<in> U \<Longrightarrow> v \<in> V \<Longrightarrow> C) \<Longrightarrow> C"
wenzelm@27612
   238
  unfolding sum_def by blast
wenzelm@7535
   239
wenzelm@13515
   240
lemma sumI [intro]:
krauss@47445
   241
    "u \<in> U \<Longrightarrow> v \<in> V \<Longrightarrow> x = u + v \<Longrightarrow> x \<in> U + V"
wenzelm@27612
   242
  unfolding sum_def by blast
wenzelm@7566
   243
wenzelm@13515
   244
lemma sumI' [intro]:
krauss@47445
   245
    "u \<in> U \<Longrightarrow> v \<in> V \<Longrightarrow> u + v \<in> U + V"
wenzelm@27612
   246
  unfolding sum_def by blast
wenzelm@7917
   247
wenzelm@61539
   248
text \<open>\<open>U\<close> is a subspace of \<open>U + V\<close>.\<close>
wenzelm@7535
   249
wenzelm@13515
   250
lemma subspace_sum1 [iff]:
ballarin@27611
   251
  assumes "vectorspace U" "vectorspace V"
krauss@47445
   252
  shows "U \<unlhd> U + V"
ballarin@27611
   253
proof -
ballarin@29234
   254
  interpret vectorspace U by fact
ballarin@29234
   255
  interpret vectorspace V by fact
wenzelm@27612
   256
  show ?thesis
wenzelm@27612
   257
  proof
ballarin@27611
   258
    show "U \<noteq> {}" ..
krauss@47445
   259
    show "U \<subseteq> U + V"
ballarin@27611
   260
    proof
ballarin@27611
   261
      fix x assume x: "x \<in> U"
ballarin@27611
   262
      moreover have "0 \<in> V" ..
krauss@47445
   263
      ultimately have "x + 0 \<in> U + V" ..
krauss@47445
   264
      with x show "x \<in> U + V" by simp
ballarin@27611
   265
    qed
ballarin@27611
   266
    fix x y assume x: "x \<in> U" and "y \<in> U"
wenzelm@27612
   267
    then show "x + y \<in> U" by simp
wenzelm@60412
   268
    from x show "a \<cdot> x \<in> U" for a by simp
wenzelm@9035
   269
  qed
wenzelm@9035
   270
qed
wenzelm@7535
   271
wenzelm@58744
   272
text \<open>The sum of two subspaces is again a subspace.\<close>
wenzelm@7917
   273
wenzelm@13515
   274
lemma sum_subspace [intro?]:
ballarin@27611
   275
  assumes "subspace U E" "vectorspace E" "subspace V E"
krauss@47445
   276
  shows "U + V \<unlhd> E"
ballarin@27611
   277
proof -
ballarin@29234
   278
  interpret subspace U E by fact
ballarin@29234
   279
  interpret vectorspace E by fact
ballarin@29234
   280
  interpret subspace V E by fact
wenzelm@27612
   281
  show ?thesis
wenzelm@27612
   282
  proof
krauss@47445
   283
    have "0 \<in> U + V"
ballarin@27611
   284
    proof
wenzelm@58744
   285
      show "0 \<in> U" using \<open>vectorspace E\<close> ..
wenzelm@58744
   286
      show "0 \<in> V" using \<open>vectorspace E\<close> ..
ballarin@27611
   287
      show "(0::'a) = 0 + 0" by simp
ballarin@27611
   288
    qed
krauss@47445
   289
    then show "U + V \<noteq> {}" by blast
krauss@47445
   290
    show "U + V \<subseteq> E"
ballarin@27611
   291
    proof
krauss@47445
   292
      fix x assume "x \<in> U + V"
ballarin@27611
   293
      then obtain u v where "x = u + v" and
wenzelm@32960
   294
        "u \<in> U" and "v \<in> V" ..
ballarin@27611
   295
      then show "x \<in> E" by simp
ballarin@27611
   296
    qed
wenzelm@44887
   297
  next
krauss@47445
   298
    fix x y assume x: "x \<in> U + V" and y: "y \<in> U + V"
krauss@47445
   299
    show "x + y \<in> U + V"
ballarin@27611
   300
    proof -
ballarin@27611
   301
      from x obtain ux vx where "x = ux + vx" and "ux \<in> U" and "vx \<in> V" ..
ballarin@27611
   302
      moreover
ballarin@27611
   303
      from y obtain uy vy where "y = uy + vy" and "uy \<in> U" and "vy \<in> V" ..
ballarin@27611
   304
      ultimately
ballarin@27611
   305
      have "ux + uy \<in> U"
wenzelm@32960
   306
        and "vx + vy \<in> V"
wenzelm@32960
   307
        and "x + y = (ux + uy) + (vx + vy)"
wenzelm@32960
   308
        using x y by (simp_all add: add_ac)
wenzelm@27612
   309
      then show ?thesis ..
ballarin@27611
   310
    qed
krauss@47445
   311
    fix a show "a \<cdot> x \<in> U + V"
ballarin@27611
   312
    proof -
ballarin@27611
   313
      from x obtain u v where "x = u + v" and "u \<in> U" and "v \<in> V" ..
wenzelm@27612
   314
      then have "a \<cdot> u \<in> U" and "a \<cdot> v \<in> V"
wenzelm@32960
   315
        and "a \<cdot> x = (a \<cdot> u) + (a \<cdot> v)" by (simp_all add: distrib)
wenzelm@27612
   316
      then show ?thesis ..
ballarin@27611
   317
    qed
wenzelm@9035
   318
  qed
wenzelm@9035
   319
qed
wenzelm@7535
   320
wenzelm@61879
   321
text \<open>The sum of two subspaces is a vectorspace.\<close>
wenzelm@7917
   322
wenzelm@13515
   323
lemma sum_vs [intro?]:
krauss@47445
   324
    "U \<unlhd> E \<Longrightarrow> V \<unlhd> E \<Longrightarrow> vectorspace E \<Longrightarrow> vectorspace (U + V)"
wenzelm@13547
   325
  by (rule subspace.vectorspace) (rule sum_subspace)
wenzelm@7535
   326
wenzelm@7808
   327
wenzelm@58744
   328
subsection \<open>Direct sums\<close>
wenzelm@7808
   329
wenzelm@58744
   330
text \<open>
wenzelm@61879
   331
  The sum of \<open>U\<close> and \<open>V\<close> is called \<^emph>\<open>direct\<close>, iff the zero element is the only
wenzelm@61879
   332
  common element of \<open>U\<close> and \<open>V\<close>. For every element \<open>x\<close> of the direct sum of
wenzelm@61879
   333
  \<open>U\<close> and \<open>V\<close> the decomposition in \<open>x = u + v\<close> with \<open>u \<in> U\<close> and \<open>v \<in> V\<close> is
wenzelm@61879
   334
  unique.
wenzelm@58744
   335
\<close>
wenzelm@7808
   336
wenzelm@10687
   337
lemma decomp:
ballarin@27611
   338
  assumes "vectorspace E" "subspace U E" "subspace V E"
wenzelm@13515
   339
  assumes direct: "U \<inter> V = {0}"
wenzelm@13515
   340
    and u1: "u1 \<in> U" and u2: "u2 \<in> U"
wenzelm@13515
   341
    and v1: "v1 \<in> V" and v2: "v2 \<in> V"
wenzelm@13515
   342
    and sum: "u1 + v1 = u2 + v2"
wenzelm@13515
   343
  shows "u1 = u2 \<and> v1 = v2"
ballarin@27611
   344
proof -
ballarin@29234
   345
  interpret vectorspace E by fact
ballarin@29234
   346
  interpret subspace U E by fact
ballarin@29234
   347
  interpret subspace V E by fact
wenzelm@27612
   348
  show ?thesis
wenzelm@27612
   349
  proof
ballarin@27611
   350
    have U: "vectorspace U"  (* FIXME: use interpret *)
wenzelm@58744
   351
      using \<open>subspace U E\<close> \<open>vectorspace E\<close> by (rule subspace.vectorspace)
ballarin@27611
   352
    have V: "vectorspace V"
wenzelm@58744
   353
      using \<open>subspace V E\<close> \<open>vectorspace E\<close> by (rule subspace.vectorspace)
ballarin@27611
   354
    from u1 u2 v1 v2 and sum have eq: "u1 - u2 = v2 - v1"
ballarin@27611
   355
      by (simp add: add_diff_swap)
ballarin@27611
   356
    from u1 u2 have u: "u1 - u2 \<in> U"
ballarin@27611
   357
      by (rule vectorspace.diff_closed [OF U])
ballarin@27611
   358
    with eq have v': "v2 - v1 \<in> U" by (simp only:)
ballarin@27611
   359
    from v2 v1 have v: "v2 - v1 \<in> V"
ballarin@27611
   360
      by (rule vectorspace.diff_closed [OF V])
ballarin@27611
   361
    with eq have u': " u1 - u2 \<in> V" by (simp only:)
ballarin@27611
   362
    
ballarin@27611
   363
    show "u1 = u2"
ballarin@27611
   364
    proof (rule add_minus_eq)
ballarin@27611
   365
      from u1 show "u1 \<in> E" ..
ballarin@27611
   366
      from u2 show "u2 \<in> E" ..
ballarin@27611
   367
      from u u' and direct show "u1 - u2 = 0" by blast
ballarin@27611
   368
    qed
ballarin@27611
   369
    show "v1 = v2"
ballarin@27611
   370
    proof (rule add_minus_eq [symmetric])
ballarin@27611
   371
      from v1 show "v1 \<in> E" ..
ballarin@27611
   372
      from v2 show "v2 \<in> E" ..
ballarin@27611
   373
      from v v' and direct show "v2 - v1 = 0" by blast
ballarin@27611
   374
    qed
wenzelm@9035
   375
  qed
wenzelm@9035
   376
qed
wenzelm@7656
   377
wenzelm@58744
   378
text \<open>
wenzelm@61540
   379
  An application of the previous lemma will be used in the proof of the
wenzelm@61540
   380
  Hahn-Banach Theorem (see page \pageref{decomp-H-use}): for any element
wenzelm@61540
   381
  \<open>y + a \<cdot> x\<^sub>0\<close> of the direct sum of a vectorspace \<open>H\<close> and the linear closure
wenzelm@61540
   382
  of \<open>x\<^sub>0\<close> the components \<open>y \<in> H\<close> and \<open>a\<close> are uniquely determined.
wenzelm@58744
   383
\<close>
wenzelm@7917
   384
wenzelm@10687
   385
lemma decomp_H':
ballarin@27611
   386
  assumes "vectorspace E" "subspace H E"
wenzelm@13515
   387
  assumes y1: "y1 \<in> H" and y2: "y2 \<in> H"
wenzelm@13515
   388
    and x': "x' \<notin> H"  "x' \<in> E"  "x' \<noteq> 0"
wenzelm@13515
   389
    and eq: "y1 + a1 \<cdot> x' = y2 + a2 \<cdot> x'"
wenzelm@13515
   390
  shows "y1 = y2 \<and> a1 = a2"
ballarin@27611
   391
proof -
ballarin@29234
   392
  interpret vectorspace E by fact
ballarin@29234
   393
  interpret subspace H E by fact
wenzelm@27612
   394
  show ?thesis
wenzelm@27612
   395
  proof
ballarin@27611
   396
    have c: "y1 = y2 \<and> a1 \<cdot> x' = a2 \<cdot> x'"
ballarin@27611
   397
    proof (rule decomp)
ballarin@27611
   398
      show "a1 \<cdot> x' \<in> lin x'" ..
ballarin@27611
   399
      show "a2 \<cdot> x' \<in> lin x'" ..
ballarin@27611
   400
      show "H \<inter> lin x' = {0}"
wenzelm@13515
   401
      proof
wenzelm@32960
   402
        show "H \<inter> lin x' \<subseteq> {0}"
wenzelm@32960
   403
        proof
ballarin@27611
   404
          fix x assume x: "x \<in> H \<inter> lin x'"
ballarin@27611
   405
          then obtain a where xx': "x = a \<cdot> x'"
ballarin@27611
   406
            by blast
ballarin@27611
   407
          have "x = 0"
ballarin@27611
   408
          proof cases
ballarin@27611
   409
            assume "a = 0"
ballarin@27611
   410
            with xx' and x' show ?thesis by simp
ballarin@27611
   411
          next
ballarin@27611
   412
            assume a: "a \<noteq> 0"
ballarin@27611
   413
            from x have "x \<in> H" ..
ballarin@27611
   414
            with xx' have "inverse a \<cdot> a \<cdot> x' \<in> H" by simp
ballarin@27611
   415
            with a and x' have "x' \<in> H" by (simp add: mult_assoc2)
wenzelm@58744
   416
            with \<open>x' \<notin> H\<close> show ?thesis by contradiction
ballarin@27611
   417
          qed
wenzelm@27612
   418
          then show "x \<in> {0}" ..
wenzelm@32960
   419
        qed
wenzelm@32960
   420
        show "{0} \<subseteq> H \<inter> lin x'"
wenzelm@32960
   421
        proof -
wenzelm@58744
   422
          have "0 \<in> H" using \<open>vectorspace E\<close> ..
wenzelm@58744
   423
          moreover have "0 \<in> lin x'" using \<open>x' \<in> E\<close> ..
ballarin@27611
   424
          ultimately show ?thesis by blast
wenzelm@32960
   425
        qed
wenzelm@9035
   426
      qed
wenzelm@58744
   427
      show "lin x' \<unlhd> E" using \<open>x' \<in> E\<close> ..
wenzelm@58744
   428
    qed (rule \<open>vectorspace E\<close>, rule \<open>subspace H E\<close>, rule y1, rule y2, rule eq)
wenzelm@27612
   429
    then show "y1 = y2" ..
ballarin@27611
   430
    from c have "a1 \<cdot> x' = a2 \<cdot> x'" ..
ballarin@27611
   431
    with x' show "a1 = a2" by (simp add: mult_right_cancel)
ballarin@27611
   432
  qed
wenzelm@9035
   433
qed
wenzelm@7535
   434
wenzelm@58744
   435
text \<open>
wenzelm@61540
   436
  Since for any element \<open>y + a \<cdot> x'\<close> of the direct sum of a vectorspace \<open>H\<close>
wenzelm@61879
   437
  and the linear closure of \<open>x'\<close> the components \<open>y \<in> H\<close> and \<open>a\<close> are unique, it
wenzelm@61879
   438
  follows from \<open>y \<in> H\<close> that \<open>a = 0\<close>.
wenzelm@58744
   439
\<close>
wenzelm@7917
   440
wenzelm@10687
   441
lemma decomp_H'_H:
ballarin@27611
   442
  assumes "vectorspace E" "subspace H E"
wenzelm@13515
   443
  assumes t: "t \<in> H"
wenzelm@13515
   444
    and x': "x' \<notin> H"  "x' \<in> E"  "x' \<noteq> 0"
wenzelm@13515
   445
  shows "(SOME (y, a). t = y + a \<cdot> x' \<and> y \<in> H) = (t, 0)"
ballarin@27611
   446
proof -
ballarin@29234
   447
  interpret vectorspace E by fact
ballarin@29234
   448
  interpret subspace H E by fact
wenzelm@27612
   449
  show ?thesis
wenzelm@27612
   450
  proof (rule, simp_all only: split_paired_all split_conv)
ballarin@27611
   451
    from t x' show "t = t + 0 \<cdot> x' \<and> t \<in> H" by simp
ballarin@27611
   452
    fix y and a assume ya: "t = y + a \<cdot> x' \<and> y \<in> H"
ballarin@27611
   453
    have "y = t \<and> a = 0"
ballarin@27611
   454
    proof (rule decomp_H')
ballarin@27611
   455
      from ya x' show "y + a \<cdot> x' = t + 0 \<cdot> x'" by simp
ballarin@27611
   456
      from ya show "y \<in> H" ..
wenzelm@58744
   457
    qed (rule \<open>vectorspace E\<close>, rule \<open>subspace H E\<close>, rule t, (rule x')+)
ballarin@27611
   458
    with t x' show "(y, a) = (y + a \<cdot> x', 0)" by simp
ballarin@27611
   459
  qed
wenzelm@13515
   460
qed
wenzelm@7535
   461
wenzelm@58744
   462
text \<open>
wenzelm@61540
   463
  The components \<open>y \<in> H\<close> and \<open>a\<close> in \<open>y + a \<cdot> x'\<close> are unique, so the function
wenzelm@61540
   464
  \<open>h'\<close> defined by \<open>h' (y + a \<cdot> x') = h y + a \<cdot> \<xi>\<close> is definite.
wenzelm@58744
   465
\<close>
wenzelm@7917
   466
bauerg@9374
   467
lemma h'_definite:
ballarin@27611
   468
  fixes H
wenzelm@13515
   469
  assumes h'_def:
wenzelm@63040
   470
    "\<And>x. h' x =
wenzelm@63040
   471
      (let (y, a) = SOME (y, a). (x = y + a \<cdot> x' \<and> y \<in> H)
wenzelm@63040
   472
       in (h y) + a * xi)"
wenzelm@13515
   473
    and x: "x = y + a \<cdot> x'"
ballarin@27611
   474
  assumes "vectorspace E" "subspace H E"
wenzelm@13515
   475
  assumes y: "y \<in> H"
wenzelm@13515
   476
    and x': "x' \<notin> H"  "x' \<in> E"  "x' \<noteq> 0"
wenzelm@13515
   477
  shows "h' x = h y + a * xi"
wenzelm@10687
   478
proof -
ballarin@29234
   479
  interpret vectorspace E by fact
ballarin@29234
   480
  interpret subspace H E by fact
krauss@47445
   481
  from x y x' have "x \<in> H + lin x'" by auto
wenzelm@63910
   482
  have "\<exists>!(y, a). x = y + a \<cdot> x' \<and> y \<in> H" (is "\<exists>!p. ?P p")
wenzelm@18689
   483
  proof (rule ex_ex1I)
wenzelm@13515
   484
    from x y show "\<exists>p. ?P p" by blast
wenzelm@13515
   485
    fix p q assume p: "?P p" and q: "?P q"
wenzelm@13515
   486
    show "p = q"
wenzelm@9035
   487
    proof -
wenzelm@13515
   488
      from p have xp: "x = fst p + snd p \<cdot> x' \<and> fst p \<in> H"
wenzelm@13515
   489
        by (cases p) simp
wenzelm@13515
   490
      from q have xq: "x = fst q + snd q \<cdot> x' \<and> fst q \<in> H"
wenzelm@13515
   491
        by (cases q) simp
wenzelm@13515
   492
      have "fst p = fst q \<and> snd p = snd q"
wenzelm@13515
   493
      proof (rule decomp_H')
wenzelm@13515
   494
        from xp show "fst p \<in> H" ..
wenzelm@13515
   495
        from xq show "fst q \<in> H" ..
wenzelm@13515
   496
        from xp and xq show "fst p + snd p \<cdot> x' = fst q + snd q \<cdot> x'"
wenzelm@13515
   497
          by simp
wenzelm@58744
   498
      qed (rule \<open>vectorspace E\<close>, rule \<open>subspace H E\<close>, (rule x')+)
wenzelm@27612
   499
      then show ?thesis by (cases p, cases q) simp
wenzelm@9035
   500
    qed
wenzelm@9035
   501
  qed
wenzelm@27612
   502
  then have eq: "(SOME (y, a). x = y + a \<cdot> x' \<and> y \<in> H) = (y, a)"
wenzelm@13515
   503
    by (rule some1_equality) (simp add: x y)
wenzelm@13515
   504
  with h'_def show "h' x = h y + a * xi" by (simp add: Let_def)
wenzelm@9035
   505
qed
wenzelm@7535
   506
wenzelm@10687
   507
end