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