src/HOL/Multivariate_Analysis/Linear_Algebra.thy
author wenzelm
Fri, 21 Sep 2012 22:45:14 +0200
changeset 49522 355f3d076924
parent 44890 22f665a2e91c
child 49525 e87b42a26991
permissions -rw-r--r--
tuned proofs;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     1
(*  Title:      HOL/Multivariate_Analysis/Linear_Algebra.thy
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     2
    Author:     Amine Chaieb, University of Cambridge
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     3
*)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     4
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     5
header {* Elementary linear algebra on Euclidean spaces *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     6
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     7
theory Linear_Algebra
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     8
imports
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     9
  Euclidean_Space
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    10
  "~~/src/HOL/Library/Infinite_Set"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    11
begin
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    12
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    13
lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    14
  by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    15
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    16
notation inner (infix "\<bullet>" 70)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    17
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    18
lemma square_bound_lemma: "(x::real) < (1 + x) * (1 + x)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    19
proof -
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    20
  have "(x + 1/2)^2 + 3/4 > 0" using zero_le_power2[of "x+1/2"] by arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    21
  thus ?thesis by (simp add: field_simps power2_eq_square)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    22
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    23
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    24
lemma square_continuous: "0 < (e::real) ==> \<exists>d. 0 < d \<and> (\<forall>y. abs(y - x) < d \<longrightarrow> abs(y * y - x * x) < e)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    25
  using isCont_power[OF isCont_ident, of 2, unfolded isCont_def LIM_eq, rule_format, of e x]
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    26
  apply (auto simp add: power2_eq_square)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    27
  apply (rule_tac x="s" in exI)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    28
  apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    29
  apply (erule_tac x=y in allE)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    30
  apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    31
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    32
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    33
lemma real_le_lsqrt: "0 <= x \<Longrightarrow> 0 <= y \<Longrightarrow> x <= y^2 ==> sqrt x <= y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    34
  using real_sqrt_le_iff[of x "y^2"] by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    35
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    36
lemma real_le_rsqrt: "x^2 \<le> y \<Longrightarrow> x \<le> sqrt y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    37
  using real_sqrt_le_mono[of "x^2" y] by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    38
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    39
lemma real_less_rsqrt: "x^2 < y \<Longrightarrow> x < sqrt y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    40
  using real_sqrt_less_mono[of "x^2" y] by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    41
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    42
lemma sqrt_even_pow2:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    43
  assumes n: "even n"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    44
  shows "sqrt(2 ^ n) = 2 ^ (n div 2)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    45
proof -
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    46
  from n obtain m where m: "n = 2*m" unfolding even_mult_two_ex ..
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    47
  from m  have "sqrt(2 ^ n) = sqrt ((2 ^ m) ^ 2)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    48
    by (simp only: power_mult[symmetric] mult_commute)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    49
  then show ?thesis  using m by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    50
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    51
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    52
lemma real_div_sqrt: "0 <= x ==> x / sqrt(x) = sqrt(x)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    53
  apply (cases "x = 0", simp_all)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    54
  using sqrt_divide_self_eq[of x]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    55
  apply (simp add: inverse_eq_divide field_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    56
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    57
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    58
text{* Hence derive more interesting properties of the norm. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    59
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    60
lemma norm_eq_0_dot: "(norm x = 0) \<longleftrightarrow> (inner x x = (0::real))"
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
    61
  by simp (* TODO: delete *)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    62
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    63
lemma norm_cauchy_schwarz: "inner x y <= norm x * norm y"
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
    64
  (* TODO: move to Inner_Product.thy *)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    65
  using Cauchy_Schwarz_ineq2[of x y] by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    66
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    67
lemma norm_triangle_sub:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    68
  fixes x y :: "'a::real_normed_vector"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    69
  shows "norm x \<le> norm y  + norm (x - y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    70
  using norm_triangle_ineq[of "y" "x - y"] by (simp add: field_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    71
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    72
lemma norm_le: "norm(x) <= norm(y) \<longleftrightarrow> x \<bullet> x <= y \<bullet> y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    73
  by (simp add: norm_eq_sqrt_inner) 
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
    74
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    75
lemma norm_lt: "norm(x) < norm(y) \<longleftrightarrow> x \<bullet> x < y \<bullet> y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    76
  by (simp add: norm_eq_sqrt_inner)
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
    77
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    78
lemma norm_eq: "norm(x) = norm (y) \<longleftrightarrow> x \<bullet> x = y \<bullet> y"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    79
  apply (subst order_eq_iff)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    80
  apply (auto simp: norm_le)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    81
  done
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
    82
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    83
lemma norm_eq_1: "norm(x) = 1 \<longleftrightarrow> x \<bullet> x = 1"
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
    84
  by (simp add: norm_eq_sqrt_inner)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    85
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    86
text{* Squaring equations and inequalities involving norms.  *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    87
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    88
lemma dot_square_norm: "x \<bullet> x = norm(x)^2"
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
    89
  by (simp only: power2_norm_eq_inner) (* TODO: move? *)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    90
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    91
lemma norm_eq_square: "norm(x) = a \<longleftrightarrow> 0 <= a \<and> x \<bullet> x = a^2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    92
  by (auto simp add: norm_eq_sqrt_inner)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    93
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    94
lemma real_abs_le_square_iff: "\<bar>x\<bar> \<le> \<bar>y\<bar> \<longleftrightarrow> (x::real)^2 \<le> y^2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    95
proof
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    96
  assume "\<bar>x\<bar> \<le> \<bar>y\<bar>"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    97
  then have "\<bar>x\<bar>\<twosuperior> \<le> \<bar>y\<bar>\<twosuperior>" by (rule power_mono, simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    98
  then show "x\<twosuperior> \<le> y\<twosuperior>" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    99
next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   100
  assume "x\<twosuperior> \<le> y\<twosuperior>"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   101
  then have "sqrt (x\<twosuperior>) \<le> sqrt (y\<twosuperior>)" by (rule real_sqrt_le_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   102
  then show "\<bar>x\<bar> \<le> \<bar>y\<bar>" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   103
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   104
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   105
lemma norm_le_square: "norm(x) <= a \<longleftrightarrow> 0 <= a \<and> x \<bullet> x <= a^2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   106
  apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   107
  using norm_ge_zero[of x]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   108
  apply arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   109
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   110
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   111
lemma norm_ge_square: "norm(x) >= a \<longleftrightarrow> a <= 0 \<or> x \<bullet> x >= a ^ 2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   112
  apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   113
  using norm_ge_zero[of x]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   114
  apply arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   115
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   116
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   117
lemma norm_lt_square: "norm(x) < a \<longleftrightarrow> 0 < a \<and> x \<bullet> x < a^2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   118
  by (metis not_le norm_ge_square)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   119
lemma norm_gt_square: "norm(x) > a \<longleftrightarrow> a < 0 \<or> x \<bullet> x > a^2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   120
  by (metis norm_le_square not_less)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   121
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   122
text{* Dot product in terms of the norm rather than conversely. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   123
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
   124
lemmas inner_simps = inner_add_left inner_add_right inner_diff_right inner_diff_left 
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   125
  inner_scaleR_left inner_scaleR_right
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   126
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   127
lemma dot_norm: "x \<bullet> y = (norm(x + y) ^2 - norm x ^ 2 - norm y ^ 2) / 2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   128
  unfolding power2_norm_eq_inner inner_simps inner_commute by auto 
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   129
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   130
lemma dot_norm_neg: "x \<bullet> y = ((norm x ^ 2 + norm y ^ 2) - norm(x - y) ^ 2) / 2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   131
  unfolding power2_norm_eq_inner inner_simps inner_commute by(auto simp add:algebra_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   132
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   133
text{* Equality of vectors in terms of @{term "op \<bullet>"} products.    *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   134
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   135
lemma vector_eq: "x = y \<longleftrightarrow> x \<bullet> x = x \<bullet> y \<and> y \<bullet> y = x \<bullet> x" (is "?lhs \<longleftrightarrow> ?rhs")
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   136
proof
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   137
  assume ?lhs then show ?rhs by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   138
next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   139
  assume ?rhs
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   140
  then have "x \<bullet> x - x \<bullet> y = 0 \<and> x \<bullet> y - y \<bullet> y = 0" by simp
44454
6f28f96a09bf avoid warnings
huffman
parents: 44451
diff changeset
   141
  hence "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0" by (simp add: inner_diff inner_commute)
6f28f96a09bf avoid warnings
huffman
parents: 44451
diff changeset
   142
  then have "(x - y) \<bullet> (x - y) = 0" by (simp add: field_simps inner_diff inner_commute)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   143
  then show "x = y" by (simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   144
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   145
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   146
lemma norm_triangle_half_r:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   147
  shows "norm (y - x1) < e / 2 \<Longrightarrow> norm (y - x2) < e / 2 \<Longrightarrow> norm (x1 - x2) < e"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   148
  using dist_triangle_half_r unfolding dist_norm[THEN sym] by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   149
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   150
lemma norm_triangle_half_l:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   151
  assumes "norm (x - y) < e / 2" "norm (x' - (y)) < e / 2" 
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   152
  shows "norm (x - x') < e"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   153
  using dist_triangle_half_l[OF assms[unfolded dist_norm[THEN sym]]]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   154
  unfolding dist_norm[THEN sym] .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   155
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   156
lemma norm_triangle_le: "norm(x) + norm y <= e ==> norm(x + y) <= e"
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   157
  by (rule norm_triangle_ineq [THEN order_trans])
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   158
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   159
lemma norm_triangle_lt: "norm(x) + norm(y) < e ==> norm(x + y) < e"
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   160
  by (rule norm_triangle_ineq [THEN le_less_trans])
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   161
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   162
lemma setsum_clauses:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   163
  shows "setsum f {} = 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   164
  and "finite S \<Longrightarrow> setsum f (insert x S) = (if x \<in> S then setsum f S else f x + setsum f S)"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   165
  by (auto simp add: insert_absorb)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   166
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   167
lemma setsum_norm_le:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   168
  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
   169
  assumes fg: "\<forall>x \<in> S. norm (f x) \<le> g x"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   170
  shows "norm (setsum f S) \<le> setsum g S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   171
  by (rule order_trans [OF norm_setsum setsum_mono]) (simp add: fg)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   172
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   173
lemma setsum_norm_bound:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   174
  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   175
  assumes fS: "finite S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   176
    and K: "\<forall>x \<in> S. norm (f x) \<le> K"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   177
  shows "norm (setsum f S) \<le> of_nat (card S) * K"
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
   178
  using setsum_norm_le[OF K] setsum_constant[symmetric]
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   179
  by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   180
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   181
lemma setsum_group:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   182
  assumes fS: "finite S" and fT: "finite T" and fST: "f ` S \<subseteq> T"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   183
  shows "setsum (\<lambda>y. setsum g {x. x\<in> S \<and> f x = y}) T = setsum g S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   184
  apply (subst setsum_image_gen[OF fS, of g f])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   185
  apply (rule setsum_mono_zero_right[OF fT fST])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   186
  apply (auto intro: setsum_0')
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   187
  done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   188
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   189
lemma vector_eq_ldot: "(\<forall>x. x \<bullet> y = x \<bullet> z) \<longleftrightarrow> y = z"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   190
proof
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   191
  assume "\<forall>x. x \<bullet> y = x \<bullet> z"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   192
  then have "\<forall>x. x \<bullet> (y - z) = 0" by (simp add: inner_diff)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   193
  then have "(y - z) \<bullet> (y - z) = 0" ..
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   194
  thus "y = z" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   195
qed simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   196
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   197
lemma vector_eq_rdot: "(\<forall>z. x \<bullet> z = y \<bullet> z) \<longleftrightarrow> x = y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   198
proof
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   199
  assume "\<forall>z. x \<bullet> z = y \<bullet> z"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   200
  then have "\<forall>z. (x - y) \<bullet> z = 0" by (simp add: inner_diff)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   201
  then have "(x - y) \<bullet> (x - y) = 0" ..
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   202
  thus "x = y" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   203
qed simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   204
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   205
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   206
subsection {* Orthogonality. *}
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   207
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   208
context real_inner
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   209
begin
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   210
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   211
definition "orthogonal x y \<longleftrightarrow> (x \<bullet> y = 0)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   212
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   213
lemma orthogonal_clauses:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   214
  "orthogonal a 0"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   215
  "orthogonal a x \<Longrightarrow> orthogonal a (c *\<^sub>R x)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   216
  "orthogonal a x \<Longrightarrow> orthogonal a (-x)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   217
  "orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x + y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   218
  "orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x - y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   219
  "orthogonal 0 a"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   220
  "orthogonal x a \<Longrightarrow> orthogonal (c *\<^sub>R x) a"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   221
  "orthogonal x a \<Longrightarrow> orthogonal (-x) a"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   222
  "orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x + y) a"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   223
  "orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x - y) a"
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   224
  unfolding orthogonal_def inner_add inner_diff by auto
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   225
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   226
end
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   227
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   228
lemma orthogonal_commute: "orthogonal x y \<longleftrightarrow> orthogonal y x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   229
  by (simp add: orthogonal_def inner_commute)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   230
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   231
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   232
subsection {* Linear functions. *}
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   233
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   234
definition linear :: "('a::real_vector \<Rightarrow> 'b::real_vector) \<Rightarrow> bool"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   235
  where "linear f \<longleftrightarrow> (\<forall>x y. f(x + y) = f x + f y) \<and> (\<forall>c x. f(c *\<^sub>R x) = c *\<^sub>R f x)"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   236
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   237
lemma linearI:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   238
  assumes "\<And>x y. f (x + y) = f x + f y" "\<And>c x. f (c *\<^sub>R x) = c *\<^sub>R f x"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   239
  shows "linear f"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   240
  using assms unfolding linear_def by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   241
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   242
lemma linear_compose_cmul: "linear f ==> linear (\<lambda>x. c *\<^sub>R f x)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   243
  by (simp add: linear_def algebra_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   244
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   245
lemma linear_compose_neg: "linear f ==> linear (\<lambda>x. -(f(x)))"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   246
  by (simp add: linear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   247
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   248
lemma linear_compose_add: "linear f \<Longrightarrow> linear g ==> linear (\<lambda>x. f(x) + g(x))"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   249
  by (simp add: linear_def algebra_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   250
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   251
lemma linear_compose_sub: "linear f \<Longrightarrow> linear g ==> linear (\<lambda>x. f x - g x)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   252
  by (simp add: linear_def algebra_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   253
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   254
lemma linear_compose: "linear f \<Longrightarrow> linear g ==> linear (g o f)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   255
  by (simp add: linear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   256
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   257
lemma linear_id: "linear id" by (simp add: linear_def id_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   258
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   259
lemma linear_zero: "linear (\<lambda>x. 0)" by (simp add: linear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   260
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   261
lemma linear_compose_setsum:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   262
  assumes fS: "finite S" and lS: "\<forall>a \<in> S. linear (f a)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   263
  shows "linear(\<lambda>x. setsum (\<lambda>a. f a x) S)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   264
  using lS
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   265
  apply (induct rule: finite_induct[OF fS])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   266
  apply (auto simp add: linear_zero intro: linear_compose_add)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   267
  done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   268
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   269
lemma linear_0: "linear f \<Longrightarrow> f 0 = 0"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   270
  unfolding linear_def
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   271
  apply clarsimp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   272
  apply (erule allE[where x="0::'a"])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   273
  apply simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   274
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   275
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   276
lemma linear_cmul: "linear f ==> f(c *\<^sub>R x) = c *\<^sub>R f x"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   277
  by (simp add: linear_def)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   278
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   279
lemma linear_neg: "linear f ==> f (-x) = - f x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   280
  using linear_cmul [where c="-1"] by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   281
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   282
lemma linear_add: "linear f ==> f(x + y) = f x + f y"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   283
  by (metis linear_def)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   284
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   285
lemma linear_sub: "linear f ==> f(x - y) = f x - f y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   286
  by (simp add: diff_minus linear_add linear_neg)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   287
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   288
lemma linear_setsum:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   289
  assumes lf: "linear f" and fS: "finite S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   290
  shows "f (setsum g S) = setsum (f o g) S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   291
  using fS
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   292
proof (induct rule: finite_induct)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   293
  case empty
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   294
  then show ?case by (simp add: linear_0[OF lf])
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   295
next
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   296
  case (insert x F)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   297
  have "f (setsum g (insert x F)) = f (g x + setsum g F)" using insert.hyps
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   298
    by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   299
  also have "\<dots> = f (g x) + f (setsum g F)" using linear_add[OF lf] by simp
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   300
  also have "\<dots> = setsum (f o g) (insert x F)" using insert.hyps by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   301
  finally show ?case .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   302
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   303
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   304
lemma linear_setsum_mul:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   305
  assumes lf: "linear f" and fS: "finite S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   306
  shows "f (setsum (\<lambda>i. c i *\<^sub>R v i) S) = setsum (\<lambda>i. c i *\<^sub>R f (v i)) S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   307
  using linear_setsum[OF lf fS, of "\<lambda>i. c i *\<^sub>R v i" , unfolded o_def] linear_cmul[OF lf]
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   308
  by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   309
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   310
lemma linear_injective_0:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   311
  assumes lf: "linear f"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   312
  shows "inj f \<longleftrightarrow> (\<forall>x. f x = 0 \<longrightarrow> x = 0)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   313
proof-
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   314
  have "inj f \<longleftrightarrow> (\<forall> x y. f x = f y \<longrightarrow> x = y)" by (simp add: inj_on_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   315
  also have "\<dots> \<longleftrightarrow> (\<forall> x y. f x - f y = 0 \<longrightarrow> x - y = 0)" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   316
  also have "\<dots> \<longleftrightarrow> (\<forall> x y. f (x - y) = 0 \<longrightarrow> x - y = 0)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   317
    by (simp add: linear_sub[OF lf])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   318
  also have "\<dots> \<longleftrightarrow> (\<forall> x. f x = 0 \<longrightarrow> x = 0)" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   319
  finally show ?thesis .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   320
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   321
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   322
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   323
subsection {* Bilinear functions. *}
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   324
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   325
definition "bilinear f \<longleftrightarrow> (\<forall>x. linear(\<lambda>y. f x y)) \<and> (\<forall>y. linear(\<lambda>x. f x y))"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   326
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   327
lemma bilinear_ladd: "bilinear h ==> h (x + y) z = (h x z) + (h y z)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   328
  by (simp add: bilinear_def linear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   329
lemma bilinear_radd: "bilinear h ==> h x (y + z) = (h x y) + (h x z)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   330
  by (simp add: bilinear_def linear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   331
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   332
lemma bilinear_lmul: "bilinear h ==> h (c *\<^sub>R x) y = c *\<^sub>R (h x y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   333
  by (simp add: bilinear_def linear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   334
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   335
lemma bilinear_rmul: "bilinear h ==> h x (c *\<^sub>R y) = c *\<^sub>R (h x y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   336
  by (simp add: bilinear_def linear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   337
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   338
lemma bilinear_lneg: "bilinear h ==> h (- x) y = -(h x y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   339
  by (simp only: scaleR_minus1_left [symmetric] bilinear_lmul)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   340
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   341
lemma bilinear_rneg: "bilinear h ==> h x (- y) = - h x y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   342
  by (simp only: scaleR_minus1_left [symmetric] bilinear_rmul)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   343
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   344
lemma  (in ab_group_add) eq_add_iff: "x = x + y \<longleftrightarrow> y = 0"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   345
  using add_imp_eq[of x y 0] by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   346
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   347
lemma bilinear_lzero:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   348
  assumes bh: "bilinear h" shows "h 0 x = 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   349
  using bilinear_ladd[OF bh, of 0 0 x] by (simp add: eq_add_iff field_simps)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   350
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   351
lemma bilinear_rzero:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   352
  assumes bh: "bilinear h" shows "h x 0 = 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   353
  using bilinear_radd[OF bh, of x 0 0 ] by (simp add: eq_add_iff field_simps)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   354
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   355
lemma bilinear_lsub: "bilinear h ==> h (x - y) z = h x z - h y z"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   356
  by (simp  add: diff_minus bilinear_ladd bilinear_lneg)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   357
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   358
lemma bilinear_rsub: "bilinear h ==> h z (x - y) = h z x - h z y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   359
  by (simp  add: diff_minus bilinear_radd bilinear_rneg)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   360
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   361
lemma bilinear_setsum:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   362
  assumes bh: "bilinear h" and fS: "finite S" and fT: "finite T"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   363
  shows "h (setsum f S) (setsum g T) = setsum (\<lambda>(i,j). h (f i) (g j)) (S \<times> T) "
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   364
proof -
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   365
  have "h (setsum f S) (setsum g T) = setsum (\<lambda>x. h (f x) (setsum g T)) S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   366
    apply (rule linear_setsum[unfolded o_def])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   367
    using bh fS apply (auto simp add: bilinear_def)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   368
    done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   369
  also have "\<dots> = setsum (\<lambda>x. setsum (\<lambda>y. h (f x) (g y)) T) S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   370
    apply (rule setsum_cong, simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   371
    apply (rule linear_setsum[unfolded o_def])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   372
    using bh fT
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   373
    apply (auto simp add: bilinear_def)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   374
    done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   375
  finally show ?thesis unfolding setsum_cartesian_product .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   376
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   377
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   378
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   379
subsection {* Adjoints. *}
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   380
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   381
definition "adjoint f = (SOME f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   382
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   383
lemma adjoint_unique:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   384
  assumes "\<forall>x y. inner (f x) y = inner x (g y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   385
  shows "adjoint f = g"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   386
  unfolding adjoint_def
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   387
proof (rule some_equality)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   388
  show "\<forall>x y. inner (f x) y = inner x (g y)" using assms .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   389
next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   390
  fix h assume "\<forall>x y. inner (f x) y = inner x (h y)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   391
  hence "\<forall>x y. inner x (g y) = inner x (h y)" using assms by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   392
  hence "\<forall>x y. inner x (g y - h y) = 0" by (simp add: inner_diff_right)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   393
  hence "\<forall>y. inner (g y - h y) (g y - h y) = 0" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   394
  hence "\<forall>y. h y = g y" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   395
  thus "h = g" by (simp add: ext)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   396
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   397
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   398
lemma choice_iff: "(\<forall>x. \<exists>y. P x y) \<longleftrightarrow> (\<exists>f. \<forall>x. P x (f x))" by metis
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   399
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   400
subsection {* Interlude: Some properties of real sets *}
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   401
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   402
lemma seq_mono_lemma: assumes "\<forall>(n::nat) \<ge> m. (d n :: real) < e n" and "\<forall>n \<ge> m. e n <= e m"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   403
  shows "\<forall>n \<ge> m. d n < e m"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   404
  using assms apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   405
  apply (erule_tac x="n" in allE)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   406
  apply (erule_tac x="n" in allE)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   407
  apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   408
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   409
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   410
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   411
lemma infinite_enumerate: assumes fS: "infinite S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   412
  shows "\<exists>r. subseq r \<and> (\<forall>n. r n \<in> S)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   413
unfolding subseq_def
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   414
using enumerate_in_set[OF fS] enumerate_mono[of _ _ S] fS by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   415
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   416
lemma approachable_lt_le: "(\<exists>(d::real)>0. \<forall>x. f x < d \<longrightarrow> P x) \<longleftrightarrow> (\<exists>d>0. \<forall>x. f x \<le> d \<longrightarrow> P x)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   417
  apply auto
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   418
  apply (rule_tac x="d/2" in exI)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   419
  apply auto
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   420
  done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   421
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   422
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   423
lemma triangle_lemma:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   424
  assumes x: "0 <= (x::real)" and y:"0 <= y" and z: "0 <= z" and xy: "x^2 <= y^2 + z^2"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   425
  shows "x <= y + z"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   426
proof -
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   427
  have "y^2 + z^2 \<le> y^2 + 2*y*z + z^2" using z y by (simp add: mult_nonneg_nonneg)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   428
  with xy have th: "x ^2 \<le> (y+z)^2" by (simp add: power2_eq_square field_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   429
  from y z have yz: "y + z \<ge> 0" by arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   430
  from power2_le_imp_le[OF th yz] show ?thesis .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   431
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   432
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   433
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   434
subsection {* A generic notion of "hull" (convex, affine, conic hull and closure). *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   435
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   436
definition hull :: "('a set \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "hull" 75)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   437
  where "S hull s = Inter {t. S t \<and> s \<subseteq> t}"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   438
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   439
lemma hull_same: "S s \<Longrightarrow> S hull s = s"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   440
  unfolding hull_def by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   441
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   442
lemma hull_in: "(\<And>T. Ball T S ==> S (Inter T)) ==> S (S hull s)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   443
  unfolding hull_def Ball_def by auto
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   444
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   445
lemma hull_eq: "(\<And>T. Ball T S ==> S (Inter T)) ==> (S hull s) = s \<longleftrightarrow> S s"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   446
  using hull_same[of S s] hull_in[of S s] by metis
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   447
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   448
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   449
lemma hull_hull: "S hull (S hull s) = S hull s"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   450
  unfolding hull_def by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   451
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   452
lemma hull_subset[intro]: "s \<subseteq> (S hull s)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   453
  unfolding hull_def by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   454
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   455
lemma hull_mono: " s \<subseteq> t ==> (S hull s) \<subseteq> (S hull t)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   456
  unfolding hull_def by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   457
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   458
lemma hull_antimono: "\<forall>x. S x \<longrightarrow> T x ==> (T hull s) \<subseteq> (S hull s)"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   459
  unfolding hull_def by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   460
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   461
lemma hull_minimal: "s \<subseteq> t \<Longrightarrow> S t ==> (S hull s) \<subseteq> t"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   462
  unfolding hull_def by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   463
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   464
lemma subset_hull: "S t ==> S hull s \<subseteq> t \<longleftrightarrow>  s \<subseteq> t"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   465
  unfolding hull_def by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   466
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   467
lemma hull_unique: "s \<subseteq> t \<Longrightarrow> S t \<Longrightarrow> (\<And>t'. s \<subseteq> t' \<Longrightarrow> S t' ==> t \<subseteq> t')
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   468
           ==> (S hull s = t)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   469
unfolding hull_def by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   470
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   471
lemma hull_induct: "(\<And>x. x\<in> S \<Longrightarrow> P x) \<Longrightarrow> Q {x. P x} \<Longrightarrow> \<forall>x\<in> Q hull S. P x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   472
  using hull_minimal[of S "{x. P x}" Q]
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   473
  by (auto simp add: subset_eq)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   474
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   475
lemma hull_inc: "x \<in> S \<Longrightarrow> x \<in> P hull S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   476
  by (metis hull_subset subset_eq)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   477
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   478
lemma hull_union_subset: "(S hull s) \<union> (S hull t) \<subseteq> (S hull (s \<union> t))"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   479
  unfolding Un_subset_iff by (metis hull_mono Un_upper1 Un_upper2)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   480
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   481
lemma hull_union:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   482
  assumes T: "\<And>T. Ball T S ==> S (Inter T)"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   483
  shows "S hull (s \<union> t) = S hull (S hull s \<union> S hull t)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   484
  apply rule
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   485
  apply (rule hull_mono)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   486
  unfolding Un_subset_iff
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   487
  apply (metis hull_subset Un_upper1 Un_upper2 subset_trans)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   488
  apply (rule hull_minimal)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   489
  apply (metis hull_union_subset)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   490
  apply (metis hull_in T)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   491
  done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   492
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   493
lemma hull_redundant_eq: "a \<in> (S hull s) \<longleftrightarrow> (S hull (insert a s) = S hull s)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   494
  unfolding hull_def by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   495
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   496
lemma hull_redundant: "a \<in> (S hull s) ==> (S hull (insert a s) = S hull s)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   497
  by (metis hull_redundant_eq)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   498
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   499
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   500
subsection {* Archimedean properties and useful consequences *}
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   501
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   502
lemma real_arch_simple: "\<exists>n. x <= real (n::nat)"
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   503
  unfolding real_of_nat_def by (rule ex_le_of_nat)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   504
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   505
lemma real_arch_inv: "0 < e \<longleftrightarrow> (\<exists>n::nat. n \<noteq> 0 \<and> 0 < inverse (real n) \<and> inverse (real n) < e)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   506
  using reals_Archimedean
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   507
  apply (auto simp add: field_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   508
  apply (subgoal_tac "inverse (real n) > 0")
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   509
  apply arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   510
  apply simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   511
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   512
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   513
lemma real_pow_lbound: "0 <= x ==> 1 + real n * x <= (1 + x) ^ n"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   514
proof (induct n)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   515
  case 0
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   516
  then show ?case by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   517
next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   518
  case (Suc n)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   519
  then have h: "1 + real n * x \<le> (1 + x) ^ n" by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   520
  from h have p: "1 \<le> (1 + x) ^ n" using Suc.prems by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   521
  from h have "1 + real n * x + x \<le> (1 + x) ^ n + x" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   522
  also have "\<dots> \<le> (1 + x) ^ Suc n" apply (subst diff_le_0_iff_le[symmetric])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   523
    apply (simp add: field_simps)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   524
    using mult_left_mono[OF p Suc.prems] apply simp
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   525
    done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   526
  finally show ?case  by (simp add: real_of_nat_Suc field_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   527
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   528
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   529
lemma real_arch_pow: assumes x: "1 < (x::real)" shows "\<exists>n. y < x^n"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   530
proof -
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   531
  from x have x0: "x - 1 > 0" by arith
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   532
  from reals_Archimedean3[OF x0, rule_format, of y]
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   533
  obtain n::nat where n:"y < real n * (x - 1)" by metis
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   534
  from x0 have x00: "x- 1 \<ge> 0" by arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   535
  from real_pow_lbound[OF x00, of n] n
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   536
  have "y < x^n" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   537
  then show ?thesis by metis
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   538
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   539
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   540
lemma real_arch_pow2: "\<exists>n. (x::real) < 2^ n"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   541
  using real_arch_pow[of 2 x] by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   542
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   543
lemma real_arch_pow_inv:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   544
  assumes y: "(y::real) > 0" and x1: "x < 1"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   545
  shows "\<exists>n. x^n < y"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   546
proof -
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   547
  { assume x0: "x > 0"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   548
    from x0 x1 have ix: "1 < 1/x" by (simp add: field_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   549
    from real_arch_pow[OF ix, of "1/y"]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   550
    obtain n where n: "1/y < (1/x)^n" by blast
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   551
    then have ?thesis using y x0
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   552
      by (auto simp add: field_simps power_divide) }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   553
  moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   554
  { assume "\<not> x > 0"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   555
    with y x1 have ?thesis apply auto by (rule exI[where x=1], auto) }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   556
  ultimately show ?thesis by metis
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   557
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   558
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   559
lemma forall_pos_mono:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   560
  "(\<And>d e::real. d < e \<Longrightarrow> P d ==> P e) \<Longrightarrow>
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   561
    (\<And>n::nat. n \<noteq> 0 ==> P(inverse(real n))) \<Longrightarrow> (\<And>e. 0 < e ==> P e)"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   562
  by (metis real_arch_inv)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   563
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   564
lemma forall_pos_mono_1:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   565
  "(\<And>d e::real. d < e \<Longrightarrow> P d ==> P e) \<Longrightarrow>
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   566
    (\<And>n. P(inverse(real (Suc n)))) ==> 0 < e ==> P e"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   567
  apply (rule forall_pos_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   568
  apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   569
  apply (atomize)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   570
  apply (erule_tac x="n - 1" in allE)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   571
  apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   572
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   573
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   574
lemma real_archimedian_rdiv_eq_0:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   575
  assumes x0: "x \<ge> 0" and c: "c \<ge> 0" and xc: "\<forall>(m::nat)>0. real m * x \<le> c"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   576
  shows "x = 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   577
proof -
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   578
  { assume "x \<noteq> 0" with x0 have xp: "x > 0" by arith
44666
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   579
    from reals_Archimedean3[OF xp, rule_format, of c]
8670a39d4420 remove more duplicate lemmas
huffman
parents: 44646
diff changeset
   580
    obtain n::nat where n: "c < real n * x" by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   581
    with xc[rule_format, of n] have "n = 0" by arith
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   582
    with n c have False by simp }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   583
  then show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   584
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   585
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   586
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   587
subsection{* A bit of linear algebra. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   588
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   589
definition (in real_vector) subspace :: "'a set \<Rightarrow> bool"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   590
  where "subspace S \<longleftrightarrow> 0 \<in> S \<and> (\<forall>x\<in> S. \<forall>y \<in>S. x + y \<in> S) \<and> (\<forall>c. \<forall>x \<in>S. c *\<^sub>R x \<in>S )"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   591
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   592
definition (in real_vector) "span S = (subspace hull S)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   593
definition (in real_vector) "dependent S \<longleftrightarrow> (\<exists>a \<in> S. a \<in> span(S - {a}))"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   594
abbreviation (in real_vector) "independent s == ~(dependent s)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   595
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   596
text {* Closure properties of subspaces. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   597
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   598
lemma subspace_UNIV[simp]: "subspace(UNIV)" by (simp add: subspace_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   599
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   600
lemma (in real_vector) subspace_0: "subspace S ==> 0 \<in> S" by (metis subspace_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   601
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   602
lemma (in real_vector) subspace_add: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S ==> x + y \<in> S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   603
  by (metis subspace_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   604
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   605
lemma (in real_vector) subspace_mul: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> c *\<^sub>R x \<in> S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   606
  by (metis subspace_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   607
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   608
lemma subspace_neg: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> - x \<in> S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   609
  by (metis scaleR_minus1_left subspace_mul)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   610
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   611
lemma subspace_sub: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x - y \<in> S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   612
  by (metis diff_minus subspace_add subspace_neg)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   613
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   614
lemma (in real_vector) subspace_setsum:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   615
  assumes sA: "subspace A" and fB: "finite B"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   616
    and f: "\<forall>x\<in> B. f x \<in> A"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   617
  shows "setsum f B \<in> A"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   618
  using  fB f sA
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   619
  by (induct rule: finite_induct[OF fB])
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   620
    (simp add: subspace_def sA, auto simp add: sA subspace_add)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   621
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   622
lemma subspace_linear_image:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   623
  assumes lf: "linear f" and sS: "subspace S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   624
  shows "subspace(f ` S)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   625
  using lf sS linear_0[OF lf]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   626
  unfolding linear_def subspace_def
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   627
  apply (auto simp add: image_iff)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   628
  apply (rule_tac x="x + y" in bexI, auto)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   629
  apply (rule_tac x="c *\<^sub>R x" in bexI, auto)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   630
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   631
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   632
lemma subspace_linear_vimage: "linear f \<Longrightarrow> subspace S \<Longrightarrow> subspace (f -` S)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   633
  by (auto simp add: subspace_def linear_def linear_0[of f])
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   634
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   635
lemma subspace_linear_preimage: "linear f ==> subspace S ==> subspace {x. f x \<in> S}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   636
  by (auto simp add: subspace_def linear_def linear_0[of f])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   637
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   638
lemma subspace_trivial: "subspace {0}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   639
  by (simp add: subspace_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   640
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   641
lemma (in real_vector) subspace_inter: "subspace A \<Longrightarrow> subspace B ==> subspace (A \<inter> B)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   642
  by (simp add: subspace_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   643
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   644
lemma subspace_Times: "\<lbrakk>subspace A; subspace B\<rbrakk> \<Longrightarrow> subspace (A \<times> B)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   645
  unfolding subspace_def zero_prod_def by simp
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   646
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   647
text {* Properties of span. *}
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   648
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   649
lemma (in real_vector) span_mono: "A \<subseteq> B ==> span A \<subseteq> span B"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   650
  by (metis span_def hull_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   651
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   652
lemma (in real_vector) subspace_span: "subspace(span S)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   653
  unfolding span_def
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   654
  apply (rule hull_in)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   655
  apply (simp only: subspace_def Inter_iff Int_iff subset_eq)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   656
  apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   657
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   658
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   659
lemma (in real_vector) span_clauses:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   660
  "a \<in> S ==> a \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   661
  "0 \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   662
  "x\<in> span S \<Longrightarrow> y \<in> span S ==> x + y \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   663
  "x \<in> span S \<Longrightarrow> c *\<^sub>R x \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   664
  by (metis span_def hull_subset subset_eq)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   665
     (metis subspace_span subspace_def)+
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   666
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   667
lemma span_unique:
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   668
  "S \<subseteq> T \<Longrightarrow> subspace T \<Longrightarrow> (\<And>T'. S \<subseteq> T' \<Longrightarrow> subspace T' \<Longrightarrow> T \<subseteq> T') \<Longrightarrow> span S = T"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   669
  unfolding span_def by (rule hull_unique)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   670
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   671
lemma span_minimal: "S \<subseteq> T \<Longrightarrow> subspace T \<Longrightarrow> span S \<subseteq> T"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   672
  unfolding span_def by (rule hull_minimal)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   673
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   674
lemma (in real_vector) span_induct:
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   675
  assumes x: "x \<in> span S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   676
    and P: "subspace P"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   677
    and SP: "\<And>x. x \<in> S ==> x \<in> P"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   678
  shows "x \<in> P"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   679
proof -
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   680
  from SP have SP': "S \<subseteq> P" by (simp add: subset_eq)
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   681
  from x hull_minimal[where S=subspace, OF SP' P, unfolded span_def[symmetric]]
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   682
  show "x \<in> P" by (metis subset_eq)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   683
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   684
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   685
lemma span_empty[simp]: "span {} = {0}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   686
  apply (simp add: span_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   687
  apply (rule hull_unique)
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   688
  apply (auto simp add: subspace_def)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   689
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   690
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   691
lemma (in real_vector) independent_empty[intro]: "independent {}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   692
  by (simp add: dependent_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   693
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   694
lemma dependent_single[simp]: "dependent {x} \<longleftrightarrow> x = 0"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   695
  unfolding dependent_def by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   696
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   697
lemma (in real_vector) independent_mono: "independent A \<Longrightarrow> B \<subseteq> A ==> independent B"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   698
  apply (clarsimp simp add: dependent_def span_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   699
  apply (subgoal_tac "span (B - {a}) \<le> span (A - {a})")
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   700
  apply force
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   701
  apply (rule span_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   702
  apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   703
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   704
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   705
lemma (in real_vector) span_subspace: "A \<subseteq> B \<Longrightarrow> B \<le> span A \<Longrightarrow>  subspace B \<Longrightarrow> span A = B"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   706
  by (metis order_antisym span_def hull_minimal)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   707
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   708
lemma (in real_vector) span_induct': assumes SP: "\<forall>x \<in> S. P x"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   709
  and P: "subspace {x. P x}" shows "\<forall>x \<in> span S. P x"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   710
  using span_induct SP P by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   711
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   712
inductive_set (in real_vector) span_induct_alt_help for S:: "'a set"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   713
  where
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   714
  span_induct_alt_help_0: "0 \<in> span_induct_alt_help S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   715
| span_induct_alt_help_S:
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   716
    "x \<in> S \<Longrightarrow> z \<in> span_induct_alt_help S \<Longrightarrow> (c *\<^sub>R x + z) \<in> span_induct_alt_help S"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   717
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   718
lemma span_induct_alt':
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   719
  assumes h0: "h 0" and hS: "\<And>c x y. x \<in> S \<Longrightarrow> h y \<Longrightarrow> h (c *\<^sub>R x + y)"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   720
  shows "\<forall>x \<in> span S. h x"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   721
proof -
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   722
  { fix x:: "'a" assume x: "x \<in> span_induct_alt_help S"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   723
    have "h x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   724
      apply (rule span_induct_alt_help.induct[OF x])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   725
      apply (rule h0)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   726
      apply (rule hS, assumption, assumption)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   727
      done }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   728
  note th0 = this
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   729
  { fix x assume x: "x \<in> span S"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   730
    have "x \<in> span_induct_alt_help S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   731
    proof (rule span_induct[where x=x and S=S])
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   732
      show "x \<in> span S" using x .
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   733
    next
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   734
      fix x assume xS : "x \<in> S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   735
        from span_induct_alt_help_S[OF xS span_induct_alt_help_0, of 1]
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   736
        show "x \<in> span_induct_alt_help S" by simp
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   737
    next
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   738
      have "0 \<in> span_induct_alt_help S" by (rule span_induct_alt_help_0)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   739
      moreover
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   740
      { fix x y
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   741
        assume h: "x \<in> span_induct_alt_help S" "y \<in> span_induct_alt_help S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   742
        from h have "(x + y) \<in> span_induct_alt_help S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   743
          apply (induct rule: span_induct_alt_help.induct)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   744
          apply simp
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   745
          unfolding add_assoc
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   746
          apply (rule span_induct_alt_help_S)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   747
          apply assumption
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   748
          apply simp
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   749
          done }
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   750
      moreover
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   751
      { fix c x
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   752
        assume xt: "x \<in> span_induct_alt_help S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   753
        then have "(c *\<^sub>R x) \<in> span_induct_alt_help S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   754
          apply (induct rule: span_induct_alt_help.induct)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   755
          apply (simp add: span_induct_alt_help_0)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   756
          apply (simp add: scaleR_right_distrib)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   757
          apply (rule span_induct_alt_help_S)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   758
          apply assumption
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   759
          apply simp
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   760
          done }
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   761
      ultimately
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   762
      show "subspace (span_induct_alt_help S)"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   763
        unfolding subspace_def Ball_def by blast
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   764
    qed }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   765
  with th0 show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   766
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   767
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   768
lemma span_induct_alt:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   769
  assumes h0: "h 0" and hS: "\<And>c x y. x \<in> S \<Longrightarrow> h y \<Longrightarrow> h (c *\<^sub>R x + y)" and x: "x \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   770
  shows "h x"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   771
  using span_induct_alt'[of h S] h0 hS x by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   772
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   773
text {* Individual closure properties. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   774
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   775
lemma span_span: "span (span A) = span A"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   776
  unfolding span_def hull_hull ..
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   777
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   778
lemma (in real_vector) span_superset: "x \<in> S ==> x \<in> span S" by (metis span_clauses(1))
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   779
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   780
lemma (in real_vector) span_0: "0 \<in> span S" by (metis subspace_span subspace_0)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   781
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   782
lemma span_inc: "S \<subseteq> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   783
  by (metis subset_eq span_superset)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   784
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   785
lemma (in real_vector) dependent_0: assumes "0\<in>A" shows "dependent A"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   786
  unfolding dependent_def apply(rule_tac x=0 in bexI)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   787
  using assms span_0 by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   788
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   789
lemma (in real_vector) span_add: "x \<in> span S \<Longrightarrow> y \<in> span S ==> x + y \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   790
  by (metis subspace_add subspace_span)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   791
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   792
lemma (in real_vector) span_mul: "x \<in> span S ==> (c *\<^sub>R x) \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   793
  by (metis subspace_span subspace_mul)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   794
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   795
lemma span_neg: "x \<in> span S ==> - x \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   796
  by (metis subspace_neg subspace_span)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   797
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   798
lemma span_sub: "x \<in> span S \<Longrightarrow> y \<in> span S ==> x - y \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   799
  by (metis subspace_span subspace_sub)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   800
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   801
lemma (in real_vector) span_setsum: "finite A \<Longrightarrow> \<forall>x \<in> A. f x \<in> span S ==> setsum f A \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   802
  by (rule subspace_setsum, rule subspace_span)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   803
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   804
lemma span_add_eq: "x \<in> span S \<Longrightarrow> x + y \<in> span S \<longleftrightarrow> y \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   805
  apply (auto simp only: span_add span_sub)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   806
  apply (subgoal_tac "(x + y) - x \<in> span S", simp)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   807
  apply (simp only: span_add span_sub)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   808
  done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   809
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   810
text {* Mapping under linear image. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   811
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   812
lemma image_subset_iff_subset_vimage: "f ` A \<subseteq> B \<longleftrightarrow> A \<subseteq> f -` B"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   813
  by auto (* TODO: move *)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   814
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   815
lemma span_linear_image:
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   816
  assumes lf: "linear f"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   817
  shows "span (f ` S) = f ` (span S)"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   818
proof (rule span_unique)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   819
  show "f ` S \<subseteq> f ` span S"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   820
    by (intro image_mono span_inc)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   821
  show "subspace (f ` span S)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   822
    using lf subspace_span by (rule subspace_linear_image)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   823
next
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   824
  fix T assume "f ` S \<subseteq> T" and "subspace T"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   825
  then show "f ` span S \<subseteq> T"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   826
    unfolding image_subset_iff_subset_vimage
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   827
    by (intro span_minimal subspace_linear_vimage lf)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   828
qed
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   829
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   830
lemma span_union: "span (A \<union> B) = (\<lambda>(a, b). a + b) ` (span A \<times> span B)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   831
proof (rule span_unique)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   832
  show "A \<union> B \<subseteq> (\<lambda>(a, b). a + b) ` (span A \<times> span B)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   833
    by safe (force intro: span_clauses)+
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   834
next
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   835
  have "linear (\<lambda>(a, b). a + b)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   836
    by (simp add: linear_def scaleR_add_right)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   837
  moreover have "subspace (span A \<times> span B)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   838
    by (intro subspace_Times subspace_span)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   839
  ultimately show "subspace ((\<lambda>(a, b). a + b) ` (span A \<times> span B))"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   840
    by (rule subspace_linear_image)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   841
next
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   842
  fix T assume "A \<union> B \<subseteq> T" and "subspace T"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   843
  then show "(\<lambda>(a, b). a + b) ` (span A \<times> span B) \<subseteq> T"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   844
    by (auto intro!: subspace_add elim: span_induct)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   845
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   846
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   847
text {* The key breakdown property. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   848
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   849
lemma span_singleton: "span {x} = range (\<lambda>k. k *\<^sub>R x)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   850
proof (rule span_unique)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   851
  show "{x} \<subseteq> range (\<lambda>k. k *\<^sub>R x)"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   852
    by (fast intro: scaleR_one [symmetric])
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   853
  show "subspace (range (\<lambda>k. k *\<^sub>R x))"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   854
    unfolding subspace_def
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   855
    by (auto intro: scaleR_add_left [symmetric])
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   856
  fix T assume "{x} \<subseteq> T" and "subspace T" thus "range (\<lambda>k. k *\<^sub>R x) \<subseteq> T"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   857
    unfolding subspace_def by auto
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   858
qed
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   859
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   860
lemma span_insert: "span (insert a S) = {x. \<exists>k. (x - k *\<^sub>R a) \<in> span S}"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   861
proof -
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   862
  have "span ({a} \<union> S) = {x. \<exists>k. (x - k *\<^sub>R a) \<in> span S}"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   863
    unfolding span_union span_singleton
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   864
    apply safe
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   865
    apply (rule_tac x=k in exI, simp)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   866
    apply (erule rev_image_eqI [OF SigmaI [OF rangeI]])
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   867
    apply simp
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   868
    apply (rule right_minus)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   869
    done
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   870
  then show ?thesis by simp
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   871
qed
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   872
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   873
lemma span_breakdown:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   874
  assumes bS: "b \<in> S" and aS: "a \<in> span S"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   875
  shows "\<exists>k. a - k *\<^sub>R b \<in> span (S - {b})"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   876
  using assms span_insert [of b "S - {b}"]
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   877
  by (simp add: insert_absorb)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   878
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   879
lemma span_breakdown_eq: "x \<in> span (insert a S) \<longleftrightarrow> (\<exists>k. (x - k *\<^sub>R a) \<in> span S)"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   880
  by (simp add: span_insert)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   881
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   882
text {* Hence some "reversal" results. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   883
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   884
lemma in_span_insert:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   885
  assumes a: "a \<in> span (insert b S)" and na: "a \<notin> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   886
  shows "b \<in> span (insert a S)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   887
proof-
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   888
  from span_breakdown[of b "insert b S" a, OF insertI1 a]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   889
  obtain k where k: "a - k*\<^sub>R b \<in> span (S - {b})" by auto
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   890
  { assume k0: "k = 0"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   891
    with k have "a \<in> span S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   892
      apply (simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   893
      apply (rule set_rev_mp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   894
      apply assumption
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   895
      apply (rule span_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   896
      apply blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   897
      done
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   898
    with na  have ?thesis by blast }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   899
  moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   900
  { assume k0: "k \<noteq> 0"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   901
    have eq: "b = (1/k) *\<^sub>R a - ((1/k) *\<^sub>R a - b)" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   902
    from k0 have eq': "(1/k) *\<^sub>R (a - k*\<^sub>R b) = (1/k) *\<^sub>R a - b"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   903
      by (simp add: algebra_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   904
    from k have "(1/k) *\<^sub>R (a - k*\<^sub>R b) \<in> span (S - {b})"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   905
      by (rule span_mul)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   906
    hence th: "(1/k) *\<^sub>R a - b \<in> span (S - {b})"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   907
      unfolding eq' .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   908
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   909
    from k
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   910
    have ?thesis
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   911
      apply (subst eq)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   912
      apply (rule span_sub)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   913
      apply (rule span_mul)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   914
      apply (rule span_superset)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   915
      apply blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   916
      apply (rule set_rev_mp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   917
      apply (rule th)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   918
      apply (rule span_mono)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   919
      using na by blast }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   920
  ultimately show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   921
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   922
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   923
lemma in_span_delete:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   924
  assumes a: "a \<in> span S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   925
    and na: "a \<notin> span (S-{b})"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   926
  shows "b \<in> span (insert a (S - {b}))"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   927
  apply (rule in_span_insert)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   928
  apply (rule set_rev_mp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   929
  apply (rule a)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   930
  apply (rule span_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   931
  apply blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   932
  apply (rule na)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   933
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   934
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   935
text {* Transitivity property. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   936
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   937
lemma span_redundant: "x \<in> span S \<Longrightarrow> span (insert x S) = span S"
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   938
  unfolding span_def by (rule hull_redundant)
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   939
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   940
lemma span_trans:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   941
  assumes x: "x \<in> span S" and y: "y \<in> span (insert x S)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   942
  shows "y \<in> span S"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   943
  using assms by (simp only: span_redundant)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   944
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   945
lemma span_insert_0[simp]: "span (insert 0 S) = span S"
44521
083eedb37a37 simplify many proofs about subspace and span;
huffman
parents: 44517
diff changeset
   946
  by (simp only: span_redundant span_0)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   947
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   948
text {* An explicit expansion is sometimes needed. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   949
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   950
lemma span_explicit:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   951
  "span P = {y. \<exists>S u. finite S \<and> S \<subseteq> P \<and> setsum (\<lambda>v. u v *\<^sub>R v) S = y}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   952
  (is "_ = ?E" is "_ = {y. ?h y}" is "_ = {y. \<exists>S u. ?Q S u y}")
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   953
proof-
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   954
  { fix x assume x: "x \<in> ?E"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   955
    then obtain S u where fS: "finite S" and SP: "S\<subseteq>P" and u: "setsum (\<lambda>v. u v *\<^sub>R v) S = x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   956
      by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   957
    have "x \<in> span P"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   958
      unfolding u[symmetric]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   959
      apply (rule span_setsum[OF fS])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   960
      using span_mono[OF SP]
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   961
      apply (auto intro: span_superset span_mul)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   962
      done }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   963
  moreover
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   964
  have "\<forall>x \<in> span P. x \<in> ?E"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   965
  proof (rule span_induct_alt')
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   966
    show "0 \<in> Collect ?h"
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   967
      unfolding mem_Collect_eq
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   968
      apply (rule exI[where x="{}"])
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   969
      apply simp
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   970
      done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   971
  next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   972
    fix c x y
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   973
    assume x: "x \<in> P" and hy: "y \<in> Collect ?h"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   974
    from hy obtain S u where fS: "finite S" and SP: "S\<subseteq>P"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   975
      and u: "setsum (\<lambda>v. u v *\<^sub>R v) S = y" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   976
    let ?S = "insert x S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   977
    let ?u = "\<lambda>y. if y = x then (if x \<in> S then u y + c else c) else u y"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   978
    from fS SP x have th0: "finite (insert x S)" "insert x S \<subseteq> P" by blast+
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   979
    { assume xS: "x \<in> S"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   980
      have S1: "S = (S - {x}) \<union> {x}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   981
        and Sss:"finite (S - {x})" "finite {x}" "(S -{x}) \<inter> {x} = {}" using xS fS by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   982
      have "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S =(\<Sum>v\<in>S - {x}. u v *\<^sub>R v) + (u x + c) *\<^sub>R x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   983
        using xS
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   984
        by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   985
          setsum_clauses(2)[OF fS] cong del: if_weak_cong)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   986
      also have "\<dots> = (\<Sum>v\<in>S. u v *\<^sub>R v) + c *\<^sub>R x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   987
        apply (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   988
        apply (simp add: algebra_simps)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   989
        done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   990
      also have "\<dots> = c*\<^sub>R x + y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   991
        by (simp add: add_commute u)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   992
      finally have "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S = c*\<^sub>R x + y" .
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   993
    then have "?Q ?S ?u (c*\<^sub>R x + y)" using th0 by blast }
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   994
    moreover
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   995
    { assume xS: "x \<notin> S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   996
      have th00: "(\<Sum>v\<in>S. (if v = x then c else u v) *\<^sub>R v) = y"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   997
        unfolding u[symmetric]
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   998
        apply (rule setsum_cong2)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   999
        using xS apply auto
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1000
        done
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1001
      have "?Q ?S ?u (c*\<^sub>R x + y)" using fS xS th0
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1002
        by (simp add: th00 setsum_clauses add_commute cong del: if_weak_cong) }
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1003
    ultimately have "?Q ?S ?u (c*\<^sub>R x + y)" by (cases "x \<in> S") simp_all
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
  1004
    then show "(c*\<^sub>R x + y) \<in> Collect ?h"
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
  1005
      unfolding mem_Collect_eq
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1006
      apply -
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1007
      apply (rule exI[where x="?S"])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1008
      apply (rule exI[where x="?u"])
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1009
      apply metis
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1010
      done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1011
  qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1012
  ultimately show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1013
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1014
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1015
lemma dependent_explicit:
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1016
  "dependent P \<longleftrightarrow> (\<exists>S u. finite S \<and> S \<subseteq> P \<and> (\<exists>v\<in>S. u v \<noteq> 0 \<and> setsum (\<lambda>v. u v *\<^sub>R v) S = 0))"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1017
  (is "?lhs = ?rhs")
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1018
proof -
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1019
  { assume dP: "dependent P"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1020
    then obtain a S u where aP: "a \<in> P" and fS: "finite S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1021
      and SP: "S \<subseteq> P - {a}" and ua: "setsum (\<lambda>v. u v *\<^sub>R v) S = a"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1022
      unfolding dependent_def span_explicit by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1023
    let ?S = "insert a S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1024
    let ?u = "\<lambda>y. if y = a then - 1 else u y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1025
    let ?v = a
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1026
    from aP SP have aS: "a \<notin> S" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1027
    from fS SP aP have th0: "finite ?S" "?S \<subseteq> P" "?v \<in> ?S" "?u ?v \<noteq> 0" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1028
    have s0: "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S = 0"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1029
      using fS aS
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1030
      apply (simp add: setsum_clauses field_simps)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1031
      apply (subst (2) ua[symmetric])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1032
      apply (rule setsum_cong2)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1033
      apply auto
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1034
      done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1035
    with th0 have ?rhs
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1036
      apply -
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1037
      apply (rule exI[where x= "?S"])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1038
      apply (rule exI[where x= "?u"])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1039
      apply auto
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1040
      done
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1041
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1042
  moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1043
  { fix S u v
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1044
    assume fS: "finite S"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1045
      and SP: "S \<subseteq> P" and vS: "v \<in> S" and uv: "u v \<noteq> 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1046
      and u: "setsum (\<lambda>v. u v *\<^sub>R v) S = 0"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1047
    let ?a = v
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1048
    let ?S = "S - {v}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1049
    let ?u = "\<lambda>i. (- u i) / u v"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1050
    have th0: "?a \<in> P" "finite ?S" "?S \<subseteq> P" using fS SP vS by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1051
    have "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S = setsum (\<lambda>v. (- (inverse (u ?a))) *\<^sub>R (u v *\<^sub>R v)) S - ?u v *\<^sub>R v"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1052
      using fS vS uv by (simp add: setsum_diff1 divide_inverse field_simps)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1053
    also have "\<dots> = ?a" unfolding scaleR_right.setsum [symmetric] u using uv by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1054
    finally  have "setsum (\<lambda>v. ?u v *\<^sub>R v) ?S = ?a" .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1055
    with th0 have ?lhs
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1056
      unfolding dependent_def span_explicit
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1057
      apply -
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1058
      apply (rule bexI[where x= "?a"])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1059
      apply (simp_all del: scaleR_minus_left)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1060
      apply (rule exI[where x= "?S"])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1061
      apply (auto simp del: scaleR_minus_left)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1062
      done
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1063
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1064
  ultimately show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1065
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1066
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1067
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1068
lemma span_finite:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1069
  assumes fS: "finite S"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1070
  shows "span S = {y. \<exists>u. setsum (\<lambda>v. u v *\<^sub>R v) S = y}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1071
  (is "_ = ?rhs")
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1072
proof -
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1073
  { fix y assume y: "y \<in> span S"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1074
    from y obtain S' u where fS': "finite S'" and SS': "S' \<subseteq> S" and
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1075
      u: "setsum (\<lambda>v. u v *\<^sub>R v) S' = y" unfolding span_explicit by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1076
    let ?u = "\<lambda>x. if x \<in> S' then u x else 0"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1077
    have "setsum (\<lambda>v. ?u v *\<^sub>R v) S = setsum (\<lambda>v. u v *\<^sub>R v) S'"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1078
      using SS' fS by (auto intro!: setsum_mono_zero_cong_right)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1079
    then have "setsum (\<lambda>v. ?u v *\<^sub>R v) S = y" by (metis u)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1080
    then have "y \<in> ?rhs" by auto }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1081
  moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1082
  { fix y u
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1083
    assume u: "setsum (\<lambda>v. u v *\<^sub>R v) S = y"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1084
    then have "y \<in> span S" using fS unfolding span_explicit by auto }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1085
  ultimately show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1086
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1087
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1088
text {* This is useful for building a basis step-by-step. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1089
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1090
lemma independent_insert:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1091
  "independent(insert a S) \<longleftrightarrow>
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1092
      (if a \<in> S then independent S
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1093
                else independent S \<and> a \<notin> span S)" (is "?lhs \<longleftrightarrow> ?rhs")
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1094
proof -
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1095
  { assume aS: "a \<in> S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1096
    then have ?thesis using insert_absorb[OF aS] by simp }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1097
  moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1098
  { assume aS: "a \<notin> S"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1099
    { assume i: ?lhs
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1100
      then have ?rhs using aS
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1101
        apply simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1102
        apply (rule conjI)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1103
        apply (rule independent_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1104
        apply assumption
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1105
        apply blast
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1106
        apply (simp add: dependent_def)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1107
        done }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1108
    moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1109
    { assume i: ?rhs
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1110
      have ?lhs using i aS
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1111
        apply simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1112
        apply (auto simp add: dependent_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1113
        apply (case_tac "aa = a", auto)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1114
        apply (subgoal_tac "insert a S - {aa} = insert a (S - {aa})")
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1115
        apply simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1116
        apply (subgoal_tac "a \<in> span (insert aa (S - {aa}))")
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1117
        apply (subgoal_tac "insert aa (S - {aa}) = S")
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1118
        apply simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1119
        apply blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1120
        apply (rule in_span_insert)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1121
        apply assumption
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1122
        apply blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1123
        apply blast
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1124
        done }
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1125
    ultimately have ?thesis by blast }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1126
  ultimately show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1127
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1128
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1129
text {* The degenerate case of the Exchange Lemma. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1130
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1131
lemma mem_delete: "x \<in> (A - {a}) \<longleftrightarrow> x \<noteq> a \<and> x \<in> A"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1132
  by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1134
lemma spanning_subset_independent:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1135
  assumes BA: "B \<subseteq> A" and iA: "independent A"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1136
    and AsB: "A \<subseteq> span B"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1137
  shows "A = B"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1138
proof
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1139
  from BA show "B \<subseteq> A" .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1140
next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1141
  from span_mono[OF BA] span_mono[OF AsB]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1142
  have sAB: "span A = span B" unfolding span_span by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1143
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1144
  { fix x assume x: "x \<in> A"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1145
    from iA have th0: "x \<notin> span (A - {x})"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1146
      unfolding dependent_def using x by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1147
    from x have xsA: "x \<in> span A" by (blast intro: span_superset)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1148
    have "A - {x} \<subseteq> A" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1149
    hence th1:"span (A - {x}) \<subseteq> span A" by (metis span_mono)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1150
    { assume xB: "x \<notin> B"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1151
      from xB BA have "B \<subseteq> A -{x}" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1152
      hence "span B \<subseteq> span (A - {x})" by (metis span_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1153
      with th1 th0 sAB have "x \<notin> span A" by blast
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1154
      with x have False by (metis span_superset) }
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1155
    then have "x \<in> B" by blast }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1156
  then show "A \<subseteq> B" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1157
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1158
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1159
text {* The general case of the Exchange Lemma, the key to what follows. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1160
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1161
lemma exchange_lemma:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1162
  assumes f:"finite t" and i: "independent s"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1163
    and sp:"s \<subseteq> span t"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1164
  shows "\<exists>t'. (card t' = card t) \<and> finite t' \<and> s \<subseteq> t' \<and> t' \<subseteq> s \<union> t \<and> s \<subseteq> span t'"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1165
using f i sp
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1166
proof (induct "card (t - s)" arbitrary: s t rule: less_induct)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1167
  case less
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1168
  note ft = `finite t` and s = `independent s` and sp = `s \<subseteq> span t`
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1169
  let ?P = "\<lambda>t'. (card t' = card t) \<and> finite t' \<and> s \<subseteq> t' \<and> t' \<subseteq> s \<union> t \<and> s \<subseteq> span t'"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1170
  let ?ths = "\<exists>t'. ?P t'"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1171
  { assume st: "s \<subseteq> t"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1172
    from st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1173
      apply (auto intro: span_superset)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1174
      done }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1175
  moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1176
  { assume st: "t \<subseteq> s"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1177
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1178
    from spanning_subset_independent[OF st s sp]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1179
      st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1180
      apply (auto intro: span_superset)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1181
      done }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1182
  moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1183
  { assume st: "\<not> s \<subseteq> t" "\<not> t \<subseteq> s"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1184
    from st(2) obtain b where b: "b \<in> t" "b \<notin> s" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1185
      from b have "t - {b} - s \<subset> t - s" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1186
      then have cardlt: "card (t - {b} - s) < card (t - s)" using ft
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1187
        by (auto intro: psubset_card_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1188
      from b ft have ct0: "card t \<noteq> 0" by auto
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1189
    { assume stb: "s \<subseteq> span(t -{b})"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1190
      from ft have ftb: "finite (t -{b})" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1191
      from less(1)[OF cardlt ftb s stb]
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1192
      obtain u where u: "card u = card (t-{b})" "s \<subseteq> u" "u \<subseteq> s \<union> (t - {b})" "s \<subseteq> span u"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1193
        and fu: "finite u" by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1194
      let ?w = "insert b u"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1195
      have th0: "s \<subseteq> insert b u" using u by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1196
      from u(3) b have "u \<subseteq> s \<union> t" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1197
      then have th1: "insert b u \<subseteq> s \<union> t" using u b by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1198
      have bu: "b \<notin> u" using b u by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1199
      from u(1) ft b have "card u = (card t - 1)" by auto
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1200
      then have th2: "card (insert b u) = card t"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1201
        using card_insert_disjoint[OF fu bu] ct0 by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1202
      from u(4) have "s \<subseteq> span u" .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1203
      also have "\<dots> \<subseteq> span (insert b u)" apply (rule span_mono) by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1204
      finally have th3: "s \<subseteq> span (insert b u)" .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1205
      from th0 th1 th2 th3 fu have th: "?P ?w"  by blast
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1206
      from th have ?ths by blast }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1207
    moreover
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1208
    { assume stb: "\<not> s \<subseteq> span(t -{b})"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1209
      from stb obtain a where a: "a \<in> s" "a \<notin> span (t - {b})" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1210
      have ab: "a \<noteq> b" using a b by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1211
      have at: "a \<notin> t" using a ab span_superset[of a "t- {b}"] by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1212
      have mlt: "card ((insert a (t - {b})) - s) < card (t - s)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1213
        using cardlt ft a b by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1214
      have ft': "finite (insert a (t - {b}))" using ft by auto
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1215
      { fix x assume xs: "x \<in> s"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1216
        have t: "t \<subseteq> (insert b (insert a (t -{b})))" using b by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1217
        from b(1) have "b \<in> span t" by (simp add: span_superset)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1218
        have bs: "b \<in> span (insert a (t - {b}))" apply(rule in_span_delete)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1219
          using a sp unfolding subset_eq apply auto done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1220
        from xs sp have "x \<in> span t" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1221
        with span_mono[OF t]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1222
        have x: "x \<in> span (insert b (insert a (t - {b})))" ..
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1223
        from span_trans[OF bs x] have "x \<in> span (insert a (t - {b}))" . }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1224
      then have sp': "s \<subseteq> span (insert a (t - {b}))" by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1225
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1226
      from less(1)[OF mlt ft' s sp'] obtain u where
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1227
        u: "card u = card (insert a (t -{b}))" "finite u" "s \<subseteq> u" "u \<subseteq> s \<union> insert a (t -{b})"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1228
          "s \<subseteq> span u" by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1229
      from u a b ft at ct0 have "?P u" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1230
      then have ?ths by blast }
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1231
    ultimately have ?ths by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1232
  }
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1233
  ultimately show ?ths by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1234
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1235
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1236
text {* This implies corresponding size bounds. *}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1237
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1238
lemma independent_span_bound:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1239
  assumes f: "finite t" and i: "independent s" and sp:"s \<subseteq> span t"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1240
  shows "finite s \<and> card s \<le> card t"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1241
  by (metis exchange_lemma[OF f i sp] finite_subset card_mono)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1242
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1243
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1244
lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x\<in> (UNIV::'a::finite set)}"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1245
proof -
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1246
  have eq: "{f x |x. x\<in> UNIV} = f ` UNIV" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1247
  show ?thesis unfolding eq
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1248
    apply (rule finite_imageI)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1249
    apply (rule finite)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1250
    done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1251
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1252
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1253
subsection{* Euclidean Spaces as Typeclass*}
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1254
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1255
lemma independent_eq_inj_on:
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1256
  fixes D :: nat and f :: "nat \<Rightarrow> 'c::real_vector"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1257
  assumes *: "inj_on f {..<D}"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1258
  shows "independent (f ` {..<D}) \<longleftrightarrow> (\<forall>a u. a < D \<longrightarrow> (\<Sum>i\<in>{..<D}-{a}. u (f i) *\<^sub>R f i) \<noteq> f a)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1259
proof -
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1260
  from * have eq: "\<And>i. i < D \<Longrightarrow> f ` {..<D} - {f i} = f`({..<D} - {i})"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1261
    and inj: "\<And>i. inj_on f ({..<D} - {i})"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1262
    by (auto simp: inj_on_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1263
  have *: "\<And>i. finite (f ` {..<D} - {i})" by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1264
  show ?thesis unfolding dependent_def span_finite[OF *]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1265
    by (auto simp: eq setsum_reindex[OF inj])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1266
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1267
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1268
lemma independent_basis:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1269
  "independent (basis ` {..<DIM('a)} :: 'a::euclidean_space set)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1270
  unfolding independent_eq_inj_on [OF basis_inj]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1271
  apply clarify
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1272
  apply (drule_tac f="inner (basis a)" in arg_cong)
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  1273
  apply (simp add: inner_setsum_right dot_basis)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1274
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1275
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1276
lemma (in euclidean_space) range_basis:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1277
    "range basis = insert 0 (basis ` {..<DIM('a)})"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1278
proof -
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1279
  have *: "UNIV = {..<DIM('a)} \<union> {DIM('a)..}" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents: