src/HOL/Multivariate_Analysis/Euclidean_Space.thy
author himmelma
Tue, 02 Mar 2010 21:32:37 +0100
changeset 35542 8f97d8caabfd
parent 35541 7b1179be2ac5
child 36309 4da07afb065b
permissions -rw-r--r--
replaced \<bullet> with inner
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
     1
(*  Title:      Library/Multivariate_Analysis/Euclidean_Space.thy
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     2
    Author:     Amine Chaieb, University of Cambridge
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     3
*)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     4
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     5
header {* (Real) Vectors in Euclidean space, and elementary linear algebra.*}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     6
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     7
theory Euclidean_Space
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     8
imports
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
     9
  Complex_Main "~~/src/HOL/Decision_Procs/Dense_Linear_Order"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    10
  Finite_Cartesian_Product Glbs Infinite_Set Numeral_Type
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    11
  Inner_Product
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    12
uses "positivstellensatz.ML" ("normarith.ML")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    13
begin
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    14
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    15
text{* Some common special cases.*}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    16
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
    17
lemma forall_1[simp]: "(\<forall>i::1. P i) \<longleftrightarrow> P 1"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    18
  by (metis num1_eq_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    19
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
    20
lemma ex_1[simp]: "(\<exists>x::1. P x) \<longleftrightarrow> P 1"
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
    21
  by auto (metis num1_eq_iff)
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
    22
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    23
lemma exhaust_2:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    24
  fixes x :: 2 shows "x = 1 \<or> x = 2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    25
proof (induct x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    26
  case (of_int z)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    27
  then have "0 <= z" and "z < 2" by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    28
  then have "z = 0 | z = 1" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    29
  then show ?case by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    30
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    31
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    32
lemma forall_2: "(\<forall>i::2. P i) \<longleftrightarrow> P 1 \<and> P 2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    33
  by (metis exhaust_2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    34
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    35
lemma exhaust_3:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    36
  fixes x :: 3 shows "x = 1 \<or> x = 2 \<or> x = 3"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    37
proof (induct x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    38
  case (of_int z)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    39
  then have "0 <= z" and "z < 3" by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    40
  then have "z = 0 \<or> z = 1 \<or> z = 2" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    41
  then show ?case by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    42
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    43
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    44
lemma forall_3: "(\<forall>i::3. P i) \<longleftrightarrow> P 1 \<and> P 2 \<and> P 3"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    45
  by (metis exhaust_3)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    46
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    47
lemma UNIV_1: "UNIV = {1::1}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    48
  by (auto simp add: num1_eq_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    49
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    50
lemma UNIV_2: "UNIV = {1::2, 2::2}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    51
  using exhaust_2 by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    52
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    53
lemma UNIV_3: "UNIV = {1::3, 2::3, 3::3}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    54
  using exhaust_3 by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    55
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    56
lemma setsum_1: "setsum f (UNIV::1 set) = f 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    57
  unfolding UNIV_1 by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    58
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    59
lemma setsum_2: "setsum f (UNIV::2 set) = f 1 + f 2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    60
  unfolding UNIV_2 by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    61
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    62
lemma setsum_3: "setsum f (UNIV::3 set) = f 1 + f 2 + f 3"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    63
  unfolding UNIV_3 by (simp add: add_ac)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    64
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    65
subsection{* Basic componentwise operations on vectors. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    66
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
    67
instantiation cart :: (plus,finite) plus
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    68
begin
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    69
  definition  vector_add_def : "op + \<equiv> (\<lambda> x y.  (\<chi> i. (x$i) + (y$i)))"
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    70
  instance ..
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    71
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    72
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
    73
instantiation cart :: (times,finite) times
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    74
begin
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    75
  definition vector_mult_def : "op * \<equiv> (\<lambda> x y.  (\<chi> i. (x$i) * (y$i)))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    76
  instance ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    77
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    78
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    79
instantiation cart :: (minus,finite) minus
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    80
begin
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    81
  definition vector_minus_def : "op - \<equiv> (\<lambda> x y.  (\<chi> i. (x$i) - (y$i)))"
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    82
  instance ..
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    83
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    84
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    85
instantiation cart :: (uminus,finite) uminus
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    86
begin
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    87
  definition vector_uminus_def : "uminus \<equiv> (\<lambda> x.  (\<chi> i. - (x$i)))"
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    88
  instance ..
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    89
end
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
    90
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    91
instantiation cart :: (zero,finite) zero
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    92
begin
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    93
  definition vector_zero_def : "0 \<equiv> (\<chi> i. 0)"
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    94
  instance ..
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    95
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    96
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    97
instantiation cart :: (one,finite) one
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
    98
begin
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
    99
  definition vector_one_def : "1 \<equiv> (\<chi> i. 1)"
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
   100
  instance ..
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   101
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   102
35540
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   103
instantiation cart :: (scaleR, finite) scaleR
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   104
begin
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   105
  definition vector_scaleR_def: "scaleR = (\<lambda> r x.  (\<chi> i. scaleR r (x$i)))"
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   106
  instance ..
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   107
end
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   108
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   109
instantiation cart :: (ord,finite) ord
35253
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
   110
begin
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
   111
  definition vector_le_def:
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
   112
    "less_eq (x :: 'a ^'b) y = (ALL i. x$i <= y$i)"
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
   113
  definition vector_less_def: "less (x :: 'a ^'b) y = (ALL i. x$i < y$i)"
68dd8b51c6b8 tuned headers;
wenzelm
parents: 35172
diff changeset
   114
  instance by (intro_classes)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   115
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   116
35540
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   117
text{* The ordering on real^1 is linear. *}
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   118
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   119
class cart_one = assumes UNIV_one: "card (UNIV \<Colon> 'a set) = Suc 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   120
begin
35540
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   121
  subclass finite
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   122
  proof from UNIV_one show "finite (UNIV :: 'a set)"
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   123
      by (auto intro!: card_ge_0_finite) qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   124
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   125
35540
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   126
instantiation num1 :: cart_one begin
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   127
instance proof
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   128
  show "CARD(1) = Suc 0" by auto
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   129
qed end
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   130
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   131
instantiation cart :: (linorder,cart_one) linorder begin
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   132
instance proof
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   133
  guess a B using UNIV_one[where 'a='b] unfolding card_Suc_eq apply- by(erule exE)+
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   134
  hence *:"UNIV = {a}" by auto
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   135
  have "\<And>P. (\<forall>i\<in>UNIV. P i) \<longleftrightarrow> P a" unfolding * by auto hence all:"\<And>P. (\<forall>i. P i) \<longleftrightarrow> P a" by auto
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   136
  fix x y z::"'a^'b::cart_one" note * = vector_le_def vector_less_def all Cart_eq
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   137
  show "x\<le>x" "(x < y) = (x \<le> y \<and> \<not> y \<le> x)" "x\<le>y \<or> y\<le>x" unfolding * by(auto simp only:field_simps)
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   138
  { assume "x\<le>y" "y\<le>z" thus "x\<le>z" unfolding * by(auto simp only:field_simps) }
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   139
  { assume "x\<le>y" "y\<le>x" thus "x=y" unfolding * by(auto simp only:field_simps) }
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   140
qed end
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35253
diff changeset
   141
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   142
text{* Also the scalar-vector multiplication. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   143
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   144
definition vector_scalar_mult:: "'a::times \<Rightarrow> 'a ^ 'n \<Rightarrow> 'a ^ 'n" (infixl "*s" 70)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   145
  where "c *s x = (\<chi> i. c * (x$i))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   146
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   147
text{* Constant Vectors *} 
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   148
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   149
definition "vec x = (\<chi> i. x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   150
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   151
subsection {* A naive proof procedure to lift really trivial arithmetic stuff from the basis of the vector space. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   152
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   153
method_setup vector = {*
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   154
let
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
   155
  val ss1 = HOL_basic_ss addsimps [@{thm setsum_addf} RS sym,
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   156
  @{thm setsum_subtractf} RS sym, @{thm setsum_right_distrib},
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   157
  @{thm setsum_left_distrib}, @{thm setsum_negf} RS sym]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   158
  val ss2 = @{simpset} addsimps
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   159
             [@{thm vector_add_def}, @{thm vector_mult_def},
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   160
              @{thm vector_minus_def}, @{thm vector_uminus_def},
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   161
              @{thm vector_one_def}, @{thm vector_zero_def}, @{thm vec_def},
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   162
              @{thm vector_scaleR_def},
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   163
              @{thm Cart_lambda_beta}, @{thm vector_scalar_mult_def}]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   164
 fun vector_arith_tac ths =
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   165
   simp_tac ss1
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   166
   THEN' (fn i => rtac @{thm setsum_cong2} i
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   167
         ORELSE rtac @{thm setsum_0'} i
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   168
         ORELSE simp_tac (HOL_basic_ss addsimps [@{thm "Cart_eq"}]) i)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   169
   (* THEN' TRY o clarify_tac HOL_cs  THEN' (TRY o rtac @{thm iffI}) *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   170
   THEN' asm_full_simp_tac (ss2 addsimps ths)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   171
 in
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   172
  Attrib.thms >> (fn ths => K (SIMPLE_METHOD' (vector_arith_tac ths)))
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   173
 end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   174
*} "Lifts trivial vector statements to real arith statements"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   176
lemma vec_0[simp]: "vec 0 = 0" by (vector vector_zero_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   177
lemma vec_1[simp]: "vec 1 = 1" by (vector vector_one_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   178
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   179
text{* Obvious "component-pushing". *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   180
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   181
lemma vec_component [simp]: "vec x $ i = x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   182
  by (vector vec_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   183
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   184
lemma vector_add_component [simp]: "(x + y)$i = x$i + y$i"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   185
  by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   186
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   187
lemma vector_minus_component [simp]: "(x - y)$i = x$i - y$i"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   188
  by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   189
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   190
lemma vector_mult_component [simp]: "(x * y)$i = x$i * y$i"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   191
  by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   192
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   193
lemma vector_smult_component [simp]: "(c *s y)$i = c * (y$i)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   194
  by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   195
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   196
lemma vector_uminus_component [simp]: "(- x)$i = - (x$i)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   197
  by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   198
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   199
lemma vector_scaleR_component [simp]: "(scaleR r x)$i = scaleR r (x$i)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   200
  by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   201
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   202
lemma cond_component: "(if b then x else y)$i = (if b then x$i else y$i)" by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   203
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   204
lemmas vector_component =
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   205
  vec_component vector_add_component vector_mult_component
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   206
  vector_smult_component vector_minus_component vector_uminus_component
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   207
  vector_scaleR_component cond_component
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   208
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   209
subsection {* Some frequently useful arithmetic lemmas over vectors. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   210
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   211
instance cart :: (semigroup_add,finite) semigroup_add
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   212
  apply (intro_classes) by (vector add_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   213
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   214
instance cart :: (monoid_add,finite) monoid_add
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   215
  apply (intro_classes) by vector+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   216
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   217
instance cart :: (group_add,finite) group_add
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   218
  apply (intro_classes) by (vector algebra_simps)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   219
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   220
instance cart :: (ab_semigroup_add,finite) ab_semigroup_add
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   221
  apply (intro_classes) by (vector add_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   222
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   223
instance cart :: (comm_monoid_add,finite) comm_monoid_add
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   224
  apply (intro_classes) by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   225
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   226
instance cart :: (ab_group_add,finite) ab_group_add
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   227
  apply (intro_classes) by vector+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   228
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   229
instance cart :: (cancel_semigroup_add,finite) cancel_semigroup_add
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   230
  apply (intro_classes)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   231
  by (vector Cart_eq)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   232
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   233
instance cart :: (cancel_ab_semigroup_add,finite) cancel_ab_semigroup_add
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   234
  apply (intro_classes)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   235
  by (vector Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   236
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   237
instance cart :: (real_vector, finite) real_vector
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   238
  by default (vector scaleR_left_distrib scaleR_right_distrib)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   239
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   240
instance cart :: (semigroup_mult,finite) semigroup_mult
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   241
  apply (intro_classes) by (vector mult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   242
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   243
instance cart :: (monoid_mult,finite) monoid_mult
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   244
  apply (intro_classes) by vector+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   245
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   246
instance cart :: (ab_semigroup_mult,finite) ab_semigroup_mult
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   247
  apply (intro_classes) by (vector mult_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   248
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   249
instance cart :: (ab_semigroup_idem_mult,finite) ab_semigroup_idem_mult
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   250
  apply (intro_classes) by (vector mult_idem)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   251
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   252
instance cart :: (comm_monoid_mult,finite) comm_monoid_mult
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   253
  apply (intro_classes) by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   254
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   255
fun vector_power where
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   256
  "vector_power x 0 = 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   257
  | "vector_power x (Suc n) = x * vector_power x n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   258
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   259
instance cart :: (semiring,finite) semiring
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   260
  apply (intro_classes) by (vector ring_simps)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   261
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   262
instance cart :: (semiring_0,finite) semiring_0
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   263
  apply (intro_classes) by (vector ring_simps)+
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   264
instance cart :: (semiring_1,finite) semiring_1
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   265
  apply (intro_classes) by vector
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   266
instance cart :: (comm_semiring,finite) comm_semiring
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   267
  apply (intro_classes) by (vector ring_simps)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   268
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   269
instance cart :: (comm_semiring_0,finite) comm_semiring_0 by (intro_classes)
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   270
instance cart :: (cancel_comm_monoid_add, finite) cancel_comm_monoid_add ..
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   271
instance cart :: (semiring_0_cancel,finite) semiring_0_cancel by (intro_classes)
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   272
instance cart :: (comm_semiring_0_cancel,finite) comm_semiring_0_cancel by (intro_classes)
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   273
instance cart :: (ring,finite) ring by (intro_classes)
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   274
instance cart :: (semiring_1_cancel,finite) semiring_1_cancel by (intro_classes)
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   275
instance cart :: (comm_semiring_1,finite) comm_semiring_1 by (intro_classes)
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   276
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   277
instance cart :: (ring_1,finite) ring_1 ..
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   278
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   279
instance cart :: (real_algebra,finite) real_algebra
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   280
  apply intro_classes
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   281
  apply (simp_all add: vector_scaleR_def ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   282
  apply vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   283
  apply vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   284
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   285
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   286
instance cart :: (real_algebra_1,finite) real_algebra_1 ..
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   287
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   288
lemma of_nat_index:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   289
  "(of_nat n :: 'a::semiring_1 ^'n)$i = of_nat n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   290
  apply (induct n)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   291
  apply vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   292
  apply vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   293
  done
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   294
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   295
lemma zero_index[simp]:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   296
  "(0 :: 'a::zero ^'n)$i = 0" by vector
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   297
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   298
lemma one_index[simp]:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   299
  "(1 :: 'a::one ^'n)$i = 1" by vector
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   300
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   301
lemma one_plus_of_nat_neq_0: "(1::'a::semiring_char_0) + of_nat n \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   302
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   303
  have "(1::'a) + of_nat n = 0 \<longleftrightarrow> of_nat 1 + of_nat n = (of_nat 0 :: 'a)" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   304
  also have "\<dots> \<longleftrightarrow> 1 + n = 0" by (simp only: of_nat_add[symmetric] of_nat_eq_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   305
  finally show ?thesis by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   306
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   307
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   308
instance cart :: (semiring_char_0,finite) semiring_char_0
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   309
proof (intro_classes)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   310
  fix m n ::nat
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   311
  show "(of_nat m :: 'a^'b) = of_nat n \<longleftrightarrow> m = n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   312
    by (simp add: Cart_eq of_nat_index)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   313
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   314
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   315
instance cart :: (comm_ring_1,finite) comm_ring_1 by intro_classes
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   316
instance cart :: (ring_char_0,finite) ring_char_0 by intro_classes
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   317
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   318
lemma vector_smult_assoc: "a *s (b *s x) = ((a::'a::semigroup_mult) * b) *s x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   319
  by (vector mult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   320
lemma vector_sadd_rdistrib: "((a::'a::semiring) + b) *s x = a *s x + b *s x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   321
  by (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   322
lemma vector_add_ldistrib: "(c::'a::semiring) *s (x + y) = c *s x + c *s y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   323
  by (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   324
lemma vector_smult_lzero[simp]: "(0::'a::mult_zero) *s x = 0" by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   325
lemma vector_smult_lid[simp]: "(1::'a::monoid_mult) *s x = x" by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   326
lemma vector_ssub_ldistrib: "(c::'a::ring) *s (x - y) = c *s x - c *s y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   327
  by (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   328
lemma vector_smult_rneg: "(c::'a::ring) *s -x = -(c *s x)" by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   329
lemma vector_smult_lneg: "- (c::'a::ring) *s x = -(c *s x)" by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   330
lemma vector_sneg_minus1: "-x = (- (1::'a::ring_1)) *s x" by vector
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   331
lemma vector_smult_rzero[simp]: "c *s 0 = (0::'a::mult_zero ^ 'n)" by vector
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   332
lemma vector_sub_rdistrib: "((a::'a::ring) - b) *s x = a *s x - b *s x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   333
  by (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   334
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   335
lemma vec_eq[simp]: "(vec m = vec n) \<longleftrightarrow> (m = n)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   336
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   337
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   338
subsection {* Topological space *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   339
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   340
instantiation cart :: (topological_space, finite) topological_space
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   341
begin
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   342
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   343
definition open_vector_def:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   344
  "open (S :: ('a ^ 'b) set) \<longleftrightarrow>
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   345
    (\<forall>x\<in>S. \<exists>A. (\<forall>i. open (A i) \<and> x$i \<in> A i) \<and>
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   346
      (\<forall>y. (\<forall>i. y$i \<in> A i) \<longrightarrow> y \<in> S))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   347
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   348
instance proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   349
  show "open (UNIV :: ('a ^ 'b) set)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   350
    unfolding open_vector_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   351
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   352
  fix S T :: "('a ^ 'b) set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   353
  assume "open S" "open T" thus "open (S \<inter> T)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   354
    unfolding open_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   355
    apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   356
    apply (drule (1) bspec)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   357
    apply (clarify, rename_tac Sa Ta)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   358
    apply (rule_tac x="\<lambda>i. Sa i \<inter> Ta i" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   359
    apply (simp add: open_Int)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   360
    done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   361
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   362
  fix K :: "('a ^ 'b) set set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   363
  assume "\<forall>S\<in>K. open S" thus "open (\<Union>K)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   364
    unfolding open_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   365
    apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   366
    apply (drule (1) bspec)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   367
    apply (drule (1) bspec)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   368
    apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   369
    apply (rule_tac x=A in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   370
    apply fast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   371
    done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   372
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   373
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   374
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   375
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   376
lemma open_vector_box: "\<forall>i. open (S i) \<Longrightarrow> open {x. \<forall>i. x $ i \<in> S i}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   377
unfolding open_vector_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   378
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   379
lemma open_vimage_Cart_nth: "open S \<Longrightarrow> open ((\<lambda>x. x $ i) -` S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   380
unfolding open_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   381
apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   382
apply (rule_tac x="\<lambda>k. if k = i then S else UNIV" in exI, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   383
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   384
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   385
lemma closed_vimage_Cart_nth: "closed S \<Longrightarrow> closed ((\<lambda>x. x $ i) -` S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   386
unfolding closed_open vimage_Compl [symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   387
by (rule open_vimage_Cart_nth)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   388
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   389
lemma closed_vector_box: "\<forall>i. closed (S i) \<Longrightarrow> closed {x. \<forall>i. x $ i \<in> S i}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   390
proof -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   391
  have "{x. \<forall>i. x $ i \<in> S i} = (\<Inter>i. (\<lambda>x. x $ i) -` S i)" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   392
  thus "\<forall>i. closed (S i) \<Longrightarrow> closed {x. \<forall>i. x $ i \<in> S i}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   393
    by (simp add: closed_INT closed_vimage_Cart_nth)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   394
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   395
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   396
lemma tendsto_Cart_nth [tendsto_intros]:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   397
  assumes "((\<lambda>x. f x) ---> a) net"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   398
  shows "((\<lambda>x. f x $ i) ---> a $ i) net"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   399
proof (rule topological_tendstoI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   400
  fix S assume "open S" "a $ i \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   401
  then have "open ((\<lambda>y. y $ i) -` S)" "a \<in> ((\<lambda>y. y $ i) -` S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   402
    by (simp_all add: open_vimage_Cart_nth)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   403
  with assms have "eventually (\<lambda>x. f x \<in> (\<lambda>y. y $ i) -` S) net"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   404
    by (rule topological_tendstoD)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   405
  then show "eventually (\<lambda>x. f x $ i \<in> S) net"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   406
    by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   407
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   408
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   409
subsection {* Square root of sum of squares *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   410
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   411
definition
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   412
  "setL2 f A = sqrt (\<Sum>i\<in>A. (f i)\<twosuperior>)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   413
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   414
lemma setL2_cong:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   415
  "\<lbrakk>A = B; \<And>x. x \<in> B \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> setL2 f A = setL2 g B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   416
  unfolding setL2_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   417
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   418
lemma strong_setL2_cong:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   419
  "\<lbrakk>A = B; \<And>x. x \<in> B =simp=> f x = g x\<rbrakk> \<Longrightarrow> setL2 f A = setL2 g B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   420
  unfolding setL2_def simp_implies_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   421
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   422
lemma setL2_infinite [simp]: "\<not> finite A \<Longrightarrow> setL2 f A = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   423
  unfolding setL2_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   424
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   425
lemma setL2_empty [simp]: "setL2 f {} = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   426
  unfolding setL2_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   427
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   428
lemma setL2_insert [simp]:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   429
  "\<lbrakk>finite F; a \<notin> F\<rbrakk> \<Longrightarrow>
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   430
    setL2 f (insert a F) = sqrt ((f a)\<twosuperior> + (setL2 f F)\<twosuperior>)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   431
  unfolding setL2_def by (simp add: setsum_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   432
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   433
lemma setL2_nonneg [simp]: "0 \<le> setL2 f A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   434
  unfolding setL2_def by (simp add: setsum_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   435
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   436
lemma setL2_0': "\<forall>a\<in>A. f a = 0 \<Longrightarrow> setL2 f A = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   437
  unfolding setL2_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   438
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   439
lemma setL2_constant: "setL2 (\<lambda>x. y) A = sqrt (of_nat (card A)) * \<bar>y\<bar>"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   440
  unfolding setL2_def by (simp add: real_sqrt_mult)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   441
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   442
lemma setL2_mono:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   443
  assumes "\<And>i. i \<in> K \<Longrightarrow> f i \<le> g i"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   444
  assumes "\<And>i. i \<in> K \<Longrightarrow> 0 \<le> f i"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   445
  shows "setL2 f K \<le> setL2 g K"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   446
  unfolding setL2_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   447
  by (simp add: setsum_nonneg setsum_mono power_mono prems)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   448
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   449
lemma setL2_strict_mono:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   450
  assumes "finite K" and "K \<noteq> {}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   451
  assumes "\<And>i. i \<in> K \<Longrightarrow> f i < g i"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   452
  assumes "\<And>i. i \<in> K \<Longrightarrow> 0 \<le> f i"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   453
  shows "setL2 f K < setL2 g K"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   454
  unfolding setL2_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   455
  by (simp add: setsum_strict_mono power_strict_mono assms)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   456
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   457
lemma setL2_right_distrib:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   458
  "0 \<le> r \<Longrightarrow> r * setL2 f A = setL2 (\<lambda>x. r * f x) A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   459
  unfolding setL2_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   460
  apply (simp add: power_mult_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   461
  apply (simp add: setsum_right_distrib [symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   462
  apply (simp add: real_sqrt_mult setsum_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   463
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   464
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   465
lemma setL2_left_distrib:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   466
  "0 \<le> r \<Longrightarrow> setL2 f A * r = setL2 (\<lambda>x. f x * r) A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   467
  unfolding setL2_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   468
  apply (simp add: power_mult_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   469
  apply (simp add: setsum_left_distrib [symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   470
  apply (simp add: real_sqrt_mult setsum_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   471
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   472
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   473
lemma setsum_nonneg_eq_0_iff:
35028
108662d50512 more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents: 34964
diff changeset
   474
  fixes f :: "'a \<Rightarrow> 'b::ordered_ab_group_add"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   475
  shows "\<lbrakk>finite A; \<forall>x\<in>A. 0 \<le> f x\<rbrakk> \<Longrightarrow> setsum f A = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   476
  apply (induct set: finite, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   477
  apply (simp add: add_nonneg_eq_0_iff setsum_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   478
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   479
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   480
lemma setL2_eq_0_iff: "finite A \<Longrightarrow> setL2 f A = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   481
  unfolding setL2_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   482
  by (simp add: setsum_nonneg setsum_nonneg_eq_0_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   483
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   484
lemma setL2_triangle_ineq:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   485
  shows "setL2 (\<lambda>i. f i + g i) A \<le> setL2 f A + setL2 g A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   486
proof (cases "finite A")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   487
  case False
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   488
  thus ?thesis by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   489
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   490
  case True
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   491
  thus ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   492
  proof (induct set: finite)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   493
    case empty
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   494
    show ?case by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   495
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   496
    case (insert x F)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   497
    hence "sqrt ((f x + g x)\<twosuperior> + (setL2 (\<lambda>i. f i + g i) F)\<twosuperior>) \<le>
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   498
           sqrt ((f x + g x)\<twosuperior> + (setL2 f F + setL2 g F)\<twosuperior>)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   499
      by (intro real_sqrt_le_mono add_left_mono power_mono insert
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   500
                setL2_nonneg add_increasing zero_le_power2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   501
    also have
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   502
      "\<dots> \<le> sqrt ((f x)\<twosuperior> + (setL2 f F)\<twosuperior>) + sqrt ((g x)\<twosuperior> + (setL2 g F)\<twosuperior>)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   503
      by (rule real_sqrt_sum_squares_triangle_ineq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   504
    finally show ?case
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   505
      using insert by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   506
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   507
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   508
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   509
lemma sqrt_sum_squares_le_sum:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   510
  "\<lbrakk>0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> sqrt (x\<twosuperior> + y\<twosuperior>) \<le> x + y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   511
  apply (rule power2_le_imp_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   512
  apply (simp add: power2_sum)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   513
  apply (simp add: mult_nonneg_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   514
  apply (simp add: add_nonneg_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   515
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   516
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   517
lemma setL2_le_setsum [rule_format]:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   518
  "(\<forall>i\<in>A. 0 \<le> f i) \<longrightarrow> setL2 f A \<le> setsum f A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   519
  apply (cases "finite A")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   520
  apply (induct set: finite)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   521
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   522
  apply clarsimp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   523
  apply (erule order_trans [OF sqrt_sum_squares_le_sum])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   524
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   525
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   526
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   527
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   528
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   529
lemma sqrt_sum_squares_le_sum_abs: "sqrt (x\<twosuperior> + y\<twosuperior>) \<le> \<bar>x\<bar> + \<bar>y\<bar>"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   530
  apply (rule power2_le_imp_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   531
  apply (simp add: power2_sum)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   532
  apply (simp add: mult_nonneg_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   533
  apply (simp add: add_nonneg_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   534
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   535
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   536
lemma setL2_le_setsum_abs: "setL2 f A \<le> (\<Sum>i\<in>A. \<bar>f i\<bar>)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   537
  apply (cases "finite A")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   538
  apply (induct set: finite)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   539
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   540
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   541
  apply (rule order_trans [OF sqrt_sum_squares_le_sum_abs])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   542
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   543
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   544
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   545
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   546
lemma setL2_mult_ineq_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   547
  fixes a b c d :: real
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   548
  shows "2 * (a * c) * (b * d) \<le> a\<twosuperior> * d\<twosuperior> + b\<twosuperior> * c\<twosuperior>"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   549
proof -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   550
  have "0 \<le> (a * d - b * c)\<twosuperior>" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   551
  also have "\<dots> = a\<twosuperior> * d\<twosuperior> + b\<twosuperior> * c\<twosuperior> - 2 * (a * d) * (b * c)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   552
    by (simp only: power2_diff power_mult_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   553
  also have "\<dots> = a\<twosuperior> * d\<twosuperior> + b\<twosuperior> * c\<twosuperior> - 2 * (a * c) * (b * d)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   554
    by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   555
  finally show "2 * (a * c) * (b * d) \<le> a\<twosuperior> * d\<twosuperior> + b\<twosuperior> * c\<twosuperior>"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   556
    by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   557
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   558
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   559
lemma setL2_mult_ineq: "(\<Sum>i\<in>A. \<bar>f i\<bar> * \<bar>g i\<bar>) \<le> setL2 f A * setL2 g A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   560
  apply (cases "finite A")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   561
  apply (induct set: finite)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   562
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   563
  apply (rule power2_le_imp_le, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   564
  apply (rule order_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   565
  apply (rule power_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   566
  apply (erule add_left_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   567
  apply (simp add: add_nonneg_nonneg mult_nonneg_nonneg setsum_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   568
  apply (simp add: power2_sum)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   569
  apply (simp add: power_mult_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   570
  apply (simp add: right_distrib left_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   571
  apply (rule ord_le_eq_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   572
  apply (rule setL2_mult_ineq_lemma)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   573
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   574
  apply (intro mult_nonneg_nonneg setL2_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   575
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   576
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   577
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   578
lemma member_le_setL2: "\<lbrakk>finite A; i \<in> A\<rbrakk> \<Longrightarrow> f i \<le> setL2 f A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   579
  apply (rule_tac s="insert i (A - {i})" and t="A" in subst)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   580
  apply fast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   581
  apply (subst setL2_insert)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   582
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   583
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   584
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   585
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   586
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   587
subsection {* Metric *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   588
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   589
(* TODO: move somewhere else *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   590
lemma finite_choice: "finite A \<Longrightarrow> \<forall>x\<in>A. \<exists>y. P x y \<Longrightarrow> \<exists>f. \<forall>x\<in>A. P x (f x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   591
apply (induct set: finite, simp_all)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   592
apply (clarify, rename_tac y)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   593
apply (rule_tac x="f(x:=y)" in exI, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   594
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   595
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   596
instantiation cart :: (metric_space, finite) metric_space
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   597
begin
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   598
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   599
definition dist_vector_def:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   600
  "dist (x::'a^'b) (y::'a^'b) = setL2 (\<lambda>i. dist (x$i) (y$i)) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   601
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   602
lemma dist_nth_le: "dist (x $ i) (y $ i) \<le> dist x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   603
unfolding dist_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   604
by (rule member_le_setL2) simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   605
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   606
instance proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   607
  fix x y :: "'a ^ 'b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   608
  show "dist x y = 0 \<longleftrightarrow> x = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   609
    unfolding dist_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   610
    by (simp add: setL2_eq_0_iff Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   611
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   612
  fix x y z :: "'a ^ 'b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   613
  show "dist x y \<le> dist x z + dist y z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   614
    unfolding dist_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   615
    apply (rule order_trans [OF _ setL2_triangle_ineq])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   616
    apply (simp add: setL2_mono dist_triangle2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   617
    done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   618
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   619
  (* FIXME: long proof! *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   620
  fix S :: "('a ^ 'b) set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   621
  show "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   622
    unfolding open_vector_def open_dist
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   623
    apply safe
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   624
     apply (drule (1) bspec)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   625
     apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   626
     apply (subgoal_tac "\<exists>e>0. \<forall>i y. dist y (x$i) < e \<longrightarrow> y \<in> A i")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   627
      apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   628
      apply (rule_tac x=e in exI, clarify)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   629
      apply (drule spec, erule mp, clarify)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   630
      apply (drule spec, drule spec, erule mp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   631
      apply (erule le_less_trans [OF dist_nth_le])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   632
     apply (subgoal_tac "\<forall>i\<in>UNIV. \<exists>e>0. \<forall>y. dist y (x$i) < e \<longrightarrow> y \<in> A i")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   633
      apply (drule finite_choice [OF finite], clarify)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   634
      apply (rule_tac x="Min (range f)" in exI, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   635
     apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   636
     apply (drule_tac x=i in spec, clarify)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   637
     apply (erule (1) bspec)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   638
    apply (drule (1) bspec, clarify)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   639
    apply (subgoal_tac "\<exists>r. (\<forall>i::'b. 0 < r i) \<and> e = setL2 r UNIV")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   640
     apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   641
     apply (rule_tac x="\<lambda>i. {y. dist y (x$i) < r i}" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   642
     apply (rule conjI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   643
      apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   644
      apply (rule conjI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   645
       apply (clarify, rename_tac y)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   646
       apply (rule_tac x="r i - dist y (x$i)" in exI, rule conjI, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   647
       apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   648
       apply (simp only: less_diff_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   649
       apply (erule le_less_trans [OF dist_triangle])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   650
      apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   651
     apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   652
     apply (drule spec, erule mp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   653
     apply (simp add: dist_vector_def setL2_strict_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   654
    apply (rule_tac x="\<lambda>i. e / sqrt (of_nat CARD('b))" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   655
    apply (simp add: divide_pos_pos setL2_constant)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   656
    done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   657
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   658
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   659
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   660
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   661
lemma LIMSEQ_Cart_nth:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   662
  "(X ----> a) \<Longrightarrow> (\<lambda>n. X n $ i) ----> a $ i"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   663
unfolding LIMSEQ_conv_tendsto by (rule tendsto_Cart_nth)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   664
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   665
lemma LIM_Cart_nth:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   666
  "(f -- x --> y) \<Longrightarrow> (\<lambda>x. f x $ i) -- x --> y $ i"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   667
unfolding LIM_conv_tendsto by (rule tendsto_Cart_nth)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   668
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   669
lemma Cauchy_Cart_nth:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   670
  "Cauchy (\<lambda>n. X n) \<Longrightarrow> Cauchy (\<lambda>n. X n $ i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   671
unfolding Cauchy_def by (fast intro: le_less_trans [OF dist_nth_le])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   672
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   673
lemma LIMSEQ_vector:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   674
  fixes X :: "nat \<Rightarrow> 'a::metric_space ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   675
  assumes X: "\<And>i. (\<lambda>n. X n $ i) ----> (a $ i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   676
  shows "X ----> a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   677
proof (rule metric_LIMSEQ_I)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   678
  fix r :: real assume "0 < r"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   679
  then have "0 < r / of_nat CARD('n)" (is "0 < ?s")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   680
    by (simp add: divide_pos_pos)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   681
  def N \<equiv> "\<lambda>i. LEAST N. \<forall>n\<ge>N. dist (X n $ i) (a $ i) < ?s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   682
  def M \<equiv> "Max (range N)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   683
  have "\<And>i. \<exists>N. \<forall>n\<ge>N. dist (X n $ i) (a $ i) < ?s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   684
    using X `0 < ?s` by (rule metric_LIMSEQ_D)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   685
  hence "\<And>i. \<forall>n\<ge>N i. dist (X n $ i) (a $ i) < ?s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   686
    unfolding N_def by (rule LeastI_ex)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   687
  hence M: "\<And>i. \<forall>n\<ge>M. dist (X n $ i) (a $ i) < ?s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   688
    unfolding M_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   689
  {
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   690
    fix n :: nat assume "M \<le> n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   691
    have "dist (X n) a = setL2 (\<lambda>i. dist (X n $ i) (a $ i)) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   692
      unfolding dist_vector_def ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   693
    also have "\<dots> \<le> setsum (\<lambda>i. dist (X n $ i) (a $ i)) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   694
      by (rule setL2_le_setsum [OF zero_le_dist])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   695
    also have "\<dots> < setsum (\<lambda>i::'n. ?s) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   696
      by (rule setsum_strict_mono, simp_all add: M `M \<le> n`)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   697
    also have "\<dots> = r"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   698
      by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   699
    finally have "dist (X n) a < r" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   700
  }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   701
  hence "\<forall>n\<ge>M. dist (X n) a < r"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   702
    by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   703
  then show "\<exists>M. \<forall>n\<ge>M. dist (X n) a < r" ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   704
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   705
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   706
lemma Cauchy_vector:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   707
  fixes X :: "nat \<Rightarrow> 'a::metric_space ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   708
  assumes X: "\<And>i. Cauchy (\<lambda>n. X n $ i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   709
  shows "Cauchy (\<lambda>n. X n)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   710
proof (rule metric_CauchyI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   711
  fix r :: real assume "0 < r"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   712
  then have "0 < r / of_nat CARD('n)" (is "0 < ?s")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   713
    by (simp add: divide_pos_pos)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   714
  def N \<equiv> "\<lambda>i. LEAST N. \<forall>m\<ge>N. \<forall>n\<ge>N. dist (X m $ i) (X n $ i) < ?s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   715
  def M \<equiv> "Max (range N)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   716
  have "\<And>i. \<exists>N. \<forall>m\<ge>N. \<forall>n\<ge>N. dist (X m $ i) (X n $ i) < ?s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   717
    using X `0 < ?s` by (rule metric_CauchyD)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   718
  hence "\<And>i. \<forall>m\<ge>N i. \<forall>n\<ge>N i. dist (X m $ i) (X n $ i) < ?s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   719
    unfolding N_def by (rule LeastI_ex)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   720
  hence M: "\<And>i. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m $ i) (X n $ i) < ?s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   721
    unfolding M_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   722
  {
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   723
    fix m n :: nat
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   724
    assume "M \<le> m" "M \<le> n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   725
    have "dist (X m) (X n) = setL2 (\<lambda>i. dist (X m $ i) (X n $ i)) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   726
      unfolding dist_vector_def ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   727
    also have "\<dots> \<le> setsum (\<lambda>i. dist (X m $ i) (X n $ i)) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   728
      by (rule setL2_le_setsum [OF zero_le_dist])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   729
    also have "\<dots> < setsum (\<lambda>i::'n. ?s) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   730
      by (rule setsum_strict_mono, simp_all add: M `M \<le> m` `M \<le> n`)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   731
    also have "\<dots> = r"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   732
      by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   733
    finally have "dist (X m) (X n) < r" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   734
  }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   735
  hence "\<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < r"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   736
    by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   737
  then show "\<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < r" ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   738
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   739
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   740
instance cart :: (complete_space, finite) complete_space
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   741
proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   742
  fix X :: "nat \<Rightarrow> 'a ^ 'b" assume "Cauchy X"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   743
  have "\<And>i. (\<lambda>n. X n $ i) ----> lim (\<lambda>n. X n $ i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   744
    using Cauchy_Cart_nth [OF `Cauchy X`]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   745
    by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   746
  hence "X ----> Cart_lambda (\<lambda>i. lim (\<lambda>n. X n $ i))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   747
    by (simp add: LIMSEQ_vector)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   748
  then show "convergent X"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   749
    by (rule convergentI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   750
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   751
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   752
subsection {* Norms *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   753
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   754
instantiation cart :: (real_normed_vector, finite) real_normed_vector
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   755
begin
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   756
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   757
definition norm_vector_def:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   758
  "norm (x::'a^'b) = setL2 (\<lambda>i. norm (x$i)) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   759
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   760
definition vector_sgn_def:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   761
  "sgn (x::'a^'b) = scaleR (inverse (norm x)) x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   762
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   763
instance proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   764
  fix a :: real and x y :: "'a ^ 'b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   765
  show "0 \<le> norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   766
    unfolding norm_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   767
    by (rule setL2_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   768
  show "norm x = 0 \<longleftrightarrow> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   769
    unfolding norm_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   770
    by (simp add: setL2_eq_0_iff Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   771
  show "norm (x + y) \<le> norm x + norm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   772
    unfolding norm_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   773
    apply (rule order_trans [OF _ setL2_triangle_ineq])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   774
    apply (simp add: setL2_mono norm_triangle_ineq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   775
    done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   776
  show "norm (scaleR a x) = \<bar>a\<bar> * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   777
    unfolding norm_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   778
    by (simp add: setL2_right_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   779
  show "sgn x = scaleR (inverse (norm x)) x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   780
    by (rule vector_sgn_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   781
  show "dist x y = norm (x - y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   782
    unfolding dist_vector_def norm_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   783
    by (simp add: dist_norm)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   784
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   785
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   786
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   787
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   788
lemma norm_nth_le: "norm (x $ i) \<le> norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   789
unfolding norm_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   790
by (rule member_le_setL2) simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   791
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   792
interpretation Cart_nth: bounded_linear "\<lambda>x. x $ i"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   793
apply default
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   794
apply (rule vector_add_component)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   795
apply (rule vector_scaleR_component)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   796
apply (rule_tac x="1" in exI, simp add: norm_nth_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   797
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   798
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   799
instance cart :: (banach, finite) banach ..
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   800
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   801
subsection {* Inner products *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   802
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
   803
abbreviation inner_bullet (infix "\<bullet>" 70)  where "x \<bullet> y \<equiv> inner x y"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
   804
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   805
instantiation cart :: (real_inner, finite) real_inner
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   806
begin
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   807
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   808
definition inner_vector_def:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   809
  "inner x y = setsum (\<lambda>i. inner (x$i) (y$i)) UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   810
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   811
instance proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   812
  fix r :: real and x y z :: "'a ^ 'b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   813
  show "inner x y = inner y x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   814
    unfolding inner_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   815
    by (simp add: inner_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   816
  show "inner (x + y) z = inner x z + inner y z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   817
    unfolding inner_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   818
    by (simp add: inner_add_left setsum_addf)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   819
  show "inner (scaleR r x) y = r * inner x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   820
    unfolding inner_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   821
    by (simp add: setsum_right_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   822
  show "0 \<le> inner x x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   823
    unfolding inner_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   824
    by (simp add: setsum_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   825
  show "inner x x = 0 \<longleftrightarrow> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   826
    unfolding inner_vector_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   827
    by (simp add: Cart_eq setsum_nonneg_eq_0_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   828
  show "norm x = sqrt (inner x x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   829
    unfolding inner_vector_def norm_vector_def setL2_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   830
    by (simp add: power2_norm_eq_inner)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   831
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   832
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   833
end
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   834
35028
108662d50512 more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents: 34964
diff changeset
   835
lemma setsum_squares_eq_0_iff: assumes fS: "finite F" and fp: "\<forall>x \<in> F. f x \<ge> (0 ::'a::ordered_ab_group_add)" shows "setsum f F = 0 \<longleftrightarrow> (ALL x:F. f x = 0)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   836
using fS fp setsum_nonneg[OF fp]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   837
proof (induct set: finite)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   838
  case empty thus ?case by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   839
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   840
  case (insert x F)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   841
  from insert.prems have Fx: "f x \<ge> 0" and Fp: "\<forall> a \<in> F. f a \<ge> 0" by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   842
  from insert.hyps Fp setsum_nonneg[OF Fp]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   843
  have h: "setsum f F = 0 \<longleftrightarrow> (\<forall>a \<in>F. f a = 0)" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   844
  from add_nonneg_eq_0_iff[OF Fx  setsum_nonneg[OF Fp]] insert.hyps(1,2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   845
  show ?case by (simp add: h)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   846
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   847
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   848
subsection{* The collapse of the general concepts to dimension one. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   849
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   850
lemma vector_one: "(x::'a ^1) = (\<chi> i. (x$1))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   851
  by (simp add: Cart_eq forall_1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   852
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   853
lemma forall_one: "(\<forall>(x::'a ^1). P x) \<longleftrightarrow> (\<forall>x. P(\<chi> i. x))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   854
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   855
  apply (erule_tac x= "x$1" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   856
  apply (simp only: vector_one[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   857
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   858
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   859
lemma norm_vector_1: "norm (x :: _^1) = norm (x$1)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   860
  by (simp add: norm_vector_def UNIV_1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   861
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   862
lemma norm_real: "norm(x::real ^ 1) = abs(x$1)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   863
  by (simp add: norm_vector_1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   864
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   865
lemma dist_real: "dist(x::real ^ 1) y = abs((x$1) - (y$1))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   866
  by (auto simp add: norm_real dist_norm)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   867
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   868
subsection {* A connectedness or intermediate value lemma with several applications. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   869
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   870
lemma connected_real_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   871
  fixes f :: "real \<Rightarrow> 'a::metric_space"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   872
  assumes ab: "a \<le> b" and fa: "f a \<in> e1" and fb: "f b \<in> e2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   873
  and dst: "\<And>e x. a <= x \<Longrightarrow> x <= b \<Longrightarrow> 0 < e ==> \<exists>d > 0. \<forall>y. abs(y - x) < d \<longrightarrow> dist(f y) (f x) < e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   874
  and e1: "\<forall>y \<in> e1. \<exists>e > 0. \<forall>y'. dist y' y < e \<longrightarrow> y' \<in> e1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   875
  and e2: "\<forall>y \<in> e2. \<exists>e > 0. \<forall>y'. dist y' y < e \<longrightarrow> y' \<in> e2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   876
  and e12: "~(\<exists>x \<ge> a. x <= b \<and> f x \<in> e1 \<and> f x \<in> e2)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   877
  shows "\<exists>x \<ge> a. x <= b \<and> f x \<notin> e1 \<and> f x \<notin> e2" (is "\<exists> x. ?P x")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   878
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   879
  let ?S = "{c. \<forall>x \<ge> a. x <= c \<longrightarrow> f x \<in> e1}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   880
  have Se: " \<exists>x. x \<in> ?S" apply (rule exI[where x=a]) by (auto simp add: fa)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   881
  have Sub: "\<exists>y. isUb UNIV ?S y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   882
    apply (rule exI[where x= b])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   883
    using ab fb e12 by (auto simp add: isUb_def setle_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   884
  from reals_complete[OF Se Sub] obtain l where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   885
    l: "isLub UNIV ?S l"by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   886
  have alb: "a \<le> l" "l \<le> b" using l ab fa fb e12
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   887
    apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   888
    by (metis linorder_linear)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   889
  have ale1: "\<forall>z \<ge> a. z < l \<longrightarrow> f z \<in> e1" using l
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   890
    apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   891
    by (metis linorder_linear not_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   892
    have th1: "\<And>z x e d :: real. z <= x + e \<Longrightarrow> e < d ==> z < x \<or> abs(z - x) < d" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   893
    have th2: "\<And>e x:: real. 0 < e ==> ~(x + e <= x)" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   894
    have th3: "\<And>d::real. d > 0 \<Longrightarrow> \<exists>e > 0. e < d" by dlo
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   895
    {assume le2: "f l \<in> e2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   896
      from le2 fa fb e12 alb have la: "l \<noteq> a" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   897
      hence lap: "l - a > 0" using alb by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   898
      from e2[rule_format, OF le2] obtain e where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   899
        e: "e > 0" "\<forall>y. dist y (f l) < e \<longrightarrow> y \<in> e2" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   900
      from dst[OF alb e(1)] obtain d where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   901
        d: "d > 0" "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> dist (f y) (f l) < e" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   902
      have "\<exists>d'. d' < d \<and> d' >0 \<and> l - d' > a" using lap d(1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   903
        apply ferrack by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   904
      then obtain d' where d': "d' > 0" "d' < d" "l - d' > a" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   905
      from d e have th0: "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> f y \<in> e2" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   906
      from th0[rule_format, of "l - d'"] d' have "f (l - d') \<in> e2" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   907
      moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   908
      have "f (l - d') \<in> e1" using ale1[rule_format, of "l -d'"] d' by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   909
      ultimately have False using e12 alb d' by auto}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   910
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   911
    {assume le1: "f l \<in> e1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   912
    from le1 fa fb e12 alb have lb: "l \<noteq> b" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   913
      hence blp: "b - l > 0" using alb by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   914
      from e1[rule_format, OF le1] obtain e where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   915
        e: "e > 0" "\<forall>y. dist y (f l) < e \<longrightarrow> y \<in> e1" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   916
      from dst[OF alb e(1)] obtain d where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   917
        d: "d > 0" "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> dist (f y) (f l) < e" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   918
      have "\<exists>d'. d' < d \<and> d' >0" using d(1) by dlo
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   919
      then obtain d' where d': "d' > 0" "d' < d" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   920
      from d e have th0: "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> f y \<in> e1" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   921
      hence "\<forall>y. l \<le> y \<and> y \<le> l + d' \<longrightarrow> f y \<in> e1" using d' by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   922
      with ale1 have "\<forall>y. a \<le> y \<and> y \<le> l + d' \<longrightarrow> f y \<in> e1" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   923
      with l d' have False
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   924
        by (auto simp add: isLub_def isUb_def setle_def setge_def leastP_def) }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   925
    ultimately show ?thesis using alb by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   926
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   927
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   928
text{* One immediately useful corollary is the existence of square roots! --- Should help to get rid of all the development of square-root for reals as a special case @{typ "real^1"} *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   929
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   930
lemma square_bound_lemma: "(x::real) < (1 + x) * (1 + x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   931
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   932
  have "(x + 1/2)^2 + 3/4 > 0" using zero_le_power2[of "x+1/2"] by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   933
  thus ?thesis by (simp add: ring_simps power2_eq_square)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   934
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   935
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   936
lemma square_continuous: "0 < (e::real) ==> \<exists>d. 0 < d \<and> (\<forall>y. abs(y - x) < d \<longrightarrow> abs(y * y - x * x) < e)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   937
  using isCont_power[OF isCont_ident, of 2, unfolded isCont_def LIM_eq, rule_format, of e x] apply (auto simp add: power2_eq_square)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   938
  apply (rule_tac x="s" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   939
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   940
  apply (erule_tac x=y in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   941
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   942
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   943
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   944
lemma real_le_lsqrt: "0 <= x \<Longrightarrow> 0 <= y \<Longrightarrow> x <= y^2 ==> sqrt x <= y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   945
  using real_sqrt_le_iff[of x "y^2"] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   946
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   947
lemma real_le_rsqrt: "x^2 \<le> y \<Longrightarrow> x \<le> sqrt y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   948
  using real_sqrt_le_mono[of "x^2" y] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   949
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   950
lemma real_less_rsqrt: "x^2 < y \<Longrightarrow> x < sqrt y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   951
  using real_sqrt_less_mono[of "x^2" y] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   952
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   953
lemma sqrt_even_pow2: assumes n: "even n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   954
  shows "sqrt(2 ^ n) = 2 ^ (n div 2)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   955
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   956
  from n obtain m where m: "n = 2*m" unfolding even_nat_equiv_def2
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   957
    by (auto simp add: nat_number)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   958
  from m  have "sqrt(2 ^ n) = sqrt ((2 ^ m) ^ 2)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   959
    by (simp only: power_mult[symmetric] mult_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   960
  then show ?thesis  using m by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   961
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   962
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   963
lemma real_div_sqrt: "0 <= x ==> x / sqrt(x) = sqrt(x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   964
  apply (cases "x = 0", simp_all)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   965
  using sqrt_divide_self_eq[of x]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   966
  apply (simp add: inverse_eq_divide real_sqrt_ge_0_iff field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   967
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   968
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   969
text{* Hence derive more interesting properties of the norm. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   970
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   971
text {*
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   972
  This type-specific version is only here
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   973
  to make @{text normarith.ML} happy.
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   974
*}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   975
lemma norm_0: "norm (0::real ^ _) = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   976
  by (rule norm_zero)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   977
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   978
lemma norm_mul[simp]: "norm(a *s x) = abs(a) * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   979
  by (simp add: norm_vector_def vector_component setL2_right_distrib
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   980
           abs_mult cong: strong_setL2_cong)
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
   981
lemma norm_eq_0_dot: "(norm x = 0) \<longleftrightarrow> (inner x x = (0::real))"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
   982
  by (simp add: norm_vector_def setL2_def power2_eq_square)
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   983
lemma norm_eq_0_imp: "norm x = 0 ==> x = (0::real ^'n)" by (metis norm_eq_zero)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   984
lemma vector_mul_eq_0[simp]: "(a *s x = 0) \<longleftrightarrow> a = (0::'a::idom) \<or> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   985
  by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   986
lemma vector_mul_lcancel[simp]: "a *s x = a *s y \<longleftrightarrow> a = (0::real) \<or> x = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   987
  by (metis eq_iff_diff_eq_0 vector_mul_eq_0 vector_ssub_ldistrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   988
lemma vector_mul_rcancel[simp]: "a *s x = b *s x \<longleftrightarrow> (a::real) = b \<or> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   989
  by (metis eq_iff_diff_eq_0 vector_mul_eq_0 vector_sub_rdistrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   990
lemma vector_mul_lcancel_imp: "a \<noteq> (0::real) ==>  a *s x = a *s y ==> (x = y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   991
  by (metis vector_mul_lcancel)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   992
lemma vector_mul_rcancel_imp: "x \<noteq> 0 \<Longrightarrow> (a::real) *s x = b *s x ==> a = b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   993
  by (metis vector_mul_rcancel)
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
   994
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   995
lemma norm_cauchy_schwarz:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
   996
  fixes x y :: "real ^ 'n"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
   997
  shows "inner x y <= norm x * norm y"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
   998
  using Cauchy_Schwarz_ineq2[of x y] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
   999
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1000
lemma norm_cauchy_schwarz_abs:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1001
  fixes x y :: "real ^ 'n"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1002
  shows "\<bar>inner x y\<bar> \<le> norm x * norm y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1003
  using norm_cauchy_schwarz[of x y] norm_cauchy_schwarz[of x "-y"]
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1004
  by (simp add: real_abs_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1005
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1006
lemma norm_triangle_sub:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1007
  fixes x y :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1008
  shows "norm x \<le> norm y  + norm (x - y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1009
  using norm_triangle_ineq[of "y" "x - y"] by (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1010
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1011
lemma component_le_norm: "\<bar>x$i\<bar> <= norm x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1012
  apply (simp add: norm_vector_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1013
  apply (rule member_le_setL2, simp_all)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1014
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1015
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1016
lemma norm_bound_component_le: "norm x <= e ==> \<bar>x$i\<bar> <= e"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1017
  by (metis component_le_norm order_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1018
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1019
lemma norm_bound_component_lt: "norm x < e ==> \<bar>x$i\<bar> < e"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1020
  by (metis component_le_norm basic_trans_rules(21))
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1021
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1022
lemma norm_le_l1: "norm x <= setsum(\<lambda>i. \<bar>x$i\<bar>) UNIV"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1023
  by (simp add: norm_vector_def setL2_le_setsum)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1024
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1025
lemma real_abs_norm: "\<bar>norm x\<bar> = norm x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1026
  by (rule abs_norm_cancel)
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1027
lemma real_abs_sub_norm: "\<bar>norm (x::real ^ 'n) - norm y\<bar> <= norm(x - y)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1028
  by (rule norm_triangle_ineq3)
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1029
lemma norm_le: "norm(x::real ^ 'n) <= norm(y) \<longleftrightarrow> x \<bullet> x <= y \<bullet> y"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1030
  by (simp add: norm_eq_sqrt_inner) 
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1031
lemma norm_lt: "norm(x::real ^ 'n) < norm(y) \<longleftrightarrow> x \<bullet> x < y \<bullet> y"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1032
  by (simp add: norm_eq_sqrt_inner)
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1033
lemma norm_eq: "norm(x::real ^ 'n) = norm (y::real ^ 'n) \<longleftrightarrow> x \<bullet> x = y \<bullet> y"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1034
  apply(subst order_eq_iff) unfolding norm_le by auto
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1035
lemma norm_eq_1: "norm(x::real ^ 'n) = 1 \<longleftrightarrow> x \<bullet> x = 1"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1036
  unfolding norm_eq_sqrt_inner by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1037
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1038
text{* Squaring equations and inequalities involving norms.  *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1039
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1040
lemma dot_square_norm: "x \<bullet> x = norm(x)^2"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1041
  by (simp add: norm_eq_sqrt_inner)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1042
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1043
lemma norm_eq_square: "norm(x) = a \<longleftrightarrow> 0 <= a \<and> x \<bullet> x = a^2"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1044
  by (auto simp add: norm_eq_sqrt_inner)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1045
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1046
lemma real_abs_le_square_iff: "\<bar>x\<bar> \<le> \<bar>y\<bar> \<longleftrightarrow> (x::real)^2 \<le> y^2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1047
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1048
  have "x^2 \<le> y^2 \<longleftrightarrow> (x -y) * (y + x) \<le> 0" by (simp add: ring_simps power2_eq_square)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1049
  also have "\<dots> \<longleftrightarrow> \<bar>x\<bar> \<le> \<bar>y\<bar>" apply (simp add: zero_compare_simps real_abs_def not_less) by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1050
finally show ?thesis ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1051
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1052
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1053
lemma norm_le_square: "norm(x) <= a \<longleftrightarrow> 0 <= a \<and> x \<bullet> x <= a^2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1054
  apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1055
  using norm_ge_zero[of x]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1056
  apply arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1057
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1058
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1059
lemma norm_ge_square: "norm(x) >= a \<longleftrightarrow> a <= 0 \<or> x \<bullet> x >= a ^ 2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1060
  apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1061
  using norm_ge_zero[of x]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1062
  apply arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1063
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1064
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1065
lemma norm_lt_square: "norm(x) < a \<longleftrightarrow> 0 < a \<and> x \<bullet> x < a^2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1066
  by (metis not_le norm_ge_square)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1067
lemma norm_gt_square: "norm(x) > a \<longleftrightarrow> a < 0 \<or> x \<bullet> x > a^2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1068
  by (metis norm_le_square not_less)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1069
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1070
text{* Dot product in terms of the norm rather than conversely. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1071
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1072
lemmas inner_simps = inner.add_left inner.add_right inner.diff_right inner.diff_left 
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1073
inner.scaleR_left inner.scaleR_right
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1074
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1075
lemma dot_norm: "x \<bullet> y = (norm(x + y) ^2 - norm x ^ 2 - norm y ^ 2) / 2"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1076
  unfolding power2_norm_eq_inner inner_simps inner_commute by auto 
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1077
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1078
lemma dot_norm_neg: "x \<bullet> y = ((norm x ^ 2 + norm y ^ 2) - norm(x - y) ^ 2) / 2"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1079
  unfolding power2_norm_eq_inner inner_simps inner_commute by(auto simp add:group_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1080
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1081
text{* Equality of vectors in terms of @{term "op \<bullet>"} products.    *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1082
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1083
lemma vector_eq: "(x:: real ^ 'n) = y \<longleftrightarrow> x \<bullet> x = x \<bullet> y\<and> y \<bullet> y = x \<bullet> x" (is "?lhs \<longleftrightarrow> ?rhs")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1084
proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1085
  assume "?lhs" then show ?rhs by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1086
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1087
  assume ?rhs
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1088
  then have "x \<bullet> x - x \<bullet> y = 0 \<and> x \<bullet> y - y \<bullet> y = 0" by simp
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1089
  hence "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0" by (simp add: inner_simps inner_commute)
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1090
  then have "(x - y) \<bullet> (x - y) = 0" by (simp add: ring_simps inner_simps inner_commute)
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1091
  then show "x = y" by (simp)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1092
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1093
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1094
subsection{* General linear decision procedure for normed spaces. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1095
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1096
lemma norm_cmul_rule_thm:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1097
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1098
  shows "b >= norm(x) ==> \<bar>c\<bar> * b >= norm(scaleR c x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1099
  unfolding norm_scaleR
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1100
  apply (erule mult_mono1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1101
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1102
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1103
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1104
  (* FIXME: Move all these theorems into the ML code using lemma antiquotation *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1105
lemma norm_add_rule_thm:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1106
  fixes x1 x2 :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1107
  shows "norm x1 \<le> b1 \<Longrightarrow> norm x2 \<le> b2 \<Longrightarrow> norm (x1 + x2) \<le> b1 + b2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1108
  by (rule order_trans [OF norm_triangle_ineq add_mono])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1109
35028
108662d50512 more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents: 34964
diff changeset
  1110
lemma ge_iff_diff_ge_0: "(a::'a::linordered_ring) \<ge> b == a - b \<ge> 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1111
  by (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1112
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1113
lemma pth_1:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1114
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1115
  shows "x == scaleR 1 x" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1116
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1117
lemma pth_2:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1118
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1119
  shows "x - y == x + -y" by (atomize (full)) simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1120
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1121
lemma pth_3:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1122
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1123
  shows "- x == scaleR (-1) x" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1124
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1125
lemma pth_4:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1126
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1127
  shows "scaleR 0 x == 0" and "scaleR c 0 = (0::'a)" by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1128
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1129
lemma pth_5:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1130
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1131
  shows "scaleR c (scaleR d x) == scaleR (c * d) x" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1132
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1133
lemma pth_6:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1134
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1135
  shows "scaleR c (x + y) == scaleR c x + scaleR c y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1136
  by (simp add: scaleR_right_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1137
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1138
lemma pth_7:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1139
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1140
  shows "0 + x == x" and "x + 0 == x" by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1141
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1142
lemma pth_8:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1143
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1144
  shows "scaleR c x + scaleR d x == scaleR (c + d) x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1145
  by (simp add: scaleR_left_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1146
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1147
lemma pth_9:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1148
  fixes x :: "'a::real_normed_vector" shows
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1149
  "(scaleR c x + z) + scaleR d x == scaleR (c + d) x + z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1150
  "scaleR c x + (scaleR d x + z) == scaleR (c + d) x + z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1151
  "(scaleR c x + w) + (scaleR d x + z) == scaleR (c + d) x + (w + z)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1152
  by (simp_all add: algebra_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1153
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1154
lemma pth_a:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1155
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1156
  shows "scaleR 0 x + y == y" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1157
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1158
lemma pth_b:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1159
  fixes x :: "'a::real_normed_vector" shows
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1160
  "scaleR c x + scaleR d y == scaleR c x + scaleR d y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1161
  "(scaleR c x + z) + scaleR d y == scaleR c x + (z + scaleR d y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1162
  "scaleR c x + (scaleR d y + z) == scaleR c x + (scaleR d y + z)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1163
  "(scaleR c x + w) + (scaleR d y + z) == scaleR c x + (w + (scaleR d y + z))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1164
  by (simp_all add: algebra_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1165
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1166
lemma pth_c:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1167
  fixes x :: "'a::real_normed_vector" shows
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1168
  "scaleR c x + scaleR d y == scaleR d y + scaleR c x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1169
  "(scaleR c x + z) + scaleR d y == scaleR d y + (scaleR c x + z)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1170
  "scaleR c x + (scaleR d y + z) == scaleR d y + (scaleR c x + z)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1171
  "(scaleR c x + w) + (scaleR d y + z) == scaleR d y + ((scaleR c x + w) + z)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1172
  by (simp_all add: algebra_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1173
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1174
lemma pth_d:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1175
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1176
  shows "x + 0 == x" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1177
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1178
lemma norm_imp_pos_and_ge:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1179
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1180
  shows "norm x == n \<Longrightarrow> norm x \<ge> 0 \<and> n \<ge> norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1181
  by atomize auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1182
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1183
lemma real_eq_0_iff_le_ge_0: "(x::real) = 0 == x \<ge> 0 \<and> -x \<ge> 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1184
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1185
lemma norm_pths:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1186
  fixes x :: "'a::real_normed_vector" shows
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1187
  "x = y \<longleftrightarrow> norm (x - y) \<le> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1188
  "x \<noteq> y \<longleftrightarrow> \<not> (norm (x - y) \<le> 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1189
  using norm_ge_zero[of "x - y"] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1190
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1191
lemma vector_dist_norm:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1192
  fixes x :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1193
  shows "dist x y = norm (x - y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1194
  by (rule dist_norm)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1195
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1196
use "normarith.ML"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1197
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1198
method_setup norm = {* Scan.succeed (SIMPLE_METHOD' o NormArith.norm_arith_tac)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1199
*} "Proves simple linear statements about vector norms"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1200
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1201
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1202
text{* Hence more metric properties. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1203
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1204
lemma dist_triangle_alt:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1205
  fixes x y z :: "'a::metric_space"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1206
  shows "dist y z <= dist x y + dist x z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1207
using dist_triangle [of y z x] by (simp add: dist_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1208
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1209
lemma dist_pos_lt:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1210
  fixes x y :: "'a::metric_space"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1211
  shows "x \<noteq> y ==> 0 < dist x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1212
by (simp add: zero_less_dist_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1213
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1214
lemma dist_nz:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1215
  fixes x y :: "'a::metric_space"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1216
  shows "x \<noteq> y \<longleftrightarrow> 0 < dist x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1217
by (simp add: zero_less_dist_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1218
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1219
lemma dist_triangle_le:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1220
  fixes x y z :: "'a::metric_space"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1221
  shows "dist x z + dist y z <= e \<Longrightarrow> dist x y <= e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1222
by (rule order_trans [OF dist_triangle2])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1223
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1224
lemma dist_triangle_lt:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1225
  fixes x y z :: "'a::metric_space"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1226
  shows "dist x z + dist y z < e ==> dist x y < e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1227
by (rule le_less_trans [OF dist_triangle2])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1228
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1229
lemma dist_triangle_half_l:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1230
  fixes x1 x2 y :: "'a::metric_space"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1231
  shows "dist x1 y < e / 2 \<Longrightarrow> dist x2 y < e / 2 \<Longrightarrow> dist x1 x2 < e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1232
by (rule dist_triangle_lt [where z=y], simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1233
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1234
lemma dist_triangle_half_r:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1235
  fixes x1 x2 y :: "'a::metric_space"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1236
  shows "dist y x1 < e / 2 \<Longrightarrow> dist y x2 < e / 2 \<Longrightarrow> dist x1 x2 < e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1237
by (rule dist_triangle_half_l, simp_all add: dist_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1238
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1239
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1240
lemma norm_triangle_half_r:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1241
  shows "norm (y - x1) < e / 2 \<Longrightarrow> norm (y - x2) < e / 2 \<Longrightarrow> norm (x1 - x2) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1242
  using dist_triangle_half_r unfolding vector_dist_norm[THEN sym] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1243
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1244
lemma norm_triangle_half_l: assumes "norm (x - y) < e / 2" "norm (x' - (y)) < e / 2" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1245
  shows "norm (x - x') < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1246
  using dist_triangle_half_l[OF assms[unfolded vector_dist_norm[THEN sym]]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1247
  unfolding vector_dist_norm[THEN sym] .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1248
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1249
lemma norm_triangle_le: "norm(x) + norm y <= e ==> norm(x + y) <= e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1250
  by (metis order_trans norm_triangle_ineq)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1251
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1252
lemma norm_triangle_lt: "norm(x) + norm(y) < e ==> norm(x + y) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1253
  by (metis basic_trans_rules(21) norm_triangle_ineq)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents: 35150
diff changeset
  1254
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1255
lemma dist_triangle_add:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1256
  fixes x y x' y' :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1257
  shows "dist (x + y) (x' + y') <= dist x x' + dist y y'"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1258
  by norm
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1259
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1260
lemma dist_mul[simp]: "dist (c *s x) (c *s y) = \<bar>c\<bar> * dist x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1261
  unfolding dist_norm vector_ssub_ldistrib[symmetric] norm_mul ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1262
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1263
lemma dist_triangle_add_half:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1264
  fixes x x' y y' :: "'a::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1265
  shows "dist x x' < e / 2 \<Longrightarrow> dist y y' < e / 2 \<Longrightarrow> dist(x + y) (x' + y') < e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1266
  by norm
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1267
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1268
lemma setsum_component [simp]:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1269
  fixes f:: " 'a \<Rightarrow> ('b::comm_monoid_add) ^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1270
  shows "(setsum f S)$i = setsum (\<lambda>x. (f x)$i) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1271
  by (cases "finite S", induct S set: finite, simp_all)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1272
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1273
lemma setsum_eq: "setsum f S = (\<chi> i. setsum (\<lambda>x. (f x)$i ) S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1274
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1275
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1276
lemma setsum_clauses:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1277
  shows "setsum f {} = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1278
  and "finite S \<Longrightarrow> setsum f (insert x S) =
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1279
                 (if x \<in> S then setsum f S else f x + setsum f S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1280
  by (auto simp add: insert_absorb)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1281
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1282
lemma setsum_cmul:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1283
  fixes f:: "'c \<Rightarrow> ('a::semiring_1)^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1284
  shows "setsum (\<lambda>x. c *s f x) S = c *s setsum f S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1285
  by (simp add: Cart_eq setsum_right_distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1286
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1287
lemma setsum_norm:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1288
  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1289
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1290
  shows "norm (setsum f S) <= setsum (\<lambda>x. norm(f x)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1291
proof(induct rule: finite_induct[OF fS])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1292
  case 1 thus ?case by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1293
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1294
  case (2 x S)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1295
  from "2.hyps" have "norm (setsum f (insert x S)) \<le> norm (f x) + norm (setsum f S)" by (simp add: norm_triangle_ineq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1296
  also have "\<dots> \<le> norm (f x) + setsum (\<lambda>x. norm(f x)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1297
    using "2.hyps" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1298
  finally  show ?case  using "2.hyps" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1299
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1300
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1301
lemma real_setsum_norm:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1302
  fixes f :: "'a \<Rightarrow> real ^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1303
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1304
  shows "norm (setsum f S) <= setsum (\<lambda>x. norm(f x)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1305
proof(induct rule: finite_induct[OF fS])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1306
  case 1 thus ?case by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1307
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1308
  case (2 x S)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1309
  from "2.hyps" have "norm (setsum f (insert x S)) \<le> norm (f x) + norm (setsum f S)" by (simp add: norm_triangle_ineq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1310
  also have "\<dots> \<le> norm (f x) + setsum (\<lambda>x. norm(f x)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1311
    using "2.hyps" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1312
  finally  show ?case  using "2.hyps" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1313
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1314
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1315
lemma setsum_norm_le:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1316
  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1317
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1318
  and fg: "\<forall>x \<in> S. norm (f x) \<le> g x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1319
  shows "norm (setsum f S) \<le> setsum g S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1320
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1321
  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1322
    by - (rule setsum_mono, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1323
  then show ?thesis using setsum_norm[OF fS, of f] fg
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1324
    by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1325
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1326
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1327
lemma real_setsum_norm_le:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1328
  fixes f :: "'a \<Rightarrow> real ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1329
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1330
  and fg: "\<forall>x \<in> S. norm (f x) \<le> g x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1331
  shows "norm (setsum f S) \<le> setsum g S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1332
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1333
  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1334
    by - (rule setsum_mono, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1335
  then show ?thesis using real_setsum_norm[OF fS, of f] fg
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1336
    by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1337
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1338
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1339
lemma setsum_norm_bound:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1340
  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1341
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1342
  and K: "\<forall>x \<in> S. norm (f x) \<le> K"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1343
  shows "norm (setsum f S) \<le> of_nat (card S) * K"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1344
  using setsum_norm_le[OF fS K] setsum_constant[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1345
  by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1346
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1347
lemma real_setsum_norm_bound:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1348
  fixes f :: "'a \<Rightarrow> real ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1349
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1350
  and K: "\<forall>x \<in> S. norm (f x) \<le> K"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1351
  shows "norm (setsum f S) \<le> of_nat (card S) * K"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1352
  using real_setsum_norm_le[OF fS K] setsum_constant[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1353
  by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1354
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1355
lemma setsum_vmul:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1356
  fixes f :: "'a \<Rightarrow> 'b::{real_normed_vector,semiring, mult_zero}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1357
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1358
  shows "setsum f S *s v = setsum (\<lambda>x. f x *s v) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1359
proof(induct rule: finite_induct[OF fS])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1360
  case 1 then show ?case by (simp add: vector_smult_lzero)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1361
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1362
  case (2 x F)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1363
  from "2.hyps" have "setsum f (insert x F) *s v = (f x + setsum f F) *s v"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1364
    by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1365
  also have "\<dots> = f x *s v + setsum f F *s v"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1366
    by (simp add: vector_sadd_rdistrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1367
  also have "\<dots> = setsum (\<lambda>x. f x *s v) (insert x F)" using "2.hyps" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1368
  finally show ?case .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1369
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1370
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1371
(* FIXME : Problem thm setsum_vmul[of _ "f:: 'a \<Rightarrow> real ^'n"]  ---
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1372
 Get rid of *s and use real_vector instead! Also prove that ^ creates a real_vector !! *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1373
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1374
    (* FIXME: Here too need stupid finiteness assumption on T!!! *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1375
lemma setsum_group:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1376
  assumes fS: "finite S" and fT: "finite T" and fST: "f ` S \<subseteq> T"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1377
  shows "setsum (\<lambda>y. setsum g {x. x\<in> S \<and> f x = y}) T = setsum g S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1378
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1379
apply (subst setsum_image_gen[OF fS, of g f])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1380
apply (rule setsum_mono_zero_right[OF fT fST])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1381
by (auto intro: setsum_0')
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1382
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1383
lemma vsum_norm_allsubsets_bound:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1384
  fixes f:: "'a \<Rightarrow> real ^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1385
  assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1386
  shows "setsum (\<lambda>x. norm (f x)) P \<le> 2 * real CARD('n) *  e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1387
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1388
  let ?d = "real CARD('n)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1389
  let ?nf = "\<lambda>x. norm (f x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1390
  let ?U = "UNIV :: 'n set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1391
  have th0: "setsum (\<lambda>x. setsum (\<lambda>i. \<bar>f x $ i\<bar>) ?U) P = setsum (\<lambda>i. setsum (\<lambda>x. \<bar>f x $ i\<bar>) P) ?U"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1392
    by (rule setsum_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1393
  have th1: "2 * ?d * e = of_nat (card ?U) * (2 * e)" by (simp add: real_of_nat_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1394
  have "setsum ?nf P \<le> setsum (\<lambda>x. setsum (\<lambda>i. \<bar>f x $ i\<bar>) ?U) P"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1395
    apply (rule setsum_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1396
    by (rule norm_le_l1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1397
  also have "\<dots> \<le> 2 * ?d * e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1398
    unfolding th0 th1
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1399
  proof(rule setsum_bounded)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1400
    fix i assume i: "i \<in> ?U"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1401
    let ?Pp = "{x. x\<in> P \<and> f x $ i \<ge> 0}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1402
    let ?Pn = "{x. x \<in> P \<and> f x $ i < 0}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1403
    have thp: "P = ?Pp \<union> ?Pn" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1404
    have thp0: "?Pp \<inter> ?Pn ={}" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1405
    have PpP: "?Pp \<subseteq> P" and PnP: "?Pn \<subseteq> P" by blast+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1406
    have Ppe:"setsum (\<lambda>x. \<bar>f x $ i\<bar>) ?Pp \<le> e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1407
      using component_le_norm[of "setsum (\<lambda>x. f x) ?Pp" i]  fPs[OF PpP]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1408
      by (auto intro: abs_le_D1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1409
    have Pne: "setsum (\<lambda>x. \<bar>f x $ i\<bar>) ?Pn \<le> e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1410
      using component_le_norm[of "setsum (\<lambda>x. - f x) ?Pn" i]  fPs[OF PnP]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1411
      by (auto simp add: setsum_negf intro: abs_le_D1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1412
    have "setsum (\<lambda>x. \<bar>f x $ i\<bar>) P = setsum (\<lambda>x. \<bar>f x $ i\<bar>) ?Pp + setsum (\<lambda>x. \<bar>f x $ i\<bar>) ?Pn"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1413
      apply (subst thp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1414
      apply (rule setsum_Un_zero)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1415
      using fP thp0 by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1416
    also have "\<dots> \<le> 2*e" using Pne Ppe by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1417
    finally show "setsum (\<lambda>x. \<bar>f x $ i\<bar>) P \<le> 2*e" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1418
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1419
  finally show ?thesis .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1420
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1421
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1422
lemma dot_lsum: "finite S \<Longrightarrow> setsum f S \<bullet> (y::'a::{real_inner}^'n) = setsum (\<lambda>x. f x \<bullet> y) S "
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1423
  apply(induct rule: finite_induct) by(auto simp add: inner_simps)
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1424
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1425
lemma dot_rsum: "finite S \<Longrightarrow> (y::'a::{real_inner}^'n) \<bullet> setsum f S = setsum (\<lambda>x. y \<bullet> f x) S "
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1426
  apply(induct rule: finite_induct) by(auto simp add: inner_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1427
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1428
subsection{* Basis vectors in coordinate directions. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1429
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1430
definition "basis k = (\<chi> i. if i = k then 1 else 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1431
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1432
lemma basis_component [simp]: "basis k $ i = (if k=i then 1 else 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1433
  unfolding basis_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1434
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1435
lemma delta_mult_idempotent:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1436
  "(if k=a then 1 else (0::'a::semiring_1)) * (if k=a then 1 else 0) = (if k=a then 1 else 0)" by (cases "k=a", auto)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1437
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1438
lemma norm_basis:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1439
  shows "norm (basis k :: real ^'n) = 1"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1440
  apply (simp add: basis_def norm_eq_sqrt_inner) unfolding inner_vector_def
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1441
  apply (vector delta_mult_idempotent)
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1442
  using setsum_delta[of "UNIV :: 'n set" "k" "\<lambda>k. 1::real"] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1443
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1444
lemma norm_basis_1: "norm(basis 1 :: real ^'n::{finite,one}) = 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1445
  by (rule norm_basis)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1446
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1447
lemma vector_choose_size: "0 <= c ==> \<exists>(x::real^'n). norm x = c"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1448
  apply (rule exI[where x="c *s basis arbitrary"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1449
  by (simp only: norm_mul norm_basis)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1450
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1451
lemma vector_choose_dist: assumes e: "0 <= e"
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1452
  shows "\<exists>(y::real^'n). dist x y = e"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1453
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1454
  from vector_choose_size[OF e] obtain c:: "real ^'n"  where "norm c = e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1455
    by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1456
  then have "dist x (x - c) = e" by (simp add: dist_norm)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1457
  then show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1458
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1459
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1460
lemma basis_inj: "inj (basis :: 'n \<Rightarrow> real ^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1461
  by (simp add: inj_on_def Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1462
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1463
lemma cond_value_iff: "f (if b then x else y) = (if b then f x else f y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1464
  by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1465
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1466
lemma basis_expansion:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1467
  "setsum (\<lambda>i. (x$i) *s basis i) UNIV = (x::('a::ring_1) ^'n)" (is "?lhs = ?rhs" is "setsum ?f ?S = _")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1468
  by (auto simp add: Cart_eq cond_value_iff setsum_delta[of "?S", where ?'b = "'a", simplified] cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1469
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1470
lemma basis_expansion_unique:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1471
  "setsum (\<lambda>i. f i *s basis i) UNIV = (x::('a::comm_ring_1) ^'n) \<longleftrightarrow> (\<forall>i. f i = x$i)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1472
  by (simp add: Cart_eq setsum_delta cond_value_iff cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1473
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1474
lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1475
  by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1476
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1477
lemma dot_basis:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1478
  shows "basis i \<bullet> x = x$i" "x \<bullet> (basis i) = (x$i)"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1479
  unfolding inner_vector_def by (auto simp add: basis_def cond_application_beta  cond_value_iff setsum_delta cong del: if_weak_cong)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1480
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1481
lemma inner_basis:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1482
  fixes x :: "'a::{real_inner, real_algebra_1} ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1483
  shows "inner (basis i) x = inner 1 (x $ i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1484
    and "inner x (basis i) = inner (x $ i) 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1485
  unfolding inner_vector_def basis_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1486
  by (auto simp add: cond_application_beta  cond_value_iff setsum_delta cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1487
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1488
lemma basis_eq_0: "basis i = (0::'a::semiring_1^'n) \<longleftrightarrow> False"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1489
  by (auto simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1490
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1491
lemma basis_nonzero:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1492
  shows "basis k \<noteq> (0:: 'a::semiring_1 ^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1493
  by (simp add: basis_eq_0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1494
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1495
lemma vector_eq_ldot: "(\<forall>x. x \<bullet> y = x \<bullet> z) \<longleftrightarrow> y = (z::real^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1496
  apply (auto simp add: Cart_eq dot_basis)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1497
  apply (erule_tac x="basis i" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1498
  apply (simp add: dot_basis)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1499
  apply (subgoal_tac "y = z")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1500
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1501
  apply (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1502
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1503
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1504
lemma vector_eq_rdot: "(\<forall>z. x \<bullet> z = y \<bullet> z) \<longleftrightarrow> x = (y::real^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1505
  apply (auto simp add: Cart_eq dot_basis)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1506
  apply (erule_tac x="basis i" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1507
  apply (simp add: dot_basis)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1508
  apply (subgoal_tac "x = y")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1509
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1510
  apply (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1511
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1512
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1513
subsection{* Orthogonality. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1514
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1515
definition "orthogonal x y \<longleftrightarrow> (x \<bullet> y = 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1516
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1517
lemma orthogonal_basis:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1518
  shows "orthogonal (basis i) x \<longleftrightarrow> x$i = (0::real)"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1519
  by (auto simp add: orthogonal_def inner_vector_def basis_def cond_value_iff cond_application_beta setsum_delta cong del: if_weak_cong)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1520
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1521
lemma orthogonal_basis_basis:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1522
  shows "orthogonal (basis i :: real^'n) (basis j) \<longleftrightarrow> i \<noteq> j"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1523
  unfolding orthogonal_basis[of i] basis_component[of j] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1524
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1525
  (* FIXME : Maybe some of these require less than comm_ring, but not all*)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1526
lemma orthogonal_clauses:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1527
  "orthogonal a (0::real ^'n)"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1528
  "orthogonal a x ==> orthogonal a (c *\<^sub>R x)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1529
  "orthogonal a x ==> orthogonal a (-x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1530
  "orthogonal a x \<Longrightarrow> orthogonal a y ==> orthogonal a (x + y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1531
  "orthogonal a x \<Longrightarrow> orthogonal a y ==> orthogonal a (x - y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1532
  "orthogonal 0 a"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1533
  "orthogonal x a ==> orthogonal (c *\<^sub>R x) a"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1534
  "orthogonal x a ==> orthogonal (-x) a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1535
  "orthogonal x a \<Longrightarrow> orthogonal y a ==> orthogonal (x + y) a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1536
  "orthogonal x a \<Longrightarrow> orthogonal y a ==> orthogonal (x - y) a"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1537
  unfolding orthogonal_def inner_simps by auto
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1538
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1539
lemma orthogonal_commute: "orthogonal (x::real ^'n)y \<longleftrightarrow> orthogonal y x"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1540
  by (simp add: orthogonal_def inner_commute)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1541
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1542
subsection{* Explicit vector construction from lists. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1543
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1544
primrec from_nat :: "nat \<Rightarrow> 'a::{monoid_add,one}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1545
where "from_nat 0 = 0" | "from_nat (Suc n) = 1 + from_nat n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1546
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1547
lemma from_nat [simp]: "from_nat = of_nat"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1548
by (rule ext, induct_tac x, simp_all)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1549
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1550
primrec
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1551
  list_fun :: "nat \<Rightarrow> _ list \<Rightarrow> _ \<Rightarrow> _"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1552
where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1553
  "list_fun n [] = (\<lambda>x. 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1554
| "list_fun n (x # xs) = fun_upd (list_fun (Suc n) xs) (from_nat n) x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1555
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1556
definition "vector l = (\<chi> i. list_fun 1 l i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1557
(*definition "vector l = (\<chi> i. if i <= length l then l ! (i - 1) else 0)"*)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1558
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1559
lemma vector_1: "(vector[x]) $1 = x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1560
  unfolding vector_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1561
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1562
lemma vector_2:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1563
 "(vector[x,y]) $1 = x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1564
 "(vector[x,y] :: 'a^2)$2 = (y::'a::zero)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1565
  unfolding vector_def by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1566
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1567
lemma vector_3:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1568
 "(vector [x,y,z] ::('a::zero)^3)$1 = x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1569
 "(vector [x,y,z] ::('a::zero)^3)$2 = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1570
 "(vector [x,y,z] ::('a::zero)^3)$3 = z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1571
  unfolding vector_def by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1572
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1573
lemma forall_vector_1: "(\<forall>v::'a::zero^1. P v) \<longleftrightarrow> (\<forall>x. P(vector[x]))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1574
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1575
  apply (erule_tac x="v$1" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1576
  apply (subgoal_tac "vector [v$1] = v")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1577
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1578
  apply (vector vector_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1579
  apply (simp add: forall_1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1580
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1581
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1582
lemma forall_vector_2: "(\<forall>v::'a::zero^2. P v) \<longleftrightarrow> (\<forall>x y. P(vector[x, y]))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1583
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1584
  apply (erule_tac x="v$1" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1585
  apply (erule_tac x="v$2" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1586
  apply (subgoal_tac "vector [v$1, v$2] = v")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1587
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1588
  apply (vector vector_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1589
  apply (simp add: forall_2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1590
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1591
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1592
lemma forall_vector_3: "(\<forall>v::'a::zero^3. P v) \<longleftrightarrow> (\<forall>x y z. P(vector[x, y, z]))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1593
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1594
  apply (erule_tac x="v$1" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1595
  apply (erule_tac x="v$2" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1596
  apply (erule_tac x="v$3" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1597
  apply (subgoal_tac "vector [v$1, v$2, v$3] = v")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1598
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1599
  apply (vector vector_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1600
  apply (simp add: forall_3)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1601
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1602
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1603
subsection{* Linear functions. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1604
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1605
definition "linear f \<longleftrightarrow> (\<forall>x y. f(x + y) = f x + f y) \<and> (\<forall>c x. f(c *s x) = c *s f x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1606
33714
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  1607
lemma linearI: assumes "\<And>x y. f (x + y) = f x + f y" "\<And>c x. f (c *s x) = c *s f x"
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  1608
  shows "linear f" using assms unfolding linear_def by auto
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  1609
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1610
lemma linear_compose_cmul: "linear f ==> linear (\<lambda>x. (c::'a::comm_semiring) *s f x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1611
  by (vector linear_def Cart_eq ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1612
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1613
lemma linear_compose_neg: "linear (f :: 'a ^'n \<Rightarrow> 'a::comm_ring ^'m) ==> linear (\<lambda>x. -(f(x)))" by (vector linear_def Cart_eq)
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1614
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1615
lemma linear_compose_add: "linear (f :: 'a ^'n \<Rightarrow> 'a::semiring_1 ^'m) \<Longrightarrow> linear g ==> linear (\<lambda>x. f(x) + g(x))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1616
  by (vector linear_def Cart_eq ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1617
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1618
lemma linear_compose_sub: "linear (f :: 'a ^'n \<Rightarrow> 'a::ring_1 ^'m) \<Longrightarrow> linear g ==> linear (\<lambda>x. f x - g x)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1619
  by (vector linear_def Cart_eq ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1620
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1621
lemma linear_compose: "linear f \<Longrightarrow> linear g ==> linear (g o f)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1622
  by (simp add: linear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1623
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1624
lemma linear_id: "linear id" by (simp add: linear_def id_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1625
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1626
lemma linear_zero: "linear (\<lambda>x. 0::'a::semiring_1 ^ 'n)" by (simp add: linear_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1627
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1628
lemma linear_compose_setsum:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1629
  assumes fS: "finite S" and lS: "\<forall>a \<in> S. linear (f a :: 'a::semiring_1 ^ 'n \<Rightarrow> 'a ^'m)"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1630
  shows "linear(\<lambda>x. setsum (\<lambda>a. f a x :: 'a::semiring_1 ^'m) S)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1631
  using lS
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1632
  apply (induct rule: finite_induct[OF fS])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1633
  by (auto simp add: linear_zero intro: linear_compose_add)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1634
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1635
lemma linear_vmul_component:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1636
  fixes f:: "'a::semiring_1^'m \<Rightarrow> 'a^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1637
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1638
  shows "linear (\<lambda>x. f x $ k *s v)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1639
  using lf
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1640
  apply (auto simp add: linear_def )
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1641
  by (vector ring_simps)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1642
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1643
lemma linear_0: "linear f ==> f 0 = (0::'a::semiring_1 ^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1644
  unfolding linear_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1645
  apply clarsimp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1646
  apply (erule allE[where x="0::'a"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1647
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1648
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1649
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1650
lemma linear_cmul: "linear f ==> f(c*s x) = c *s f x" by (simp add: linear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1651
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1652
lemma linear_neg: "linear (f :: 'a::ring_1 ^'n \<Rightarrow> _) ==> f (-x) = - f x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1653
  unfolding vector_sneg_minus1
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1654
  using linear_cmul[of f] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1655
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1656
lemma linear_add: "linear f ==> f(x + y) = f x + f y" by (metis linear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1657
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1658
lemma linear_sub: "linear (f::'a::ring_1 ^'n \<Rightarrow> _) ==> f(x - y) = f x - f y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1659
  by (simp add: diff_def linear_add linear_neg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1660
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1661
lemma linear_setsum:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1662
  fixes f:: "'a::semiring_1^'n \<Rightarrow> _"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1663
  assumes lf: "linear f" and fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1664
  shows "f (setsum g S) = setsum (f o g) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1665
proof (induct rule: finite_induct[OF fS])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1666
  case 1 thus ?case by (simp add: linear_0[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1667
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1668
  case (2 x F)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1669
  have "f (setsum g (insert x F)) = f (g x + setsum g F)" using "2.hyps"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1670
    by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1671
  also have "\<dots> = f (g x) + f (setsum g F)" using linear_add[OF lf] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1672
  also have "\<dots> = setsum (f o g) (insert x F)" using "2.hyps" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1673
  finally show ?case .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1674
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1675
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1676
lemma linear_setsum_mul:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1677
  fixes f:: "'a ^'n \<Rightarrow> 'a::semiring_1^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1678
  assumes lf: "linear f" and fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1679
  shows "f (setsum (\<lambda>i. c i *s v i) S) = setsum (\<lambda>i. c i *s f (v i)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1680
  using linear_setsum[OF lf fS, of "\<lambda>i. c i *s v i" , unfolded o_def]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1681
  linear_cmul[OF lf] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1682
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1683
lemma linear_injective_0:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1684
  assumes lf: "linear (f:: 'a::ring_1 ^ 'n \<Rightarrow> _)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1685
  shows "inj f \<longleftrightarrow> (\<forall>x. f x = 0 \<longrightarrow> x = 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1686
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1687
  have "inj f \<longleftrightarrow> (\<forall> x y. f x = f y \<longrightarrow> x = y)" by (simp add: inj_on_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1688
  also have "\<dots> \<longleftrightarrow> (\<forall> x y. f x - f y = 0 \<longrightarrow> x - y = 0)" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1689
  also have "\<dots> \<longleftrightarrow> (\<forall> x y. f (x - y) = 0 \<longrightarrow> x - y = 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1690
    by (simp add: linear_sub[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1691
  also have "\<dots> \<longleftrightarrow> (\<forall> x. f x = 0 \<longrightarrow> x = 0)" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1692
  finally show ?thesis .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1693
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1694
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1695
lemma linear_bounded:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1696
  fixes f:: "real ^'m \<Rightarrow> real ^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1697
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1698
  shows "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1699
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1700
  let ?S = "UNIV:: 'm set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1701
  let ?B = "setsum (\<lambda>i. norm(f(basis i))) ?S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1702
  have fS: "finite ?S" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1703
  {fix x:: "real ^ 'm"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1704
    let ?g = "(\<lambda>i. (x$i) *s (basis i) :: real ^ 'm)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1705
    have "norm (f x) = norm (f (setsum (\<lambda>i. (x$i) *s (basis i)) ?S))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1706
      by (simp only:  basis_expansion)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1707
    also have "\<dots> = norm (setsum (\<lambda>i. (x$i) *s f (basis i))?S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1708
      using linear_setsum[OF lf fS, of ?g, unfolded o_def] linear_cmul[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1709
      by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1710
    finally have th0: "norm (f x) = norm (setsum (\<lambda>i. (x$i) *s f (basis i))?S)" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1711
    {fix i assume i: "i \<in> ?S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1712
      from component_le_norm[of x i]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1713
      have "norm ((x$i) *s f (basis i :: real ^'m)) \<le> norm (f (basis i)) * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1714
      unfolding norm_mul
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1715
      apply (simp only: mult_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1716
      apply (rule mult_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1717
      by (auto simp add: ring_simps norm_ge_zero) }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1718
    then have th: "\<forall>i\<in> ?S. norm ((x$i) *s f (basis i :: real ^'m)) \<le> norm (f (basis i)) * norm x" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1719
    from real_setsum_norm_le[OF fS, of "\<lambda>i. (x$i) *s (f (basis i))", OF th]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1720
    have "norm (f x) \<le> ?B * norm x" unfolding th0 setsum_left_distrib by metis}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1721
  then show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1722
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1723
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1724
lemma linear_bounded_pos:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1725
  fixes f:: "real ^'n \<Rightarrow> real ^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1726
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1727
  shows "\<exists>B > 0. \<forall>x. norm (f x) \<le> B * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1728
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1729
  from linear_bounded[OF lf] obtain B where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1730
    B: "\<forall>x. norm (f x) \<le> B * norm x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1731
  let ?K = "\<bar>B\<bar> + 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1732
  have Kp: "?K > 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1733
    {assume C: "B < 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1734
      have "norm (1::real ^ 'n) > 0" by (simp add: zero_less_norm_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1735
      with C have "B * norm (1:: real ^ 'n) < 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1736
        by (simp add: zero_compare_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1737
      with B[rule_format, of 1] norm_ge_zero[of "f 1"] have False by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1738
    }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1739
    then have Bp: "B \<ge> 0" by ferrack
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1740
    {fix x::"real ^ 'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1741
      have "norm (f x) \<le> ?K *  norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1742
      using B[rule_format, of x] norm_ge_zero[of x] norm_ge_zero[of "f x"] Bp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1743
      apply (auto simp add: ring_simps split add: abs_split)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1744
      apply (erule order_trans, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1745
      done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1746
  }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1747
  then show ?thesis using Kp by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1748
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1749
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1750
lemma smult_conv_scaleR: "c *s x = scaleR c x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1751
  unfolding vector_scalar_mult_def vector_scaleR_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1752
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1753
lemma linear_conv_bounded_linear:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1754
  fixes f :: "real ^ _ \<Rightarrow> real ^ _"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1755
  shows "linear f \<longleftrightarrow> bounded_linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1756
proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1757
  assume "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1758
  show "bounded_linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1759
  proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1760
    fix x y show "f (x + y) = f x + f y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1761
      using `linear f` unfolding linear_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1762
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1763
    fix r x show "f (scaleR r x) = scaleR r (f x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1764
      using `linear f` unfolding linear_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1765
      by (simp add: smult_conv_scaleR)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1766
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1767
    have "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1768
      using `linear f` by (rule linear_bounded)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1769
    thus "\<exists>K. \<forall>x. norm (f x) \<le> norm x * K"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1770
      by (simp add: mult_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1771
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1772
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1773
  assume "bounded_linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1774
  then interpret f: bounded_linear f .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1775
  show "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1776
    unfolding linear_def smult_conv_scaleR
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1777
    by (simp add: f.add f.scaleR)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1778
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1779
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1780
lemma bounded_linearI': fixes f::"real^'n \<Rightarrow> real^'m"
33714
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  1781
  assumes "\<And>x y. f (x + y) = f x + f y" "\<And>c x. f (c *s x) = c *s f x"
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  1782
  shows "bounded_linear f" unfolding linear_conv_bounded_linear[THEN sym]
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  1783
  by(rule linearI[OF assms])
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  1784
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1785
subsection{* Bilinear functions. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1786
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1787
definition "bilinear f \<longleftrightarrow> (\<forall>x. linear(\<lambda>y. f x y)) \<and> (\<forall>y. linear(\<lambda>x. f x y))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1788
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1789
lemma bilinear_ladd: "bilinear h ==> h (x + y) z = (h x z) + (h y z)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1790
  by (simp add: bilinear_def linear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1791
lemma bilinear_radd: "bilinear h ==> h x (y + z) = (h x y) + (h x z)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1792
  by (simp add: bilinear_def linear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1793
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1794
lemma bilinear_lmul: "bilinear h ==> h (c *s x) y = c *s (h x y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1795
  by (simp add: bilinear_def linear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1796
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1797
lemma bilinear_rmul: "bilinear h ==> h x (c *s y) = c *s (h x y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1798
  by (simp add: bilinear_def linear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1799
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1800
lemma bilinear_lneg: "bilinear h ==> h (- (x:: 'a::ring_1 ^ 'n)) y = -(h x y)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1801
  by (simp only: vector_sneg_minus1 bilinear_lmul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1802
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1803
lemma bilinear_rneg: "bilinear h ==> h x (- (y:: 'a::ring_1 ^ 'n)) = - h x y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1804
  by (simp only: vector_sneg_minus1 bilinear_rmul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1805
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1806
lemma  (in ab_group_add) eq_add_iff: "x = x + y \<longleftrightarrow> y = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1807
  using add_imp_eq[of x y 0] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1808
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1809
lemma bilinear_lzero:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1810
  fixes h :: "'a::ring^'n \<Rightarrow> _" assumes bh: "bilinear h" shows "h 0 x = 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1811
  using bilinear_ladd[OF bh, of 0 0 x]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1812
    by (simp add: eq_add_iff ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1813
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1814
lemma bilinear_rzero:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  1815
  fixes h :: "'a::ring^_ \<Rightarrow> _" assumes bh: "bilinear h" shows "h x 0 = 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1816
  using bilinear_radd[OF bh, of x 0 0 ]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1817
    by (simp add: eq_add_iff ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1818
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  1819
lemma bilinear_lsub: "bilinear h ==> h (x - (y:: 'a::ring_1 ^ _)) z = h x z - h y z"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1820
  by (simp  add: diff_def bilinear_ladd bilinear_lneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1821
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  1822
lemma bilinear_rsub: "bilinear h ==> h z (x - (y:: 'a::ring_1 ^ _)) = h z x - h z y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1823
  by (simp  add: diff_def bilinear_radd bilinear_rneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1824
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1825
lemma bilinear_setsum:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  1826
  fixes h:: "'a ^_ \<Rightarrow> 'a::semiring_1^_\<Rightarrow> 'a ^ _"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1827
  assumes bh: "bilinear h" and fS: "finite S" and fT: "finite T"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1828
  shows "h (setsum f S) (setsum g T) = setsum (\<lambda>(i,j). h (f i) (g j)) (S \<times> T) "
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1829
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1830
  have "h (setsum f S) (setsum g T) = setsum (\<lambda>x. h (f x) (setsum g T)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1831
    apply (rule linear_setsum[unfolded o_def])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1832
    using bh fS by (auto simp add: bilinear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1833
  also have "\<dots> = setsum (\<lambda>x. setsum (\<lambda>y. h (f x) (g y)) T) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1834
    apply (rule setsum_cong, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1835
    apply (rule linear_setsum[unfolded o_def])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1836
    using bh fT by (auto simp add: bilinear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1837
  finally show ?thesis unfolding setsum_cartesian_product .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1838
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1839
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1840
lemma bilinear_bounded:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1841
  fixes h:: "real ^'m \<Rightarrow> real^'n \<Rightarrow> real ^'k"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1842
  assumes bh: "bilinear h"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1843
  shows "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1844
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1845
  let ?M = "UNIV :: 'm set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1846
  let ?N = "UNIV :: 'n set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1847
  let ?B = "setsum (\<lambda>(i,j). norm (h (basis i) (basis j))) (?M \<times> ?N)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1848
  have fM: "finite ?M" and fN: "finite ?N" by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1849
  {fix x:: "real ^ 'm" and  y :: "real^'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1850
    have "norm (h x y) = norm (h (setsum (\<lambda>i. (x$i) *s basis i) ?M) (setsum (\<lambda>i. (y$i) *s basis i) ?N))" unfolding basis_expansion ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1851
    also have "\<dots> = norm (setsum (\<lambda> (i,j). h ((x$i) *s basis i) ((y$j) *s basis j)) (?M \<times> ?N))"  unfolding bilinear_setsum[OF bh fM fN] ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1852
    finally have th: "norm (h x y) = \<dots>" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1853
    have "norm (h x y) \<le> ?B * norm x * norm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1854
      apply (simp add: setsum_left_distrib th)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1855
      apply (rule real_setsum_norm_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1856
      using fN fM
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1857
      apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1858
      apply (auto simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh] norm_mul ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1859
      apply (rule mult_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1860
      apply (auto simp add: norm_ge_zero zero_le_mult_iff component_le_norm)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1861
      apply (rule mult_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1862
      apply (auto simp add: norm_ge_zero zero_le_mult_iff component_le_norm)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1863
      done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1864
  then show ?thesis by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1865
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1866
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1867
lemma bilinear_bounded_pos:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  1868
  fixes h:: "real ^'m \<Rightarrow> real^'n \<Rightarrow> real ^'k"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1869
  assumes bh: "bilinear h"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1870
  shows "\<exists>B > 0. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1871
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1872
  from bilinear_bounded[OF bh] obtain B where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1873
    B: "\<forall>x y. norm (h x y) \<le> B * norm x * norm y" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1874
  let ?K = "\<bar>B\<bar> + 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1875
  have Kp: "?K > 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1876
  have KB: "B < ?K" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1877
  {fix x::"real ^'m" and y :: "real ^'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1878
    from KB Kp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1879
    have "B * norm x * norm y \<le> ?K * norm x * norm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1880
      apply -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1881
      apply (rule mult_right_mono, rule mult_right_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1882
      by (auto simp add: norm_ge_zero)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1883
    then have "norm (h x y) \<le> ?K * norm x * norm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1884
      using B[rule_format, of x y] by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1885
  with Kp show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1886
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1887
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1888
lemma bilinear_conv_bounded_bilinear:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1889
  fixes h :: "real ^ _ \<Rightarrow> real ^ _ \<Rightarrow> real ^ _"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1890
  shows "bilinear h \<longleftrightarrow> bounded_bilinear h"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1891
proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1892
  assume "bilinear h"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1893
  show "bounded_bilinear h"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1894
  proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1895
    fix x y z show "h (x + y) z = h x z + h y z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1896
      using `bilinear h` unfolding bilinear_def linear_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1897
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1898
    fix x y z show "h x (y + z) = h x y + h x z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1899
      using `bilinear h` unfolding bilinear_def linear_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1900
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1901
    fix r x y show "h (scaleR r x) y = scaleR r (h x y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1902
      using `bilinear h` unfolding bilinear_def linear_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1903
      by (simp add: smult_conv_scaleR)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1904
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1905
    fix r x y show "h x (scaleR r y) = scaleR r (h x y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1906
      using `bilinear h` unfolding bilinear_def linear_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1907
      by (simp add: smult_conv_scaleR)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1908
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1909
    have "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1910
      using `bilinear h` by (rule bilinear_bounded)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1911
    thus "\<exists>K. \<forall>x y. norm (h x y) \<le> norm x * norm y * K"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1912
      by (simp add: mult_ac)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1913
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1914
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1915
  assume "bounded_bilinear h"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1916
  then interpret h: bounded_bilinear h .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1917
  show "bilinear h"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1918
    unfolding bilinear_def linear_conv_bounded_linear
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1919
    using h.bounded_linear_left h.bounded_linear_right
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1920
    by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1921
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1922
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1923
subsection{* Adjoints. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1924
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1925
definition "adjoint f = (SOME f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1926
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1927
lemma choice_iff: "(\<forall>x. \<exists>y. P x y) \<longleftrightarrow> (\<exists>f. \<forall>x. P x (f x))" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1928
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1929
lemma adjoint_works_lemma:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1930
  fixes f:: "real ^'n \<Rightarrow> real ^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1931
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1932
  shows "\<forall>x y. f x \<bullet> y = x \<bullet> adjoint f y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1933
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1934
  let ?N = "UNIV :: 'n set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1935
  let ?M = "UNIV :: 'm set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1936
  have fN: "finite ?N" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1937
  have fM: "finite ?M" by simp
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1938
  {fix y:: "real ^ 'm"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1939
    let ?w = "(\<chi> i. (f (basis i) \<bullet> y)) :: real ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1940
    {fix x
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1941
      have "f x \<bullet> y = f (setsum (\<lambda>i. (x$i) *s basis i) ?N) \<bullet> y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1942
        by (simp only: basis_expansion)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1943
      also have "\<dots> = (setsum (\<lambda>i. (x$i) *s f (basis i)) ?N) \<bullet> y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1944
        unfolding linear_setsum[OF lf fN]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1945
        by (simp add: linear_cmul[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1946
      finally have "f x \<bullet> y = x \<bullet> ?w"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1947
        apply (simp only: )
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1948
        apply (simp add: inner_vector_def setsum_left_distrib setsum_right_distrib setsum_commute[of _ ?M ?N] ring_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1949
        done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1950
  }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1951
  then show ?thesis unfolding adjoint_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1952
    some_eq_ex[of "\<lambda>f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1953
    using choice_iff[of "\<lambda>a b. \<forall>x. f x \<bullet> a = x \<bullet> b "]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1954
    by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1955
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1956
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1957
lemma adjoint_works:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1958
  fixes f:: "real ^'n \<Rightarrow> real ^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1959
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1960
  shows "x \<bullet> adjoint f y = f x \<bullet> y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1961
  using adjoint_works_lemma[OF lf] by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1962
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1963
lemma adjoint_linear:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1964
  fixes f:: "real ^'n \<Rightarrow> real ^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1965
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1966
  shows "linear (adjoint f)"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1967
  unfolding linear_def vector_eq_ldot[symmetric] apply safe
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1968
  unfolding inner_simps smult_conv_scaleR adjoint_works[OF lf] by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1969
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1970
lemma adjoint_clauses:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1971
  fixes f:: "real ^'n \<Rightarrow> real ^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1972
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1973
  shows "x \<bullet> adjoint f y = f x \<bullet> y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1974
  and "adjoint f y \<bullet> x = y \<bullet> f x"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1975
  by (simp_all add: adjoint_works[OF lf] inner_commute)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1976
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1977
lemma adjoint_adjoint:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1978
  fixes f:: "real ^'n \<Rightarrow> real ^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1979
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1980
  shows "adjoint (adjoint f) = f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1981
  apply (rule ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1982
  by (simp add: vector_eq_ldot[symmetric] adjoint_clauses[OF adjoint_linear[OF lf]] adjoint_clauses[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1983
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1984
lemma adjoint_unique:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  1985
  fixes f:: "real ^'n \<Rightarrow> real ^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1986
  assumes lf: "linear f" and u: "\<forall>x y. f' x \<bullet> y = x \<bullet> f y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1987
  shows "f' = adjoint f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1988
  apply (rule ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1989
  using u
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1990
  by (simp add: vector_eq_rdot[symmetric] adjoint_clauses[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1991
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1992
text{* Matrix notation. NB: an MxN matrix is of type @{typ "'a^'n^'m"}, not @{typ "'a^'m^'n"} *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  1993
34292
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  1994
definition matrix_matrix_mult :: "('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'p^'n \<Rightarrow> 'a ^ 'p ^'m"  (infixl "**" 70)
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  1995
  where "m ** m' == (\<chi> i j. setsum (\<lambda>k. ((m$i)$k) * ((m'$k)$j)) (UNIV :: 'n set)) ::'a ^ 'p ^'m"
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  1996
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  1997
definition matrix_vector_mult :: "('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'n \<Rightarrow> 'a ^ 'm"  (infixl "*v" 70)
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  1998
  where "m *v x \<equiv> (\<chi> i. setsum (\<lambda>j. ((m$i)$j) * (x$j)) (UNIV ::'n set)) :: 'a^'m"
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  1999
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  2000
definition vector_matrix_mult :: "'a ^ 'm \<Rightarrow> ('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'n "  (infixl "v*" 70)
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  2001
  where "v v* m == (\<chi> j. setsum (\<lambda>i. ((m$i)$j) * (v$i)) (UNIV :: 'm set)) :: 'a^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2002
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2003
definition "(mat::'a::zero => 'a ^'n^'n) k = (\<chi> i j. if i = j then k else 0)"
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2004
definition transpose where 
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2005
  "(transpose::'a^'n^'m \<Rightarrow> 'a^'m^'n) A = (\<chi> i j. ((A$j)$i))"
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2006
definition "(row::'m => 'a ^'n^'m \<Rightarrow> 'a ^'n) i A = (\<chi> j. ((A$i)$j))"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2007
definition "(column::'n =>'a^'n^'m =>'a^'m) j A = (\<chi> i. ((A$i)$j))"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2008
definition "rows(A::'a^'n^'m) = { row i A | i. i \<in> (UNIV :: 'm set)}"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2009
definition "columns(A::'a^'n^'m) = { column i A | i. i \<in> (UNIV :: 'n set)}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2010
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2011
lemma mat_0[simp]: "mat 0 = 0" by (vector mat_def)
34292
14fd037ccc47 remove overloaded star operator, use specific vector / matrix operators
hoelzl
parents: 34291
diff changeset
  2012
lemma matrix_add_ldistrib: "(A ** (B + C)) = (A ** B) + (A ** C)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2013
  by (vector matrix_matrix_mult_def setsum_addf[symmetric] ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2014
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2015
lemma matrix_mul_lid:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2016
  fixes A :: "'a::semiring_1 ^ 'm ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2017
  shows "mat 1 ** A = A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2018
  apply (simp add: matrix_matrix_mult_def mat_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2019
  apply vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2020
  by (auto simp only: cond_value_iff cond_application_beta setsum_delta'[OF finite]  mult_1_left mult_zero_left if_True UNIV_I)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2021
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2022
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2023
lemma matrix_mul_rid:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2024
  fixes A :: "'a::semiring_1 ^ 'm ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2025
  shows "A ** mat 1 = A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2026
  apply (simp add: matrix_matrix_mult_def mat_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2027
  apply vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2028
  by (auto simp only: cond_value_iff cond_application_beta setsum_delta[OF finite]  mult_1_right mult_zero_right if_True UNIV_I cong: if_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2029
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2030
lemma matrix_mul_assoc: "A ** (B ** C) = (A ** B) ** C"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2031
  apply (vector matrix_matrix_mult_def setsum_right_distrib setsum_left_distrib mult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2032
  apply (subst setsum_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2033
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2034
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2035
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2036
lemma matrix_vector_mul_assoc: "A *v (B *v x) = (A ** B) *v x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2037
  apply (vector matrix_matrix_mult_def matrix_vector_mult_def setsum_right_distrib setsum_left_distrib mult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2038
  apply (subst setsum_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2039
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2040
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2041
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2042
lemma matrix_vector_mul_lid: "mat 1 *v x = (x::'a::semiring_1 ^ 'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2043
  apply (vector matrix_vector_mult_def mat_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2044
  by (simp add: cond_value_iff cond_application_beta
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2045
    setsum_delta' cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2046
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2047
lemma matrix_transpose_mul: "transpose(A ** B) = transpose B ** transpose (A::'a::comm_semiring_1^_^_)"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2048
  by (simp add: matrix_matrix_mult_def transpose_def Cart_eq mult_commute)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2049
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2050
lemma matrix_eq:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2051
  fixes A B :: "'a::semiring_1 ^ 'n ^ 'm"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2052
  shows "A = B \<longleftrightarrow>  (\<forall>x. A *v x = B *v x)" (is "?lhs \<longleftrightarrow> ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2053
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2054
  apply (subst Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2055
  apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2056
  apply (clarsimp simp add: matrix_vector_mult_def basis_def cond_value_iff cond_application_beta Cart_eq cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2057
  apply (erule_tac x="basis ia" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2058
  apply (erule_tac x="i" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2059
  by (auto simp add: basis_def cond_value_iff cond_application_beta setsum_delta[OF finite] cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2060
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2061
lemma matrix_vector_mul_component:
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2062
  shows "((A::real^_^_) *v x)$k = (A$k) \<bullet> x"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2063
  by (simp add: matrix_vector_mult_def inner_vector_def)
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2064
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2065
lemma dot_lmul_matrix: "((x::real ^_) v* A) \<bullet> y = x \<bullet> (A *v y)"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2066
  apply (simp add: inner_vector_def matrix_vector_mult_def vector_matrix_mult_def setsum_left_distrib setsum_right_distrib mult_ac)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2067
  apply (subst setsum_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2068
  by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2069
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2070
lemma transpose_mat: "transpose (mat n) = mat n"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2071
  by (vector transpose_def mat_def)
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2072
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2073
lemma transpose_transpose: "transpose(transpose A) = A"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2074
  by (vector transpose_def)
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2075
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2076
lemma row_transpose:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2077
  fixes A:: "'a::semiring_1^_^_"
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2078
  shows "row i (transpose A) = column i A"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2079
  by (simp add: row_def column_def transpose_def Cart_eq)
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2080
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2081
lemma column_transpose:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2082
  fixes A:: "'a::semiring_1^_^_"
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2083
  shows "column i (transpose A) = row i A"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2084
  by (simp add: row_def column_def transpose_def Cart_eq)
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2085
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2086
lemma rows_transpose: "rows(transpose (A::'a::semiring_1^_^_)) = columns A"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2087
by (auto simp add: rows_def columns_def row_transpose intro: set_ext)
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2088
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2089
lemma columns_transpose: "columns(transpose (A::'a::semiring_1^_^_)) = rows A" by (metis transpose_transpose rows_transpose)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2090
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2091
text{* Two sometimes fruitful ways of looking at matrix-vector multiplication. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2092
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2093
lemma matrix_mult_dot: "A *v x = (\<chi> i. A$i \<bullet> x)"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2094
  by (simp add: matrix_vector_mult_def inner_vector_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2095
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2096
lemma matrix_mult_vsum: "(A::'a::comm_semiring_1^'n^'m) *v x = setsum (\<lambda>i. (x$i) *s column i A) (UNIV:: 'n set)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2097
  by (simp add: matrix_vector_mult_def Cart_eq column_def mult_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2098
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2099
lemma vector_componentwise:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2100
  "(x::'a::ring_1^'n) = (\<chi> j. setsum (\<lambda>i. (x$i) * (basis i :: 'a^'n)$j) (UNIV :: 'n set))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2101
  apply (subst basis_expansion[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2102
  by (vector Cart_eq setsum_component)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2103
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2104
lemma linear_componentwise:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2105
  fixes f:: "'a::ring_1 ^'m \<Rightarrow> 'a ^ _"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2106
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2107
  shows "(f x)$j = setsum (\<lambda>i. (x$i) * (f (basis i)$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2108
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2109
  let ?M = "(UNIV :: 'm set)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2110
  let ?N = "(UNIV :: 'n set)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2111
  have fM: "finite ?M" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2112
  have "?rhs = (setsum (\<lambda>i.(x$i) *s f (basis i) ) ?M)$j"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2113
    unfolding vector_smult_component[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2114
    unfolding setsum_component[of "(\<lambda>i.(x$i) *s f (basis i :: 'a^'m))" ?M]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2115
    ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2116
  then show ?thesis unfolding linear_setsum_mul[OF lf fM, symmetric] basis_expansion ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2117
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2118
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2119
text{* Inverse matrices  (not necessarily square) *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2120
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2121
definition "invertible(A::'a::semiring_1^'n^'m) \<longleftrightarrow> (\<exists>A'::'a^'m^'n. A ** A' = mat 1 \<and> A' ** A = mat 1)"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2122
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2123
definition "matrix_inv(A:: 'a::semiring_1^'n^'m) =
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2124
        (SOME A'::'a^'m^'n. A ** A' = mat 1 \<and> A' ** A = mat 1)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2125
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2126
text{* Correspondence between matrices and linear operators. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2127
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2128
definition matrix:: "('a::{plus,times, one, zero}^'m \<Rightarrow> 'a ^ 'n) \<Rightarrow> 'a^'m^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2129
where "matrix f = (\<chi> i j. (f(basis j))$i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2130
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2131
lemma matrix_vector_mul_linear: "linear(\<lambda>x. A *v (x::'a::comm_semiring_1 ^ _))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2132
  by (simp add: linear_def matrix_vector_mult_def Cart_eq ring_simps setsum_right_distrib setsum_addf)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2133
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2134
lemma matrix_works: assumes lf: "linear f" shows "matrix f *v x = f (x::'a::comm_ring_1 ^ 'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2135
apply (simp add: matrix_def matrix_vector_mult_def Cart_eq mult_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2136
apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2137
apply (rule linear_componentwise[OF lf, symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2138
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2139
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2140
lemma matrix_vector_mul: "linear f ==> f = (\<lambda>x. matrix f *v (x::'a::comm_ring_1 ^ 'n))" by (simp add: ext matrix_works)
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2141
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2142
lemma matrix_of_matrix_vector_mul: "matrix(\<lambda>x. A *v (x :: 'a:: comm_ring_1 ^ 'n)) = A"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2143
  by (simp add: matrix_eq matrix_vector_mul_linear matrix_works)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2144
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2145
lemma matrix_compose:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2146
  assumes lf: "linear (f::'a::comm_ring_1^'n \<Rightarrow> 'a^'m)"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2147
  and lg: "linear (g::'a::comm_ring_1^'m \<Rightarrow> 'a^_)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2148
  shows "matrix (g o f) = matrix g ** matrix f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2149
  using lf lg linear_compose[OF lf lg] matrix_works[OF linear_compose[OF lf lg]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2150
  by (simp  add: matrix_eq matrix_works matrix_vector_mul_assoc[symmetric] o_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2151
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2152
lemma matrix_vector_column:"(A::'a::comm_semiring_1^'n^_) *v x = setsum (\<lambda>i. (x$i) *s ((transpose A)$i)) (UNIV:: 'n set)"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2153
  by (simp add: matrix_vector_mult_def transpose_def Cart_eq mult_commute)
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2154
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2155
lemma adjoint_matrix: "adjoint(\<lambda>x. (A::real^'n^'m) *v x) = (\<lambda>x. transpose A *v x)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2156
  apply (rule adjoint_unique[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2157
  apply (rule matrix_vector_mul_linear)
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2158
  apply (simp add: transpose_def inner_vector_def matrix_vector_mult_def setsum_left_distrib setsum_right_distrib)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2159
  apply (subst setsum_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2160
  apply (auto simp add: mult_ac)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2161
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2162
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2163
lemma matrix_adjoint: assumes lf: "linear (f :: real^'n \<Rightarrow> real ^'m)"
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  2164
  shows "matrix(adjoint f) = transpose(matrix f)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2165
  apply (subst matrix_vector_mul[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2166
  unfolding adjoint_matrix matrix_of_matrix_vector_mul ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2167
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2168
subsection{* Interlude: Some properties of real sets *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2169
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2170
lemma seq_mono_lemma: assumes "\<forall>(n::nat) \<ge> m. (d n :: real) < e n" and "\<forall>n \<ge> m. e n <= e m"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2171
  shows "\<forall>n \<ge> m. d n < e m"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2172
  using prems apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2173
  apply (erule_tac x="n" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2174
  apply (erule_tac x="n" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2175
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2176
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2177
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2178
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2179
lemma real_convex_bound_lt:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2180
  assumes xa: "(x::real) < a" and ya: "y < a" and u: "0 <= u" and v: "0 <= v"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2181
  and uv: "u + v = 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2182
  shows "u * x + v * y < a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2183
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2184
  have uv': "u = 0 \<longrightarrow> v \<noteq> 0" using u v uv by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2185
  have "a = a * (u + v)" unfolding uv  by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2186
  hence th: "u * a + v * a = a" by (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2187
  from xa u have "u \<noteq> 0 \<Longrightarrow> u*x < u*a" by (simp add: mult_compare_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2188
  from ya v have "v \<noteq> 0 \<Longrightarrow> v * y < v * a" by (simp add: mult_compare_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2189
  from xa ya u v have "u * x + v * y < u * a + v * a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2190
    apply (cases "u = 0", simp_all add: uv')
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2191
    apply(rule mult_strict_left_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2192
    using uv' apply simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2193
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2194
    apply (rule add_less_le_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2195
    apply(rule mult_strict_left_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2196
    apply simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2197
    apply (rule mult_left_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2198
    apply simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2199
    done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2200
  thus ?thesis unfolding th .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2201
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2202
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2203
lemma real_convex_bound_le:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2204
  assumes xa: "(x::real) \<le> a" and ya: "y \<le> a" and u: "0 <= u" and v: "0 <= v"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2205
  and uv: "u + v = 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2206
  shows "u * x + v * y \<le> a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2207
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2208
  from xa ya u v have "u * x + v * y \<le> u * a + v * a" by (simp add: add_mono mult_left_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2209
  also have "\<dots> \<le> (u + v) * a" by (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2210
  finally show ?thesis unfolding uv by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2211
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2212
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2213
lemma infinite_enumerate: assumes fS: "infinite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2214
  shows "\<exists>r. subseq r \<and> (\<forall>n. r n \<in> S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2215
unfolding subseq_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2216
using enumerate_in_set[OF fS] enumerate_mono[of _ _ S] fS by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2217
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2218
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)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2219
apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2220
apply (rule_tac x="d/2" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2221
apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2222
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2223
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2224
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2225
lemma triangle_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2226
  assumes x: "0 <= (x::real)" and y:"0 <= y" and z: "0 <= z" and xy: "x^2 <= y^2 + z^2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2227
  shows "x <= y + z"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2228
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2229
  have "y^2 + z^2 \<le> y^2 + 2*y*z + z^2" using z y  by (simp add: zero_compare_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2230
  with xy have th: "x ^2 \<le> (y+z)^2" by (simp add: power2_eq_square ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2231
  from y z have yz: "y + z \<ge> 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2232
  from power2_le_imp_le[OF th yz] show ?thesis .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2233
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2234
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2235
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2236
lemma lambda_skolem: "(\<forall>i. \<exists>x. P i x) \<longleftrightarrow>
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2237
   (\<exists>x::'a ^ 'n. \<forall>i. P i (x$i))" (is "?lhs \<longleftrightarrow> ?rhs")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2238
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2239
  let ?S = "(UNIV :: 'n set)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2240
  {assume H: "?rhs"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2241
    then have ?lhs by auto}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2242
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2243
  {assume H: "?lhs"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2244
    then obtain f where f:"\<forall>i. P i (f i)" unfolding choice_iff by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2245
    let ?x = "(\<chi> i. (f i)) :: 'a ^ 'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2246
    {fix i
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2247
      from f have "P i (f i)" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2248
      then have "P i (?x$i)" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2249
    }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2250
    hence "\<forall>i. P i (?x$i)" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2251
    hence ?rhs by metis }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2252
  ultimately show ?thesis by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2253
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2254
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2255
subsection{* Operator norm. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2256
33270
paulson
parents: 33175
diff changeset
  2257
definition "onorm f = Sup {norm (f x)| x. norm x = 1}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2258
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2259
lemma norm_bound_generalize:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2260
  fixes f:: "real ^'n \<Rightarrow> real^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2261
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2262
  shows "(\<forall>x. norm x = 1 \<longrightarrow> norm (f x) \<le> b) \<longleftrightarrow> (\<forall>x. norm (f x) \<le> b * norm x)" (is "?lhs \<longleftrightarrow> ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2263
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2264
  {assume H: ?rhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2265
    {fix x :: "real^'n" assume x: "norm x = 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2266
      from H[rule_format, of x] x have "norm (f x) \<le> b" by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2267
    then have ?lhs by blast }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2268
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2269
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2270
  {assume H: ?lhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2271
    from H[rule_format, of "basis arbitrary"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2272
    have bp: "b \<ge> 0" using norm_ge_zero[of "f (basis arbitrary)"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2273
      by (auto simp add: norm_basis elim: order_trans [OF norm_ge_zero])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2274
    {fix x :: "real ^'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2275
      {assume "x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2276
        then have "norm (f x) \<le> b * norm x" by (simp add: linear_0[OF lf] bp)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2277
      moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2278
      {assume x0: "x \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2279
        hence n0: "norm x \<noteq> 0" by (metis norm_eq_zero)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2280
        let ?c = "1/ norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2281
        have "norm (?c*s x) = 1" using x0 by (simp add: n0 norm_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2282
        with H have "norm (f(?c*s x)) \<le> b" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2283
        hence "?c * norm (f x) \<le> b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2284
          by (simp add: linear_cmul[OF lf] norm_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2285
        hence "norm (f x) \<le> b * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2286
          using n0 norm_ge_zero[of x] by (auto simp add: field_simps)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2287
      ultimately have "norm (f x) \<le> b * norm x" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2288
    then have ?rhs by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2289
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2290
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2291
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2292
lemma onorm:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2293
  fixes f:: "real ^'n \<Rightarrow> real ^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2294
  assumes lf: "linear f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2295
  shows "norm (f x) <= onorm f * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2296
  and "\<forall>x. norm (f x) <= b * norm x \<Longrightarrow> onorm f <= b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2297
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2298
  {
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2299
    let ?S = "{norm (f x) |x. norm x = 1}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2300
    have Se: "?S \<noteq> {}" using  norm_basis by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2301
    from linear_bounded[OF lf] have b: "\<exists> b. ?S *<= b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2302
      unfolding norm_bound_generalize[OF lf, symmetric] by (auto simp add: setle_def)
33270
paulson
parents: 33175
diff changeset
  2303
    {from Sup[OF Se b, unfolded onorm_def[symmetric]]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2304
      show "norm (f x) <= onorm f * norm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2305
        apply -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2306
        apply (rule spec[where x = x])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2307
        unfolding norm_bound_generalize[OF lf, symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2308
        by (auto simp add: isLub_def isUb_def leastP_def setge_def setle_def)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2309
    {
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2310
      show "\<forall>x. norm (f x) <= b * norm x \<Longrightarrow> onorm f <= b"
33270
paulson
parents: 33175
diff changeset
  2311
        using Sup[OF Se b, unfolded onorm_def[symmetric]]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2312
        unfolding norm_bound_generalize[OF lf, symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2313
        by (auto simp add: isLub_def isUb_def leastP_def setge_def setle_def)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2314
  }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2315
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2316
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2317
lemma onorm_pos_le: assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)" shows "0 <= onorm f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2318
  using order_trans[OF norm_ge_zero onorm(1)[OF lf, of "basis arbitrary"], unfolded norm_basis] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2319
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2320
lemma onorm_eq_0: assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2321
  shows "onorm f = 0 \<longleftrightarrow> (\<forall>x. f x = 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2322
  using onorm[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2323
  apply (auto simp add: onorm_pos_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2324
  apply atomize
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2325
  apply (erule allE[where x="0::real"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2326
  using onorm_pos_le[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2327
  apply arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2328
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2329
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2330
lemma onorm_const: "onorm(\<lambda>x::real^'n. (y::real ^'m)) = norm y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2331
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2332
  let ?f = "\<lambda>x::real^'n. (y::real ^ 'm)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2333
  have th: "{norm (?f x)| x. norm x = 1} = {norm y}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2334
    by(auto intro: vector_choose_size set_ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2335
  show ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2336
    unfolding onorm_def th
33270
paulson
parents: 33175
diff changeset
  2337
    apply (rule Sup_unique) by (simp_all  add: setle_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2338
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2339
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2340
lemma onorm_pos_lt: assumes lf: "linear (f::real ^ 'n \<Rightarrow> real ^'m)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2341
  shows "0 < onorm f \<longleftrightarrow> ~(\<forall>x. f x = 0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2342
  unfolding onorm_eq_0[OF lf, symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2343
  using onorm_pos_le[OF lf] by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2344
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2345
lemma onorm_compose:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2346
  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2347
  and lg: "linear (g::real^'k \<Rightarrow> real^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2348
  shows "onorm (f o g) <= onorm f * onorm g"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2349
  apply (rule onorm(2)[OF linear_compose[OF lg lf], rule_format])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2350
  unfolding o_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2351
  apply (subst mult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2352
  apply (rule order_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2353
  apply (rule onorm(1)[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2354
  apply (rule mult_mono1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2355
  apply (rule onorm(1)[OF lg])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2356
  apply (rule onorm_pos_le[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2357
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2358
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2359
lemma onorm_neg_lemma: assumes lf: "linear (f::real ^'n \<Rightarrow> real^'m)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2360
  shows "onorm (\<lambda>x. - f x) \<le> onorm f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2361
  using onorm[OF linear_compose_neg[OF lf]] onorm[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2362
  unfolding norm_minus_cancel by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2363
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2364
lemma onorm_neg: assumes lf: "linear (f::real ^'n \<Rightarrow> real^'m)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2365
  shows "onorm (\<lambda>x. - f x) = onorm f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2366
  using onorm_neg_lemma[OF lf] onorm_neg_lemma[OF linear_compose_neg[OF lf]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2367
  by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2368
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2369
lemma onorm_triangle:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2370
  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)" and lg: "linear g"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2371
  shows "onorm (\<lambda>x. f x + g x) <= onorm f + onorm g"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2372
  apply(rule onorm(2)[OF linear_compose_add[OF lf lg], rule_format])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2373
  apply (rule order_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2374
  apply (rule norm_triangle_ineq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2375
  apply (simp add: distrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2376
  apply (rule add_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2377
  apply (rule onorm(1)[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2378
  apply (rule onorm(1)[OF lg])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2379
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2380
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2381
lemma onorm_triangle_le: "linear (f::real ^'n \<Rightarrow> real ^'m) \<Longrightarrow> linear g \<Longrightarrow> onorm(f) + onorm(g) <= e
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2382
  \<Longrightarrow> onorm(\<lambda>x. f x + g x) <= e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2383
  apply (rule order_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2384
  apply (rule onorm_triangle)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2385
  apply assumption+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2386
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2387
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2388
lemma onorm_triangle_lt: "linear (f::real ^'n \<Rightarrow> real ^'m) \<Longrightarrow> linear g \<Longrightarrow> onorm(f) + onorm(g) < e
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2389
  ==> onorm(\<lambda>x. f x + g x) < e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2390
  apply (rule order_le_less_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2391
  apply (rule onorm_triangle)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2392
  by assumption+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2393
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2394
(* "lift" from 'a to 'a^1 and "drop" from 'a^1 to 'a -- FIXME: potential use of transfer *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2395
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2396
abbreviation vec1:: "'a \<Rightarrow> 'a ^ 1" where "vec1 x \<equiv> vec x"
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2397
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2398
abbreviation dest_vec1:: "'a ^1 \<Rightarrow> 'a"
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2399
  where "dest_vec1 x \<equiv> (x$1)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2400
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2401
lemma vec1_component[simp]: "(vec1 x)$1 = x"
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2402
  by (simp add: )
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2403
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2404
lemma vec1_dest_vec1[simp]: "vec1(dest_vec1 x) = x" "dest_vec1(vec1 y) = y"
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2405
  by (simp_all add:  Cart_eq forall_1)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2406
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2407
lemma forall_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (vec1 x))" by (metis vec1_dest_vec1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2408
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2409
lemma exists_vec1: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P(vec1 x))" by (metis vec1_dest_vec1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2410
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2411
lemma vec1_eq[simp]:  "vec1 x = vec1 y \<longleftrightarrow> x = y" by (metis vec1_dest_vec1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2412
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2413
lemma dest_vec1_eq[simp]: "dest_vec1 x = dest_vec1 y \<longleftrightarrow> x = y" by (metis vec1_dest_vec1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2414
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2415
lemma vec_in_image_vec: "vec x \<in> (vec ` S) \<longleftrightarrow> x \<in> S" by auto
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2416
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2417
lemma vec_add: "vec(x + y) = vec x + vec y"  by (vector vec_def)
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2418
lemma vec_sub: "vec(x - y) = vec x - vec y" by (vector vec_def)
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2419
lemma vec_cmul: "vec(c* x) = c *s vec x " by (vector vec_def)
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2420
lemma vec_neg: "vec(- x) = - vec x " by (vector vec_def)
33714
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2421
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2422
lemma range_vec1[simp]:"range vec1 = UNIV" apply(rule set_ext,rule) unfolding image_iff defer
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2423
  apply(rule_tac x="dest_vec1 x" in bexI) by auto
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2424
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2425
lemma vec_setsum: assumes fS: "finite S"
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2426
  shows "vec(setsum f S) = setsum (vec o f) S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2427
  apply (induct rule: finite_induct[OF fS])
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2428
  apply (simp)
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2429
  apply (auto simp add: vec_add)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2430
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2431
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2432
lemma dest_vec1_lambda: "dest_vec1(\<chi> i. x i) = x 1"
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2433
  by (simp)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2434
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2435
lemma dest_vec1_vec: "dest_vec1(vec x) = x"
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2436
  by (simp)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2437
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2438
lemma dest_vec1_sum: assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2439
  shows "dest_vec1(setsum f S) = setsum (dest_vec1 o f) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2440
  apply (induct rule: finite_induct[OF fS])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2441
  apply (simp add: dest_vec1_vec)
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2442
  apply (auto simp add:vector_minus_component)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2443
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2444
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2445
lemma norm_vec1: "norm(vec1 x) = abs(x)"
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2446
  by (simp add: vec_def norm_real)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2447
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2448
lemma dist_vec1: "dist(vec1 x) (vec1 y) = abs(x - y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2449
  by (simp only: dist_real vec1_component)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2450
lemma abs_dest_vec1: "norm x = \<bar>dest_vec1 x\<bar>"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2451
  by (metis vec1_dest_vec1 norm_vec1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2452
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2453
lemmas vec1_dest_vec1_simps = forall_vec1 vec_add[THEN sym] dist_vec1 vec_sub[THEN sym] vec1_dest_vec1 norm_vec1 vector_smult_component
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2454
   vec1_eq vec_cmul[THEN sym] smult_conv_scaleR[THEN sym] o_def dist_real_def norm_vec1 real_norm_def
33714
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2455
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2456
lemma bounded_linear_vec1:"bounded_linear (vec1::real\<Rightarrow>real^1)"
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2457
  unfolding bounded_linear_def additive_def bounded_linear_axioms_def 
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2458
  unfolding smult_conv_scaleR[THEN sym] unfolding vec1_dest_vec1_simps
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2459
  apply(rule conjI) defer apply(rule conjI) defer apply(rule_tac x=1 in exI) by auto
eb2574ac4173 Added new lemmas to Euclidean Space by Robert Himmelmann
hoelzl
parents: 33270
diff changeset
  2460
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2461
lemma linear_vmul_dest_vec1:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2462
  fixes f:: "'a::semiring_1^_ \<Rightarrow> 'a^1"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2463
  shows "linear f \<Longrightarrow> linear (\<lambda>x. dest_vec1(f x) *s v)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2464
  apply (rule linear_vmul_component)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2465
  by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2466
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2467
lemma linear_from_scalars:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2468
  assumes lf: "linear (f::'a::comm_ring_1 ^1 \<Rightarrow> 'a^_)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2469
  shows "f = (\<lambda>x. dest_vec1 x *s column 1 (matrix f))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2470
  apply (rule ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2471
  apply (subst matrix_works[OF lf, symmetric])
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2472
  apply (auto simp add: Cart_eq matrix_vector_mult_def column_def  mult_commute UNIV_1)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2473
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2474
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2475
lemma linear_to_scalars: assumes lf: "linear (f::real ^'n \<Rightarrow> real^1)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2476
  shows "f = (\<lambda>x. vec1(row 1 (matrix f) \<bullet> x))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2477
  apply (rule ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2478
  apply (subst matrix_works[OF lf, symmetric])
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2479
  apply (simp add: Cart_eq matrix_vector_mult_def row_def inner_vector_def mult_commute forall_1)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2480
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2481
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2482
lemma dest_vec1_eq_0: "dest_vec1 x = 0 \<longleftrightarrow> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2483
  by (simp add: dest_vec1_eq[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2484
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2485
lemma setsum_scalars: assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2486
  shows "setsum f S = vec1 (setsum (dest_vec1 o f) S)"
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2487
  unfolding vec_setsum[OF fS] by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2488
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2489
lemma dest_vec1_wlog_le: "(\<And>(x::'a::linorder ^ 1) y. P x y \<longleftrightarrow> P y x)  \<Longrightarrow> (\<And>x y. dest_vec1 x <= dest_vec1 y ==> P x y) \<Longrightarrow> P x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2490
  apply (cases "dest_vec1 x \<le> dest_vec1 y")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2491
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2492
  apply (subgoal_tac "dest_vec1 y \<le> dest_vec1 x")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2493
  apply (auto)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2494
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2495
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2496
text{* Pasting vectors. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2497
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2498
lemma linear_fstcart[intro]: "linear fstcart"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2499
  by (auto simp add: linear_def Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2500
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2501
lemma linear_sndcart[intro]: "linear sndcart"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2502
  by (auto simp add: linear_def Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2503
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2504
lemma fstcart_vec[simp]: "fstcart(vec x) = vec x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2505
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2506
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2507
lemma fstcart_add[simp]:"fstcart(x + y) = fstcart (x::'a::{plus,times}^('b::finite + 'c::finite)) + fstcart y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2508
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2509
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2510
lemma fstcart_cmul[simp]:"fstcart(c*s x) = c*s fstcart (x::'a::{plus,times}^('b::finite + 'c::finite))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2511
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2512
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2513
lemma fstcart_neg[simp]:"fstcart(- x) = - fstcart (x::'a::ring_1^(_ + _))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2514
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2515
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2516
lemma fstcart_sub[simp]:"fstcart(x - y) = fstcart (x::'a::ring_1^(_ + _)) - fstcart y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2517
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2518
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2519
lemma fstcart_setsum:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2520
  fixes f:: "'d \<Rightarrow> 'a::semiring_1^_"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2521
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2522
  shows "fstcart (setsum f S) = setsum (\<lambda>i. fstcart (f i)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2523
  by (induct rule: finite_induct[OF fS], simp_all add: vec_0[symmetric] del: vec_0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2524
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2525
lemma sndcart_vec[simp]: "sndcart(vec x) = vec x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2526
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2527
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2528
lemma sndcart_add[simp]:"sndcart(x + y) = sndcart (x::'a::{plus,times}^(_ + _)) + sndcart y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2529
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2530
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2531
lemma sndcart_cmul[simp]:"sndcart(c*s x) = c*s sndcart (x::'a::{plus,times}^(_ + _))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2532
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2533
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2534
lemma sndcart_neg[simp]:"sndcart(- x) = - sndcart (x::'a::ring_1^(_ + _))"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2535
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2536
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2537
lemma sndcart_sub[simp]:"sndcart(x - y) = sndcart (x::'a::ring_1^(_ + _)) - sndcart y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2538
  by (simp add: Cart_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2539
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2540
lemma sndcart_setsum:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2541
  fixes f:: "'d \<Rightarrow> 'a::semiring_1^_"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2542
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2543
  shows "sndcart (setsum f S) = setsum (\<lambda>i. sndcart (f i)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2544
  by (induct rule: finite_induct[OF fS], simp_all add: vec_0[symmetric] del: vec_0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2545
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2546
lemma pastecart_vec[simp]: "pastecart (vec x) (vec x) = vec x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2547
  by (simp add: pastecart_eq fstcart_pastecart sndcart_pastecart)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2548
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2549
lemma pastecart_add[simp]:"pastecart (x1::'a::{plus,times}^_) y1 + pastecart x2 y2 = pastecart (x1 + x2) (y1 + y2)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2550
  by (simp add: pastecart_eq fstcart_pastecart sndcart_pastecart)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2551
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2552
lemma pastecart_cmul[simp]: "pastecart (c *s (x1::'a::{plus,times}^_)) (c *s y1) = c *s pastecart x1 y1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2553
  by (simp add: pastecart_eq fstcart_pastecart sndcart_pastecart)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2554
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2555
lemma pastecart_neg[simp]: "pastecart (- (x::'a::ring_1^_)) (- y) = - pastecart x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2556
  unfolding vector_sneg_minus1 pastecart_cmul ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2557
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2558
lemma pastecart_sub: "pastecart (x1::'a::ring_1^_) y1 - pastecart x2 y2 = pastecart (x1 - x2) (y1 - y2)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2559
  by (simp add: diff_def pastecart_neg[symmetric] del: pastecart_neg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2560
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2561
lemma pastecart_setsum:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2562
  fixes f:: "'d \<Rightarrow> 'a::semiring_1^_"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2563
  assumes fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2564
  shows "pastecart (setsum f S) (setsum g S) = setsum (\<lambda>i. pastecart (f i) (g i)) S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2565
  by (simp  add: pastecart_eq fstcart_setsum[OF fS] sndcart_setsum[OF fS] fstcart_pastecart sndcart_pastecart)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2566
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2567
lemma setsum_Plus:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2568
  "\<lbrakk>finite A; finite B\<rbrakk> \<Longrightarrow>
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2569
    (\<Sum>x\<in>A <+> B. g x) = (\<Sum>x\<in>A. g (Inl x)) + (\<Sum>x\<in>B. g (Inr x))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2570
  unfolding Plus_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2571
  by (subst setsum_Un_disjoint, auto simp add: setsum_reindex)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2572
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2573
lemma setsum_UNIV_sum:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2574
  fixes g :: "'a::finite + 'b::finite \<Rightarrow> _"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2575
  shows "(\<Sum>x\<in>UNIV. g x) = (\<Sum>x\<in>UNIV. g (Inl x)) + (\<Sum>x\<in>UNIV. g (Inr x))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2576
  apply (subst UNIV_Plus_UNIV [symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2577
  apply (rule setsum_Plus [OF finite finite])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2578
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2579
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2580
lemma norm_fstcart: "norm(fstcart x) <= norm (x::real ^('n::finite + 'm::finite))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2581
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2582
  have th0: "norm x = norm (pastecart (fstcart x) (sndcart x))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2583
    by (simp add: pastecart_fst_snd)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2584
  have th1: "fstcart x \<bullet> fstcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2585
    by (simp add: inner_vector_def setsum_UNIV_sum pastecart_def setsum_nonneg)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2586
  then show ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2587
    unfolding th0
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2588
    unfolding norm_eq_sqrt_inner real_sqrt_le_iff id_def
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2589
    by (simp add: inner_vector_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2590
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2591
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2592
lemma dist_fstcart: "dist(fstcart (x::real^_)) (fstcart y) <= dist x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2593
  unfolding dist_norm by (metis fstcart_sub[symmetric] norm_fstcart)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2594
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2595
lemma norm_sndcart: "norm(sndcart x) <= norm (x::real ^('n::finite + 'm::finite))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2596
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2597
  have th0: "norm x = norm (pastecart (fstcart x) (sndcart x))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2598
    by (simp add: pastecart_fst_snd)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2599
  have th1: "sndcart x \<bullet> sndcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2600
    by (simp add: inner_vector_def setsum_UNIV_sum pastecart_def setsum_nonneg)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2601
  then show ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2602
    unfolding th0
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2603
    unfolding norm_eq_sqrt_inner real_sqrt_le_iff id_def
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2604
    by (simp add: inner_vector_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2605
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2606
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2607
lemma dist_sndcart: "dist(sndcart (x::real^_)) (sndcart y) <= dist x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2608
  unfolding dist_norm by (metis sndcart_sub[symmetric] norm_sndcart)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2609
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2610
lemma dot_pastecart: "(pastecart (x1::real^'n) (x2::real^'m)) \<bullet> (pastecart y1 y2) =  x1 \<bullet> y1 + x2 \<bullet> y2"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  2611
  by (simp add: inner_vector_def setsum_UNIV_sum pastecart_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2612
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2613
text {* TODO: move to NthRoot *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2614
lemma sqrt_add_le_add_sqrt:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2615
  assumes x: "0 \<le> x" and y: "0 \<le> y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2616
  shows "sqrt (x + y) \<le> sqrt x + sqrt y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2617
apply (rule power2_le_imp_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2618
apply (simp add: real_sum_squared_expand add_nonneg_nonneg x y)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2619
apply (simp add: mult_nonneg_nonneg x y)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2620
apply (simp add: add_nonneg_nonneg x y)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2621
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2622
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2623
lemma norm_pastecart: "norm (pastecart x y) <= norm x + norm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2624
  unfolding norm_vector_def setL2_def setsum_UNIV_sum
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2625
  by (simp add: sqrt_add_le_add_sqrt setsum_nonneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2626
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2627
subsection {* A generic notion of "hull" (convex, affine, conic hull and closure). *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2628
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2629
definition hull :: "'a set set \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "hull" 75) where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2630
  "S hull s = Inter {t. t \<in> S \<and> s \<subseteq> t}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2631
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2632
lemma hull_same: "s \<in> S \<Longrightarrow> S hull s = s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2633
  unfolding hull_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2634
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2635
lemma hull_in: "(\<And>T. T \<subseteq> S ==> Inter T \<in> S) ==> (S hull s) \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2636
unfolding hull_def subset_iff by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2637
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2638
lemma hull_eq: "(\<And>T. T \<subseteq> S ==> Inter T \<in> S) ==> (S hull s) = s \<longleftrightarrow> s \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2639
using hull_same[of s S] hull_in[of S s] by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2640
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2641
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2642
lemma hull_hull: "S hull (S hull s) = S hull s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2643
  unfolding hull_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2644
34964
4e8be3c04d37 Replaced vec1 and dest_vec1 by abbreviation.
hoelzl
parents: 34915
diff changeset
  2645
lemma hull_subset[intro]: "s \<subseteq> (S hull s)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2646
  unfolding hull_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2647
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2648
lemma hull_mono: " s \<subseteq> t ==> (S hull s) \<subseteq> (S hull t)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2649
  unfolding hull_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2650
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2651
lemma hull_antimono: "S \<subseteq> T ==> (T hull s) \<subseteq> (S hull s)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2652
  unfolding hull_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2653
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2654
lemma hull_minimal: "s \<subseteq> t \<Longrightarrow> t \<in> S ==> (S hull s) \<subseteq> t"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2655
  unfolding hull_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2656
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2657
lemma subset_hull: "t \<in> S ==> S hull s \<subseteq> t \<longleftrightarrow>  s \<subseteq> t"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2658
  unfolding hull_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2659
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2660
lemma hull_unique: "s \<subseteq> t \<Longrightarrow> t \<in> S \<Longrightarrow> (\<And>t'. s \<subseteq> t' \<Longrightarrow> t' \<in> S ==> t \<subseteq> t')
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2661
           ==> (S hull s = t)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2662
unfolding hull_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2663
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2664
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"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2665
  using hull_minimal[of S "{x. P x}" Q]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2666
  by (auto simp add: subset_eq Collect_def mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2667
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2668
lemma hull_inc: "x \<in> S \<Longrightarrow> x \<in> P hull S" by (metis hull_subset subset_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2669
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2670
lemma hull_union_subset: "(S hull s) \<union> (S hull t) \<subseteq> (S hull (s \<union> t))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2671
unfolding Un_subset_iff by (metis hull_mono Un_upper1 Un_upper2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2672
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2673
lemma hull_union: assumes T: "\<And>T. T \<subseteq> S ==> Inter T \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2674
  shows "S hull (s \<union> t) = S hull (S hull s \<union> S hull t)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2675
apply rule
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2676
apply (rule hull_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2677
unfolding Un_subset_iff
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2678
apply (metis hull_subset Un_upper1 Un_upper2 subset_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2679
apply (rule hull_minimal)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2680
apply (metis hull_union_subset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2681
apply (metis hull_in T)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2682
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2683
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2684
lemma hull_redundant_eq: "a \<in> (S hull s) \<longleftrightarrow> (S hull (insert a s) = S hull s)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2685
  unfolding hull_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2686
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2687
lemma hull_redundant: "a \<in> (S hull s) ==> (S hull (insert a s) = S hull s)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2688
by (metis hull_redundant_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2689
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2690
text{* Archimedian properties and useful consequences. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2691
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2692
lemma real_arch_simple: "\<exists>n. x <= real (n::nat)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2693
  using reals_Archimedean2[of x] apply auto by (rule_tac x="Suc n" in exI, auto)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2694
lemmas real_arch_lt = reals_Archimedean2
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2695
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2696
lemmas real_arch = reals_Archimedean3
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2697
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2698
lemma real_arch_inv: "0 < e \<longleftrightarrow> (\<exists>n::nat. n \<noteq> 0 \<and> 0 < inverse (real n) \<and> inverse (real n) < e)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2699
  using reals_Archimedean
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2700
  apply (auto simp add: field_simps inverse_positive_iff_positive)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2701
  apply (subgoal_tac "inverse (real n) > 0")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2702
  apply arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2703
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2704
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2705
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2706
lemma real_pow_lbound: "0 <= x ==> 1 + real n * x <= (1 + x) ^ n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2707
proof(induct n)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2708
  case 0 thus ?case by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2709
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2710
  case (Suc n)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2711
  hence h: "1 + real n * x \<le> (1 + x) ^ n" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2712
  from h have p: "1 \<le> (1 + x) ^ n" using Suc.prems by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2713
  from h have "1 + real n * x + x \<le> (1 + x) ^ n + x" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2714
  also have "\<dots> \<le> (1 + x) ^ Suc n" apply (subst diff_le_0_iff_le[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2715
    apply (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2716
    using mult_left_mono[OF p Suc.prems] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2717
  finally show ?case  by (simp add: real_of_nat_Suc ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2718
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2719
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2720
lemma real_arch_pow: assumes x: "1 < (x::real)" shows "\<exists>n. y < x^n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2721
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2722
  from x have x0: "x - 1 > 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2723
  from real_arch[OF x0, rule_format, of y]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2724
  obtain n::nat where n:"y < real n * (x - 1)" by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2725
  from x0 have x00: "x- 1 \<ge> 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2726
  from real_pow_lbound[OF x00, of n] n
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2727
  have "y < x^n" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2728
  then show ?thesis by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2729
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2730
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2731
lemma real_arch_pow2: "\<exists>n. (x::real) < 2^ n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2732
  using real_arch_pow[of 2 x] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2733
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2734
lemma real_arch_pow_inv: assumes y: "(y::real) > 0" and x1: "x < 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2735
  shows "\<exists>n. x^n < y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2736
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2737
  {assume x0: "x > 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2738
    from x0 x1 have ix: "1 < 1/x" by (simp add: field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2739
    from real_arch_pow[OF ix, of "1/y"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2740
    obtain n where n: "1/y < (1/x)^n" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2741
    then
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2742
    have ?thesis using y x0 by (auto simp add: field_simps power_divide) }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2743
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2744
  {assume "\<not> x > 0" with y x1 have ?thesis apply auto by (rule exI[where x=1], auto)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2745
  ultimately show ?thesis by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2746
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2747
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2748
lemma forall_pos_mono: "(\<And>d e::real. d < e \<Longrightarrow> P d ==> P e) \<Longrightarrow> (\<And>n::nat. n \<noteq> 0 ==> P(inverse(real n))) \<Longrightarrow> (\<And>e. 0 < e ==> P e)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2749
  by (metis real_arch_inv)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2750
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2751
lemma forall_pos_mono_1: "(\<And>d e::real. d < e \<Longrightarrow> P d ==> P e) \<Longrightarrow> (\<And>n. P(inverse(real (Suc n)))) ==> 0 < e ==> P e"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2752
  apply (rule forall_pos_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2753
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2754
  apply (atomize)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2755
  apply (erule_tac x="n - 1" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2756
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2757
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2758
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2759
lemma real_archimedian_rdiv_eq_0: assumes x0: "x \<ge> 0" and c: "c \<ge> 0" and xc: "\<forall>(m::nat)>0. real m * x \<le> c"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2760
  shows "x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2761
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2762
  {assume "x \<noteq> 0" with x0 have xp: "x > 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2763
    from real_arch[OF xp, rule_format, of c] obtain n::nat where n: "c < real n * x"  by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2764
    with xc[rule_format, of n] have "n = 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2765
    with n c have False by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2766
  then show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2767
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2768
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2769
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2770
(* Geometric progression.                                                    *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2771
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2772
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2773
lemma sum_gp_basic: "((1::'a::{field}) - x) * setsum (\<lambda>i. x^i) {0 .. n} = (1 - x^(Suc n))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2774
  (is "?lhs = ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2775
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2776
  {assume x1: "x = 1" hence ?thesis by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2777
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2778
  {assume x1: "x\<noteq>1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2779
    hence x1': "x - 1 \<noteq> 0" "1 - x \<noteq> 0" "x - 1 = - (1 - x)" "- (1 - x) \<noteq> 0" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2780
    from geometric_sum[OF x1, of "Suc n", unfolded x1']
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2781
    have "(- (1 - x)) * setsum (\<lambda>i. x^i) {0 .. n} = - (1 - x^(Suc n))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2782
      unfolding atLeastLessThanSuc_atLeastAtMost
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2783
      using x1' apply (auto simp only: field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2784
      apply (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2785
      done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2786
    then have ?thesis by (simp add: ring_simps) }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2787
  ultimately show ?thesis by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2788
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2789
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2790
lemma sum_gp_multiplied: assumes mn: "m <= n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2791
  shows "((1::'a::{field}) - x) * setsum (op ^ x) {m..n} = x^m - x^ Suc n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2792
  (is "?lhs = ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2793
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2794
  let ?S = "{0..(n - m)}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2795
  from mn have mn': "n - m \<ge> 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2796
  let ?f = "op + m"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2797
  have i: "inj_on ?f ?S" unfolding inj_on_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2798
  have f: "?f ` ?S = {m..n}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2799
    using mn apply (auto simp add: image_iff Bex_def) by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2800
  have th: "op ^ x o op + m = (\<lambda>i. x^m * x^i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2801
    by (rule ext, simp add: power_add power_mult)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2802
  from setsum_reindex[OF i, of "op ^ x", unfolded f th setsum_right_distrib[symmetric]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2803
  have "?lhs = x^m * ((1 - x) * setsum (op ^ x) {0..n - m})" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2804
  then show ?thesis unfolding sum_gp_basic using mn
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2805
    by (simp add: ring_simps power_add[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2806
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2807
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2808
lemma sum_gp: "setsum (op ^ (x::'a::{field})) {m .. n} =
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2809
   (if n < m then 0 else if x = 1 then of_nat ((n + 1) - m)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2810
                    else (x^ m - x^ (Suc n)) / (1 - x))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2811
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2812
  {assume nm: "n < m" hence ?thesis by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2813
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2814
  {assume "\<not> n < m" hence nm: "m \<le> n" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2815
    {assume x: "x = 1"  hence ?thesis by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2816
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2817
    {assume x: "x \<noteq> 1" hence nz: "1 - x \<noteq> 0" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2818
      from sum_gp_multiplied[OF nm, of x] nz have ?thesis by (simp add: field_simps)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2819
    ultimately have ?thesis by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2820
  }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2821
  ultimately show ?thesis by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2822
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2823
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2824
lemma sum_gp_offset: "setsum (op ^ (x::'a::{field})) {m .. m+n} =
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2825
  (if x = 1 then of_nat n + 1 else x^m * (1 - x^Suc n) / (1 - x))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2826
  unfolding sum_gp[of x m "m + n"] power_Suc
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2827
  by (simp add: ring_simps power_add)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2828
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2829
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2830
subsection{* A bit of linear algebra. *}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2831
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2832
definition "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 *s x \<in>S )"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2833
definition "span S = (subspace hull S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2834
definition "dependent S \<longleftrightarrow> (\<exists>a \<in> S. a \<in> span(S - {a}))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2835
abbreviation "independent s == ~(dependent s)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2836
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2837
(* Closure properties of subspaces.                                          *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2838
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2839
lemma subspace_UNIV[simp]: "subspace(UNIV)" by (simp add: subspace_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2840
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2841
lemma subspace_0: "subspace S ==> 0 \<in> S" by (metis subspace_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2842
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2843
lemma subspace_add: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S ==> x + y \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2844
  by (metis subspace_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2845
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2846
lemma subspace_mul: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> c *s x \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2847
  by (metis subspace_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2848
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2849
lemma subspace_neg: "subspace S \<Longrightarrow> (x::'a::ring_1^_) \<in> S \<Longrightarrow> - x \<in> S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2850
  by (metis vector_sneg_minus1 subspace_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2851
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2852
lemma subspace_sub: "subspace S \<Longrightarrow> (x::'a::ring_1^_) \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x - y \<in> S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2853
  by (metis diff_def subspace_add subspace_neg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2854
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2855
lemma subspace_setsum:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2856
  assumes sA: "subspace A" and fB: "finite B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2857
  and f: "\<forall>x\<in> B. f x \<in> A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2858
  shows "setsum f B \<in> A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2859
  using  fB f sA
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2860
  apply(induct rule: finite_induct[OF fB])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2861
  by (simp add: subspace_def sA, auto simp add: sA subspace_add)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2862
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2863
lemma subspace_linear_image:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2864
  assumes lf: "linear (f::'a::semiring_1^_ \<Rightarrow> _)" and sS: "subspace S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2865
  shows "subspace(f ` S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2866
  using lf sS linear_0[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2867
  unfolding linear_def subspace_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2868
  apply (auto simp add: image_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2869
  apply (rule_tac x="x + y" in bexI, auto)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2870
  apply (rule_tac x="c*s x" in bexI, auto)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2871
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2872
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2873
lemma subspace_linear_preimage: "linear (f::'a::semiring_1^_ \<Rightarrow> _) ==> subspace S ==> subspace {x. f x \<in> S}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2874
  by (auto simp add: subspace_def linear_def linear_0[of f])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2875
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2876
lemma subspace_trivial: "subspace {0::'a::semiring_1 ^_}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2877
  by (simp add: subspace_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2878
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2879
lemma subspace_inter: "subspace A \<Longrightarrow> subspace B ==> subspace (A \<inter> B)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2880
  by (simp add: subspace_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2881
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2882
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2883
lemma span_mono: "A \<subseteq> B ==> span A \<subseteq> span B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2884
  by (metis span_def hull_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2885
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2886
lemma subspace_span: "subspace(span S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2887
  unfolding span_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2888
  apply (rule hull_in[unfolded mem_def])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2889
  apply (simp only: subspace_def Inter_iff Int_iff subset_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2890
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2891
  apply (erule_tac x="X" in ballE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2892
  apply (simp add: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2893
  apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2894
  apply (erule_tac x="X" in ballE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2895
  apply (erule_tac x="X" in ballE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2896
  apply (erule_tac x="X" in ballE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2897
  apply (clarsimp simp add: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2898
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2899
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2900
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2901
  apply (erule_tac x="X" in ballE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2902
  apply (erule_tac x="X" in ballE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2903
  apply (simp add: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2904
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2905
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2906
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2907
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2908
lemma span_clauses:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2909
  "a \<in> S ==> a \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2910
  "0 \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2911
  "x\<in> span S \<Longrightarrow> y \<in> span S ==> x + y \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2912
  "x \<in> span S \<Longrightarrow> c *s x \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2913
  by (metis span_def hull_subset subset_eq subspace_span subspace_def)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2914
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2915
lemma span_induct: assumes SP: "\<And>x. x \<in> S ==> P x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2916
  and P: "subspace P" and x: "x \<in> span S" shows "P x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2917
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2918
  from SP have SP': "S \<subseteq> P" by (simp add: mem_def subset_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2919
  from P have P': "P \<in> subspace" by (simp add: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2920
  from x hull_minimal[OF SP' P', unfolded span_def[symmetric]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2921
  show "P x" by (metis mem_def subset_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2922
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2923
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2924
lemma span_empty: "span {} = {(0::'a::semiring_0 ^ _)}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2925
  apply (simp add: span_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2926
  apply (rule hull_unique)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2927
  apply (auto simp add: mem_def subspace_def)
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2928
  unfolding mem_def[of "0::'a^_", symmetric]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2929
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2930
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2931
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2932
lemma independent_empty: "independent {}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2933
  by (simp add: dependent_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2934
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2935
lemma independent_mono: "independent A \<Longrightarrow> B \<subseteq> A ==> independent B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2936
  apply (clarsimp simp add: dependent_def span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2937
  apply (subgoal_tac "span (B - {a}) \<le> span (A - {a})")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2938
  apply force
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2939
  apply (rule span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2940
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2941
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2942
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2943
lemma span_subspace: "A \<subseteq> B \<Longrightarrow> B \<le> span A \<Longrightarrow>  subspace B \<Longrightarrow> span A = B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2944
  by (metis order_antisym span_def hull_minimal mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2945
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2946
lemma span_induct': assumes SP: "\<forall>x \<in> S. P x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2947
  and P: "subspace P" shows "\<forall>x \<in> span S. P x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2948
  using span_induct SP P by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2949
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  2950
inductive span_induct_alt_help for S:: "'a::semiring_1^_ \<Rightarrow> bool"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2951
  where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2952
  span_induct_alt_help_0: "span_induct_alt_help S 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2953
  | span_induct_alt_help_S: "x \<in> S \<Longrightarrow> span_induct_alt_help S z \<Longrightarrow> span_induct_alt_help S (c *s x + z)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2954
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2955
lemma span_induct_alt':
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  2956
  assumes h0: "h (0::'a::semiring_1^'n)" and hS: "\<And>c x y. x \<in> S \<Longrightarrow> h y \<Longrightarrow> h (c*s x + y)" shows "\<forall>x \<in> span S. h x"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2957
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2958
  {fix x:: "'a^'n" assume x: "span_induct_alt_help S x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2959
    have "h x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2960
      apply (rule span_induct_alt_help.induct[OF x])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2961
      apply (rule h0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2962
      apply (rule hS, assumption, assumption)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2963
      done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2964
  note th0 = this
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2965
  {fix x assume x: "x \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2966
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2967
    have "span_induct_alt_help S x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2968
      proof(rule span_induct[where x=x and S=S])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2969
        show "x \<in> span S" using x .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2970
      next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2971
        fix x assume xS : "x \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2972
          from span_induct_alt_help_S[OF xS span_induct_alt_help_0, of 1]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2973
          show "span_induct_alt_help S x" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2974
        next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2975
        have "span_induct_alt_help S 0" by (rule span_induct_alt_help_0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2976
        moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2977
        {fix x y assume h: "span_induct_alt_help S x" "span_induct_alt_help S y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2978
          from h
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2979
          have "span_induct_alt_help S (x + y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2980
            apply (induct rule: span_induct_alt_help.induct)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2981
            apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2982
            unfolding add_assoc
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2983
            apply (rule span_induct_alt_help_S)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2984
            apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2985
            apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2986
            done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2987
        moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2988
        {fix c x assume xt: "span_induct_alt_help S x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2989
          then have "span_induct_alt_help S (c*s x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2990
            apply (induct rule: span_induct_alt_help.induct)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2991
            apply (simp add: span_induct_alt_help_0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2992
            apply (simp add: vector_smult_assoc vector_add_ldistrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2993
            apply (rule span_induct_alt_help_S)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2994
            apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2995
            apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2996
            done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2997
        }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2998
        ultimately show "subspace (span_induct_alt_help S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  2999
          unfolding subspace_def mem_def Ball_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3000
      qed}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3001
  with th0 show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3002
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3003
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3004
lemma span_induct_alt:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3005
  assumes h0: "h (0::'a::semiring_1^'n)" and hS: "\<And>c x y. x \<in> S \<Longrightarrow> h y \<Longrightarrow> h (c*s x + y)" and x: "x \<in> span S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3006
  shows "h x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3007
using span_induct_alt'[of h S] h0 hS x by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3008
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3009
(* Individual closure properties. *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3010
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3011
lemma span_superset: "x \<in> S ==> x \<in> span S" by (metis span_clauses)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3012
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3013
lemma span_0: "0 \<in> span S" by (metis subspace_span subspace_0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3014
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3015
lemma span_add: "x \<in> span S \<Longrightarrow> y \<in> span S ==> x + y \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3016
  by (metis subspace_add subspace_span)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3017
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3018
lemma span_mul: "x \<in> span S ==> (c *s x) \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3019
  by (metis subspace_span subspace_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3020
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3021
lemma span_neg: "x \<in> span S ==> - (x::'a::ring_1^_) \<in> span S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3022
  by (metis subspace_neg subspace_span)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3023
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3024
lemma span_sub: "(x::'a::ring_1^_) \<in> span S \<Longrightarrow> y \<in> span S ==> x - y \<in> span S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3025
  by (metis subspace_span subspace_sub)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3026
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3027
lemma span_setsum: "finite A \<Longrightarrow> \<forall>x \<in> A. f x \<in> span S ==> setsum f A \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3028
  apply (rule subspace_setsum)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3029
  by (metis subspace_span subspace_setsum)+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3030
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3031
lemma span_add_eq: "(x::'a::ring_1^_) \<in> span S \<Longrightarrow> x + y \<in> span S \<longleftrightarrow> y \<in> span S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3032
  apply (auto simp only: span_add span_sub)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3033
  apply (subgoal_tac "(x + y) - x \<in> span S", simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3034
  by (simp only: span_add span_sub)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3035
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3036
(* Mapping under linear image. *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3037
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3038
lemma span_linear_image: assumes lf: "linear (f::'a::semiring_1 ^ _ => _)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3039
  shows "span (f ` S) = f ` (span S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3040
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3041
  {fix x
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3042
    assume x: "x \<in> span (f ` S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3043
    have "x \<in> f ` span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3044
      apply (rule span_induct[where x=x and S = "f ` S"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3045
      apply (clarsimp simp add: image_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3046
      apply (frule span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3047
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3048
      apply (simp only: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3049
      apply (rule subspace_linear_image[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3050
      apply (rule subspace_span)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3051
      apply (rule x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3052
      done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3053
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3054
  {fix x assume x: "x \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3055
    have th0:"(\<lambda>a. f a \<in> span (f ` S)) = {x. f x \<in> span (f ` S)}" apply (rule set_ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3056
      unfolding mem_def Collect_def ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3057
    have "f x \<in> span (f ` S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3058
      apply (rule span_induct[where S=S])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3059
      apply (rule span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3060
      apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3061
      apply (subst th0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3062
      apply (rule subspace_linear_preimage[OF lf subspace_span, of "f ` S"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3063
      apply (rule x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3064
      done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3065
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3066
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3067
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3068
(* The key breakdown property. *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3069
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3070
lemma span_breakdown:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3071
  assumes bS: "(b::'a::ring_1 ^ _) \<in> S" and aS: "a \<in> span S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3072
  shows "\<exists>k. a - k*s b \<in> span (S - {b})" (is "?P a")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3073
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3074
  {fix x assume xS: "x \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3075
    {assume ab: "x = b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3076
      then have "?P x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3077
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3078
        apply (rule exI[where x="1"], simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3079
        by (rule span_0)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3080
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3081
    {assume ab: "x \<noteq> b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3082
      then have "?P x"  using xS
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3083
        apply -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3084
        apply (rule exI[where x=0])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3085
        apply (rule span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3086
        by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3087
    ultimately have "?P x" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3088
  moreover have "subspace ?P"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3089
    unfolding subspace_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3090
    apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3091
    apply (simp add: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3092
    apply (rule exI[where x=0])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3093
    using span_0[of "S - {b}"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3094
    apply (simp add: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3095
    apply (clarsimp simp add: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3096
    apply (rule_tac x="k + ka" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3097
    apply (subgoal_tac "x + y - (k + ka) *s b = (x - k*s b) + (y - ka *s b)")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3098
    apply (simp only: )
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3099
    apply (rule span_add[unfolded mem_def])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3100
    apply assumption+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3101
    apply (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3102
    apply (clarsimp simp add: mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3103
    apply (rule_tac x= "c*k" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3104
    apply (subgoal_tac "c *s x - (c * k) *s b = c*s (x - k*s b)")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3105
    apply (simp only: )
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3106
    apply (rule span_mul[unfolded mem_def])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3107
    apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3108
    by (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3109
  ultimately show "?P a" using aS span_induct[where S=S and P= "?P"] by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3110
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3111
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3112
lemma span_breakdown_eq:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3113
  "(x::'a::ring_1^_) \<in> span (insert a S) \<longleftrightarrow> (\<exists>k. (x - k *s a) \<in> span S)" (is "?lhs \<longleftrightarrow> ?rhs")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3114
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3115
  {assume x: "x \<in> span (insert a S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3116
    from x span_breakdown[of "a" "insert a S" "x"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3117
    have ?rhs apply clarsimp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3118
      apply (rule_tac x= "k" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3119
      apply (rule set_rev_mp[of _ "span (S - {a})" _])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3120
      apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3121
      apply (rule span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3122
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3123
      done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3124
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3125
  { fix k assume k: "x - k *s a \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3126
    have eq: "x = (x - k *s a) + k *s a" by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3127
    have "(x - k *s a) + k *s a \<in> span (insert a S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3128
      apply (rule span_add)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3129
      apply (rule set_rev_mp[of _ "span S" _])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3130
      apply (rule k)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3131
      apply (rule span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3132
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3133
      apply (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3134
      apply (rule span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3135
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3136
      done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3137
    then have ?lhs using eq by metis}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3138
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3139
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3140
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3141
(* Hence some "reversal" results.*)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3142
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3143
lemma in_span_insert:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3144
  assumes a: "(a::'a::field^_) \<in> span (insert b S)" and na: "a \<notin> span S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3145
  shows "b \<in> span (insert a S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3146
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3147
  from span_breakdown[of b "insert b S" a, OF insertI1 a]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3148
  obtain k where k: "a - k*s b \<in> span (S - {b})" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3149
  {assume k0: "k = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3150
    with k have "a \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3151
      apply (simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3152
      apply (rule set_rev_mp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3153
      apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3154
      apply (rule span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3155
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3156
      done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3157
    with na  have ?thesis by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3158
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3159
  {assume k0: "k \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3160
    have eq: "b = (1/k) *s a - ((1/k) *s a - b)" by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3161
    from k0 have eq': "(1/k) *s (a - k*s b) = (1/k) *s a - b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3162
      by (vector field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3163
    from k have "(1/k) *s (a - k*s b) \<in> span (S - {b})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3164
      by (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3165
    hence th: "(1/k) *s a - b \<in> span (S - {b})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3166
      unfolding eq' .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3167
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3168
    from k
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3169
    have ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3170
      apply (subst eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3171
      apply (rule span_sub)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3172
      apply (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3173
      apply (rule span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3174
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3175
      apply (rule set_rev_mp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3176
      apply (rule th)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3177
      apply (rule span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3178
      using na by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3179
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3180
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3181
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3182
lemma in_span_delete:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3183
  assumes a: "(a::'a::field^_) \<in> span S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3184
  and na: "a \<notin> span (S-{b})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3185
  shows "b \<in> span (insert a (S - {b}))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3186
  apply (rule in_span_insert)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3187
  apply (rule set_rev_mp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3188
  apply (rule a)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3189
  apply (rule span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3190
  apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3191
  apply (rule na)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3192
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3193
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3194
(* Transitivity property. *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3195
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3196
lemma span_trans:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3197
  assumes x: "(x::'a::ring_1^_) \<in> span S" and y: "y \<in> span (insert x S)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3198
  shows "y \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3199
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3200
  from span_breakdown[of x "insert x S" y, OF insertI1 y]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3201
  obtain k where k: "y -k*s x \<in> span (S - {x})" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3202
  have eq: "y = (y - k *s x) + k *s x" by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3203
  show ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3204
    apply (subst eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3205
    apply (rule span_add)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3206
    apply (rule set_rev_mp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3207
    apply (rule k)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3208
    apply (rule span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3209
    apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3210
    apply (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3211
    by (rule x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3212
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3213
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3214
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3215
(* An explicit expansion is sometimes needed.                                *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3216
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3217
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3218
lemma span_explicit:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3219
  "span P = {y::'a::semiring_1^_. \<exists>S u. finite S \<and> S \<subseteq> P \<and> setsum (\<lambda>v. u v *s v) S = y}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3220
  (is "_ = ?E" is "_ = {y. ?h y}" is "_ = {y. \<exists>S u. ?Q S u y}")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3221
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3222
  {fix x assume x: "x \<in> ?E"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3223
    then obtain S u where fS: "finite S" and SP: "S\<subseteq>P" and u: "setsum (\<lambda>v. u v *s v) S = x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3224
      by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3225
    have "x \<in> span P"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3226
      unfolding u[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3227
      apply (rule span_setsum[OF fS])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3228
      using span_mono[OF SP]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3229
      by (auto intro: span_superset span_mul)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3230
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3231
  have "\<forall>x \<in> span P. x \<in> ?E"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3232
    unfolding mem_def Collect_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3233
  proof(rule span_induct_alt')
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3234
    show "?h 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3235
      apply (rule exI[where x="{}"]) by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3236
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3237
    fix c x y
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3238
    assume x: "x \<in> P" and hy: "?h y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3239
    from hy obtain S u where fS: "finite S" and SP: "S\<subseteq>P"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3240
      and u: "setsum (\<lambda>v. u v *s v) S = y" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3241
    let ?S = "insert x S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3242
    let ?u = "\<lambda>y. if y = x then (if x \<in> S then u y + c else c)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3243
                  else u y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3244
    from fS SP x have th0: "finite (insert x S)" "insert x S \<subseteq> P" by blast+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3245
    {assume xS: "x \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3246
      have S1: "S = (S - {x}) \<union> {x}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3247
        and Sss:"finite (S - {x})" "finite {x}" "(S -{x}) \<inter> {x} = {}" using xS fS by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3248
      have "setsum (\<lambda>v. ?u v *s v) ?S =(\<Sum>v\<in>S - {x}. u v *s v) + (u x + c) *s x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3249
        using xS
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3250
        by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3251
          setsum_clauses(2)[OF fS] cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3252
      also have "\<dots> = (\<Sum>v\<in>S. u v *s v) + c *s x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3253
        apply (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3254
        by (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3255
      also have "\<dots> = c*s x + y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3256
        by (simp add: add_commute u)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3257
      finally have "setsum (\<lambda>v. ?u v *s v) ?S = c*s x + y" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3258
    then have "?Q ?S ?u (c*s x + y)" using th0 by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3259
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3260
  {assume xS: "x \<notin> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3261
    have th00: "(\<Sum>v\<in>S. (if v = x then c else u v) *s v) = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3262
      unfolding u[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3263
      apply (rule setsum_cong2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3264
      using xS by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3265
    have "?Q ?S ?u (c*s x + y)" using fS xS th0
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3266
      by (simp add: th00 setsum_clauses add_commute cong del: if_weak_cong)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3267
  ultimately have "?Q ?S ?u (c*s x + y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3268
    by (cases "x \<in> S", simp, simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3269
    then show "?h (c*s x + y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3270
      apply -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3271
      apply (rule exI[where x="?S"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3272
      apply (rule exI[where x="?u"]) by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3273
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3274
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3275
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3276
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3277
lemma dependent_explicit:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3278
  "dependent P \<longleftrightarrow> (\<exists>S u. finite S \<and> S \<subseteq> P \<and> (\<exists>(v::'a::{idom,field}^_) \<in>S. u v \<noteq> 0 \<and> setsum (\<lambda>v. u v *s v) S = 0))" (is "?lhs = ?rhs")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3279
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3280
  {assume dP: "dependent P"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3281
    then obtain a S u where aP: "a \<in> P" and fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3282
      and SP: "S \<subseteq> P - {a}" and ua: "setsum (\<lambda>v. u v *s v) S = a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3283
      unfolding dependent_def span_explicit by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3284
    let ?S = "insert a S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3285
    let ?u = "\<lambda>y. if y = a then - 1 else u y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3286
    let ?v = a
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3287
    from aP SP have aS: "a \<notin> S" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3288
    from fS SP aP have th0: "finite ?S" "?S \<subseteq> P" "?v \<in> ?S" "?u ?v \<noteq> 0" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3289
    have s0: "setsum (\<lambda>v. ?u v *s v) ?S = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3290
      using fS aS
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3291
      apply (simp add: vector_smult_lneg vector_smult_lid setsum_clauses ring_simps )
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3292
      apply (subst (2) ua[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3293
      apply (rule setsum_cong2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3294
      by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3295
    with th0 have ?rhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3296
      apply -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3297
      apply (rule exI[where x= "?S"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3298
      apply (rule exI[where x= "?u"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3299
      by clarsimp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3300
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3301
  {fix S u v assume fS: "finite S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3302
      and SP: "S \<subseteq> P" and vS: "v \<in> S" and uv: "u v \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3303
    and u: "setsum (\<lambda>v. u v *s v) S = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3304
    let ?a = v
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3305
    let ?S = "S - {v}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3306
    let ?u = "\<lambda>i. (- u i) / u v"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3307
    have th0: "?a \<in> P" "finite ?S" "?S \<subseteq> P"       using fS SP vS by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3308
    have "setsum (\<lambda>v. ?u v *s v) ?S = setsum (\<lambda>v. (- (inverse (u ?a))) *s (u v *s v)) S - ?u v *s v"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3309
      using fS vS uv
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3310
      by (simp add: setsum_diff1 vector_smult_lneg divide_inverse
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3311
        vector_smult_assoc field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3312
    also have "\<dots> = ?a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3313
      unfolding setsum_cmul u
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3314
      using uv by (simp add: vector_smult_lneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3315
    finally  have "setsum (\<lambda>v. ?u v *s v) ?S = ?a" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3316
    with th0 have ?lhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3317
      unfolding dependent_def span_explicit
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3318
      apply -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3319
      apply (rule bexI[where x= "?a"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3320
      apply simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3321
      apply (rule exI[where x= "?S"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3322
      by auto}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3323
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3324
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3325
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3326
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3327
lemma span_finite:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3328
  assumes fS: "finite S"
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3329
  shows "span S = {(y::'a::semiring_1^_). \<exists>u. setsum (\<lambda>v. u v *s v) S = y}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3330
  (is "_ = ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3331
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3332
  {fix y assume y: "y \<in> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3333
    from y obtain S' u where fS': "finite S'" and SS': "S' \<subseteq> S" and
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3334
      u: "setsum (\<lambda>v. u v *s v) S' = y" unfolding span_explicit by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3335
    let ?u = "\<lambda>x. if x \<in> S' then u x else 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3336
    from setsum_restrict_set[OF fS, of "\<lambda>v. u v *s v" S', symmetric] SS'
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3337
    have "setsum (\<lambda>v. ?u v *s v) S = setsum (\<lambda>v. u v *s v) S'"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3338
      unfolding cond_value_iff cond_application_beta
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3339
      by (simp add: cond_value_iff inf_absorb2 cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3340
    hence "setsum (\<lambda>v. ?u v *s v) S = y" by (metis u)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3341
    hence "y \<in> ?rhs" by auto}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3342
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3343
  {fix y u assume u: "setsum (\<lambda>v. u v *s v) S = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3344
    then have "y \<in> span S" using fS unfolding span_explicit by auto}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3345
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3346
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3347
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3348
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3349
(* Standard bases are a spanning set, and obviously finite.                  *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3350
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3351
lemma span_stdbasis:"span {basis i :: 'a::ring_1^'n | i. i \<in> (UNIV :: 'n set)} = UNIV"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3352
apply (rule set_ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3353
apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3354
apply (subst basis_expansion[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3355
apply (rule span_setsum)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3356
apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3357
apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3358
apply (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3359
apply (rule span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3360
apply (auto simp add: Collect_def mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3361
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3362
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3363
lemma finite_stdbasis: "finite {basis i ::real^'n |i. i\<in> (UNIV:: 'n set)}" (is "finite ?S")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3364
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3365
  have eq: "?S = basis ` UNIV" by blast
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3366
  show ?thesis unfolding eq by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3367
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3368
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3369
lemma card_stdbasis: "card {basis i ::real^'n |i. i\<in> (UNIV :: 'n set)} = CARD('n)" (is "card ?S = _")
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3370
proof-
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3371
  have eq: "?S = basis ` UNIV" by blast
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3372
  show ?thesis unfolding eq using card_image[OF basis_inj] by simp
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3373
qed
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3374
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3375
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3376
lemma independent_stdbasis_lemma:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3377
  assumes x: "(x::'a::semiring_1 ^ _) \<in> span (basis ` S)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3378
  and iS: "i \<notin> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3379
  shows "(x$i) = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3380
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3381
  let ?U = "UNIV :: 'n set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3382
  let ?B = "basis ` S"
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3383
  let ?P = "\<lambda>(x::'a^_). \<forall>i\<in> ?U. i \<notin> S \<longrightarrow> x$i =0"
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3384
 {fix x::"'a^_" assume xS: "x\<in> ?B"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3385
   from xS have "?P x" by auto}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3386
 moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3387
 have "subspace ?P"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3388
   by (auto simp add: subspace_def Collect_def mem_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3389
 ultimately show ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3390
   using x span_induct[of ?B ?P x] iS by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3391
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3392
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3393
lemma independent_stdbasis: "independent {basis i ::real^'n |i. i\<in> (UNIV :: 'n set)}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3394
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3395
  let ?I = "UNIV :: 'n set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3396
  let ?b = "basis :: _ \<Rightarrow> real ^'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3397
  let ?B = "?b ` ?I"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3398
  have eq: "{?b i|i. i \<in> ?I} = ?B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3399
    by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3400
  {assume d: "dependent ?B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3401
    then obtain k where k: "k \<in> ?I" "?b k \<in> span (?B - {?b k})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3402
      unfolding dependent_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3403
    have eq1: "?B - {?b k} = ?B - ?b ` {k}"  by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3404
    have eq2: "?B - {?b k} = ?b ` (?I - {k})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3405
      unfolding eq1
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3406
      apply (rule inj_on_image_set_diff[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3407
      apply (rule basis_inj) using k(1) by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3408
    from k(2) have th0: "?b k \<in> span (?b ` (?I - {k}))" unfolding eq2 .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3409
    from independent_stdbasis_lemma[OF th0, of k, simplified]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3410
    have False by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3411
  then show ?thesis unfolding eq dependent_def ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3412
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3413
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3414
(* This is useful for building a basis step-by-step.                         *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3415
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3416
lemma independent_insert:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3417
  "independent(insert (a::'a::field ^_) S) \<longleftrightarrow>
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3418
      (if a \<in> S then independent S
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3419
                else independent S \<and> a \<notin> span S)" (is "?lhs \<longleftrightarrow> ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3420
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3421
  {assume aS: "a \<in> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3422
    hence ?thesis using insert_absorb[OF aS] by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3423
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3424
  {assume aS: "a \<notin> S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3425
    {assume i: ?lhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3426
      then have ?rhs using aS
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3427
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3428
        apply (rule conjI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3429
        apply (rule independent_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3430
        apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3431
        apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3432
        by (simp add: dependent_def)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3433
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3434
    {assume i: ?rhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3435
      have ?lhs using i aS
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3436
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3437
        apply (auto simp add: dependent_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3438
        apply (case_tac "aa = a", auto)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3439
        apply (subgoal_tac "insert a S - {aa} = insert a (S - {aa})")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3440
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3441
        apply (subgoal_tac "a \<in> span (insert aa (S - {aa}))")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3442
        apply (subgoal_tac "insert aa (S - {aa}) = S")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3443
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3444
        apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3445
        apply (rule in_span_insert)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3446
        apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3447
        apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3448
        apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3449
        done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3450
    ultimately have ?thesis by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3451
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3452
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3453
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3454
(* The degenerate case of the Exchange Lemma.  *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3455
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3456
lemma mem_delete: "x \<in> (A - {a}) \<longleftrightarrow> x \<noteq> a \<and> x \<in> A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3457
  by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3458
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3459
lemma span_span: "span (span A) = span A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3460
  unfolding span_def hull_hull ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3461
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3462
lemma span_inc: "S \<subseteq> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3463
  by (metis subset_eq span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3464
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3465
lemma spanning_subset_independent:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3466
  assumes BA: "B \<subseteq> A" and iA: "independent (A::('a::field ^_) set)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3467
  and AsB: "A \<subseteq> span B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3468
  shows "A = B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3469
proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3470
  from BA show "B \<subseteq> A" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3471
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3472
  from span_mono[OF BA] span_mono[OF AsB]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3473
  have sAB: "span A = span B" unfolding span_span by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3474
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3475
  {fix x assume x: "x \<in> A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3476
    from iA have th0: "x \<notin> span (A - {x})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3477
      unfolding dependent_def using x by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3478
    from x have xsA: "x \<in> span A" by (blast intro: span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3479
    have "A - {x} \<subseteq> A" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3480
    hence th1:"span (A - {x}) \<subseteq> span A" by (metis span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3481
    {assume xB: "x \<notin> B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3482
      from xB BA have "B \<subseteq> A -{x}" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3483
      hence "span B \<subseteq> span (A - {x})" by (metis span_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3484
      with th1 th0 sAB have "x \<notin> span A" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3485
      with x have False by (metis span_superset)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3486
    then have "x \<in> B" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3487
  then show "A \<subseteq> B" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3488
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3489
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3490
(* The general case of the Exchange Lemma, the key to what follows.  *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3491
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3492
lemma exchange_lemma:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3493
  assumes f:"finite (t:: ('a::field^'n) set)" and i: "independent s"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3494
  and sp:"s \<subseteq> span t"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3495
  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'"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3496
using f i sp
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3497
proof(induct "card (t - s)" arbitrary: s t rule: less_induct)
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3498
  case less
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3499
  note ft = `finite t` and s = `independent s` and sp = `s \<subseteq> span t`
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3500
  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'"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3501
  let ?ths = "\<exists>t'. ?P t'"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3502
  {assume st: "s \<subseteq> t"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3503
    from st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3504
      by (auto intro: span_superset)}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3505
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3506
  {assume st: "t \<subseteq> s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3507
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3508
    from spanning_subset_independent[OF st s sp]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3509
      st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3510
      by (auto intro: span_superset)}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3511
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3512
  {assume st: "\<not> s \<subseteq> t" "\<not> t \<subseteq> s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3513
    from st(2) obtain b where b: "b \<in> t" "b \<notin> s" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3514
      from b have "t - {b} - s \<subset> t - s" by blast
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3515
      then have cardlt: "card (t - {b} - s) < card (t - s)" using ft
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3516
        by (auto intro: psubset_card_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3517
      from b ft have ct0: "card t \<noteq> 0" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3518
    {assume stb: "s \<subseteq> span(t -{b})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3519
      from ft have ftb: "finite (t -{b})" by auto
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3520
      from less(1)[OF cardlt ftb s stb]
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3521
      obtain u where u: "card u = card (t-{b})" "s \<subseteq> u" "u \<subseteq> s \<union> (t - {b})" "s \<subseteq> span u" and fu: "finite u" by blast
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3522
      let ?w = "insert b u"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3523
      have th0: "s \<subseteq> insert b u" using u by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3524
      from u(3) b have "u \<subseteq> s \<union> t" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3525
      then have th1: "insert b u \<subseteq> s \<union> t" using u b by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3526
      have bu: "b \<notin> u" using b u by blast
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3527
      from u(1) ft b have "card u = (card t - 1)" by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3528
      then
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3529
      have th2: "card (insert b u) = card t"
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3530
        using card_insert_disjoint[OF fu bu] ct0 by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3531
      from u(4) have "s \<subseteq> span u" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3532
      also have "\<dots> \<subseteq> span (insert b u)" apply (rule span_mono) by blast
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3533
      finally have th3: "s \<subseteq> span (insert b u)" .
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3534
      from th0 th1 th2 th3 fu have th: "?P ?w"  by blast
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3535
      from th have ?ths by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3536
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3537
    {assume stb: "\<not> s \<subseteq> span(t -{b})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3538
      from stb obtain a where a: "a \<in> s" "a \<notin> span (t - {b})" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3539
      have ab: "a \<noteq> b" using a b by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3540
      have at: "a \<notin> t" using a ab span_superset[of a "t- {b}"] by auto
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3541
      have mlt: "card ((insert a (t - {b})) - s) < card (t - s)"
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3542
        using cardlt ft a b by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3543
      have ft': "finite (insert a (t - {b}))" using ft by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3544
      {fix x assume xs: "x \<in> s"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3545
        have t: "t \<subseteq> (insert b (insert a (t -{b})))" using b by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3546
        from b(1) have "b \<in> span t" by (simp add: span_superset)
35541
himmelma
parents: 35540
diff changeset
  3547
        have bs: "b \<in> span (insert a (t - {b}))" apply(rule in_span_delete)
himmelma
parents: 35540
diff changeset
  3548
          using  a sp unfolding subset_eq by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3549
        from xs sp have "x \<in> span t" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3550
        with span_mono[OF t]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3551
        have x: "x \<in> span (insert b (insert a (t - {b})))" ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3552
        from span_trans[OF bs x] have "x \<in> span (insert a (t - {b}))"  .}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3553
      then have sp': "s \<subseteq> span (insert a (t - {b}))" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3554
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3555
      from less(1)[OF mlt ft' s sp'] obtain u where
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3556
        u: "card u = card (insert a (t -{b}))" "finite u" "s \<subseteq> u" "u \<subseteq> s \<union> insert a (t -{b})"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3557
        "s \<subseteq> span u" by blast
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3558
      from u a b ft at ct0 have "?P u" by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3559
      then have ?ths by blast }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3560
    ultimately have ?ths by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3561
  }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3562
  ultimately
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3563
  show ?ths  by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3564
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3565
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3566
(* This implies corresponding size bounds.                                   *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3567
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3568
lemma independent_span_bound:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3569
  assumes f: "finite t" and i: "independent (s::('a::field^_) set)" and sp:"s \<subseteq> span t"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3570
  shows "finite s \<and> card s \<le> card t"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3571
  by (metis exchange_lemma[OF f i sp] finite_subset card_mono)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3572
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3573
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3574
lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x\<in> (UNIV::'a::finite set)}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3575
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3576
  have eq: "{f x |x. x\<in> UNIV} = f ` UNIV" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3577
  show ?thesis unfolding eq
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3578
    apply (rule finite_imageI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3579
    apply (rule finite)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3580
    done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3581
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3582
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3583
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3584
lemma independent_bound:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3585
  fixes S:: "(real^'n) set"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3586
  shows "independent S \<Longrightarrow> finite S \<and> card S <= CARD('n)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3587
  apply (subst card_stdbasis[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3588
  apply (rule independent_span_bound)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3589
  apply (rule finite_Atleast_Atmost_nat)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3590
  apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3591
  unfolding span_stdbasis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3592
  apply (rule subset_UNIV)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3593
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3594
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3595
lemma dependent_biggerset: "(finite (S::(real ^'n) set) ==> card S > CARD('n)) ==> dependent S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3596
  by (metis independent_bound not_less)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3597
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3598
(* Hence we can create a maximal independent subset.                         *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3599
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3600
lemma maximal_independent_subset_extend:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3601
  assumes sv: "(S::(real^'n) set) \<subseteq> V" and iS: "independent S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3602
  shows "\<exists>B. S \<subseteq> B \<and> B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3603
  using sv iS
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3604
proof(induct "CARD('n) - card S" arbitrary: S rule: less_induct)
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3605
  case less
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3606
  note sv = `S \<subseteq> V` and i = `independent S`
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3607
  let ?P = "\<lambda>B. S \<subseteq> B \<and> B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3608
  let ?ths = "\<exists>x. ?P x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3609
  let ?d = "CARD('n)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3610
  {assume "V \<subseteq> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3611
    then have ?ths  using sv i by blast }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3612
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3613
  {assume VS: "\<not> V \<subseteq> span S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3614
    from VS obtain a where a: "a \<in> V" "a \<notin> span S" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3615
    from a have aS: "a \<notin> S" by (auto simp add: span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3616
    have th0: "insert a S \<subseteq> V" using a sv by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3617
    from independent_insert[of a S]  i a
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3618
    have th1: "independent (insert a S)" by auto
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3619
    have mlt: "?d - card (insert a S) < ?d - card S"
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3620
      using aS a independent_bound[OF th1]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3621
      by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3622
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 34292
diff changeset
  3623
    from less(1)[OF mlt th0 th1]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3624
    obtain B where B: "insert a S \<subseteq> B" "B \<subseteq> V" "independent B" " V \<subseteq> span B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3625
      by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3626
    from B have "?P B" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3627
    then have ?ths by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3628
  ultimately show ?ths by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3629
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3630
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3631
lemma maximal_independent_subset:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3632
  "\<exists>(B:: (real ^'n) set). B\<subseteq> V \<and> independent B \<and> V \<subseteq> span B"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3633
  by (metis maximal_independent_subset_extend[of "{}:: (real ^'n) set"] empty_subsetI independent_empty)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3634
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3635
(* Notion of dimension.                                                      *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3636
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3637
definition "dim V = (SOME n. \<exists>B. B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (card B = n))"
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3638
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3639
lemma basis_exists:  "\<exists>B. (B :: (real ^'n) set) \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (card B = dim V)"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3640
unfolding dim_def some_eq_ex[of "\<lambda>n. \<exists>B. B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (card B = n)"]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3641
using maximal_independent_subset[of V] independent_bound
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3642
by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3643
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3644
(* Consequences of independence or spanning for cardinality.                 *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3645
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3646
lemma independent_card_le_dim: 
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3647
  assumes "(B::(real ^'n) set) \<subseteq> V" and "independent B" shows "card B \<le> dim V"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3648
proof -
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3649
  from basis_exists[of V] `B \<subseteq> V`
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3650
  obtain B' where "independent B'" and "B \<subseteq> span B'" and "card B' = dim V" by blast
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3651
  with independent_span_bound[OF _ `independent B` `B \<subseteq> span B'`] independent_bound[of B']
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3652
  show ?thesis by auto
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3653
qed
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3654
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3655
lemma span_card_ge_dim:  "(B::(real ^'n) set) \<subseteq> V \<Longrightarrow> V \<subseteq> span B \<Longrightarrow> finite B \<Longrightarrow> dim V \<le> card B"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3656
  by (metis basis_exists[of V] independent_span_bound subset_trans)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3657
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3658
lemma basis_card_eq_dim:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3659
  "B \<subseteq> (V:: (real ^'n) set) \<Longrightarrow> V \<subseteq> span B \<Longrightarrow> independent B \<Longrightarrow> finite B \<and> card B = dim V"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3660
  by (metis order_eq_iff independent_card_le_dim span_card_ge_dim independent_mono independent_bound)
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3661
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3662
lemma dim_unique: "(B::(real ^'n) set) \<subseteq> V \<Longrightarrow> V \<subseteq> span B \<Longrightarrow> independent B \<Longrightarrow> card B = n \<Longrightarrow> dim V = n"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3663
  by (metis basis_card_eq_dim)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3664
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3665
(* More lemmas about dimension.                                              *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3666
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3667
lemma dim_univ: "dim (UNIV :: (real^'n) set) = CARD('n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3668
  apply (rule dim_unique[of "{basis i |i. i\<in> (UNIV :: 'n set)}"])
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3669
  by (auto simp only: span_stdbasis card_stdbasis finite_stdbasis independent_stdbasis)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3670
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3671
lemma dim_subset:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3672
  "(S:: (real ^'n) set) \<subseteq> T \<Longrightarrow> dim S \<le> dim T"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3673
  using basis_exists[of T] basis_exists[of S]
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3674
  by (metis independent_card_le_dim subset_trans)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3675
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3676
lemma dim_subset_univ: "dim (S:: (real^'n) set) \<le> CARD('n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3677
  by (metis dim_subset subset_UNIV dim_univ)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3678
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3679
(* Converses to those.                                                       *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3680
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3681
lemma card_ge_dim_independent:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3682
  assumes BV:"(B::(real ^'n) set) \<subseteq> V" and iB:"independent B" and dVB:"dim V \<le> card B"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3683
  shows "V \<subseteq> span B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3684
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3685
  {fix a assume aV: "a \<in> V"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3686
    {assume aB: "a \<notin> span B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3687
      then have iaB: "independent (insert a B)" using iB aV  BV by (simp add: independent_insert)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3688
      from aV BV have th0: "insert a B \<subseteq> V" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3689
      from aB have "a \<notin>B" by (auto simp add: span_superset)
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3690
      with independent_card_le_dim[OF th0 iaB] dVB independent_bound[OF iB] have False by auto }
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3691
    then have "a \<in> span B"  by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3692
  then show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3693
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3694
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3695
lemma card_le_dim_spanning:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3696
  assumes BV: "(B:: (real ^'n) set) \<subseteq> V" and VB: "V \<subseteq> span B"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3697
  and fB: "finite B" and dVB: "dim V \<ge> card B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3698
  shows "independent B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3699
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3700
  {fix a assume a: "a \<in> B" "a \<in> span (B -{a})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3701
    from a fB have c0: "card B \<noteq> 0" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3702
    from a fB have cb: "card (B -{a}) = card B - 1" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3703
    from BV a have th0: "B -{a} \<subseteq> V" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3704
    {fix x assume x: "x \<in> V"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3705
      from a have eq: "insert a (B -{a}) = B" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3706
      from x VB have x': "x \<in> span B" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3707
      from span_trans[OF a(2), unfolded eq, OF x']
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3708
      have "x \<in> span (B -{a})" . }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3709
    then have th1: "V \<subseteq> span (B -{a})" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3710
    have th2: "finite (B -{a})" using fB by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3711
    from span_card_ge_dim[OF th0 th1 th2]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3712
    have c: "dim V \<le> card (B -{a})" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3713
    from c c0 dVB cb have False by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3714
  then show ?thesis unfolding dependent_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3715
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3716
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3717
lemma card_eq_dim: "(B:: (real ^'n) set) \<subseteq> V \<Longrightarrow> card B = dim V \<Longrightarrow> finite B \<Longrightarrow> independent B \<longleftrightarrow> V \<subseteq> span B"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3718
  by (metis order_eq_iff card_le_dim_spanning
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3719
    card_ge_dim_independent)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3720
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3721
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3722
(* More general size bound lemmas.                                           *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3723
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3724
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3725
lemma independent_bound_general:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3726
  "independent (S:: (real^'n) set) \<Longrightarrow> finite S \<and> card S \<le> dim S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3727
  by (metis independent_card_le_dim independent_bound subset_refl)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3728
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3729
lemma dependent_biggerset_general: "(finite (S:: (real^'n) set) \<Longrightarrow> card S > dim S) \<Longrightarrow> dependent S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3730
  using independent_bound_general[of S] by (metis linorder_not_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3731
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3732
lemma dim_span: "dim (span (S:: (real ^'n) set)) = dim S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3733
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3734
  have th0: "dim S \<le> dim (span S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3735
    by (auto simp add: subset_eq intro: dim_subset span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3736
  from basis_exists[of S]
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3737
  obtain B where B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "card B = dim S" by blast
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3738
  from B have fB: "finite B" "card B = dim S" using independent_bound by blast+
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3739
  have bSS: "B \<subseteq> span S" using B(1) by (metis subset_eq span_inc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3740
  have sssB: "span S \<subseteq> span B" using span_mono[OF B(3)] by (simp add: span_span)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3741
  from span_card_ge_dim[OF bSS sssB fB(1)] th0 show ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3742
    using fB(2)  by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3743
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3744
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3745
lemma subset_le_dim: "(S:: (real ^'n) set) \<subseteq> span T \<Longrightarrow> dim S \<le> dim T"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3746
  by (metis dim_span dim_subset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3747
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3748
lemma span_eq_dim: "span (S:: (real ^'n) set) = span T ==> dim S = dim T"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3749
  by (metis dim_span)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3750
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3751
lemma spans_image:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3752
  assumes lf: "linear (f::'a::semiring_1^_ \<Rightarrow> _)" and VB: "V \<subseteq> span B"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3753
  shows "f ` V \<subseteq> span (f ` B)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3754
  unfolding span_linear_image[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3755
  by (metis VB image_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3756
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3757
lemma dim_image_le:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3758
  fixes f :: "real^'n \<Rightarrow> real^'m"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3759
  assumes lf: "linear f" shows "dim (f ` S) \<le> dim (S:: (real ^'n) set)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3760
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3761
  from basis_exists[of S] obtain B where
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3762
    B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "card B = dim S" by blast
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3763
  from B have fB: "finite B" "card B = dim S" using independent_bound by blast+
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3764
  have "dim (f ` S) \<le> card (f ` B)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3765
    apply (rule span_card_ge_dim)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3766
    using lf B fB by (auto simp add: span_linear_image spans_image subset_image_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3767
  also have "\<dots> \<le> dim S" using card_image_le[OF fB(1)] fB by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3768
  finally show ?thesis .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3769
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3770
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3771
(* Relation between bases and injectivity/surjectivity of map.               *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3772
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3773
lemma spanning_surjective_image:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3774
  assumes us: "UNIV \<subseteq> span (S:: ('a::semiring_1 ^_) set)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3775
  and lf: "linear f" and sf: "surj f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3776
  shows "UNIV \<subseteq> span (f ` S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3777
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3778
  have "UNIV \<subseteq> f ` UNIV" using sf by (auto simp add: surj_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3779
  also have " \<dots> \<subseteq> span (f ` S)" using spans_image[OF lf us] .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3780
finally show ?thesis .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3781
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3782
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3783
lemma independent_injective_image:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3784
  assumes iS: "independent (S::('a::semiring_1^_) set)" and lf: "linear f" and fi: "inj f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3785
  shows "independent (f ` S)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3786
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3787
  {fix a assume a: "a \<in> S" "f a \<in> span (f ` S - {f a})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3788
    have eq: "f ` S - {f a} = f ` (S - {a})" using fi
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3789
      by (auto simp add: inj_on_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3790
    from a have "f a \<in> f ` span (S -{a})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3791
      unfolding eq span_linear_image[OF lf, of "S - {a}"]  by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3792
    hence "a \<in> span (S -{a})" using fi by (auto simp add: inj_on_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3793
    with a(1) iS  have False by (simp add: dependent_def) }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3794
  then show ?thesis unfolding dependent_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3795
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3796
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3797
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3798
(* Picking an orthogonal replacement for a spanning set.                     *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3799
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3800
    (* FIXME : Move to some general theory ?*)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3801
definition "pairwise R S \<longleftrightarrow> (\<forall>x \<in> S. \<forall>y\<in> S. x\<noteq>y \<longrightarrow> R x y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3802
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3803
lemma vector_sub_project_orthogonal: "(b::real^'n) \<bullet> (x - ((b \<bullet> x) / (b \<bullet> b)) *s b) = 0"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3804
  unfolding inner_simps smult_conv_scaleR by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3805
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3806
lemma basis_orthogonal:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3807
  fixes B :: "(real ^'n) set"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3808
  assumes fB: "finite B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3809
  shows "\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3810
  (is " \<exists>C. ?P B C")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3811
proof(induct rule: finite_induct[OF fB])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3812
  case 1 thus ?case apply (rule exI[where x="{}"]) by (auto simp add: pairwise_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3813
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3814
  case (2 a B)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3815
  note fB = `finite B` and aB = `a \<notin> B`
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3816
  from `\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C`
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3817
  obtain C where C: "finite C" "card C \<le> card B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3818
    "span C = span B" "pairwise orthogonal C" by blast
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3819
  let ?a = "a - setsum (\<lambda>x. (x \<bullet> a / (x \<bullet> x)) *s x) C"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3820
  let ?C = "insert ?a C"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3821
  from C(1) have fC: "finite ?C" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3822
  from fB aB C(1,2) have cC: "card ?C \<le> card (insert a B)" by (simp add: card_insert_if)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3823
  {fix x k
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3824
    have th0: "\<And>(a::'b::comm_ring) b c. a - (b - c) = c + (a - b)" by (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3825
    have "x - k *s (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *s x)) \<in> span C \<longleftrightarrow> x - k *s a \<in> span C"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3826
      apply (simp only: vector_ssub_ldistrib th0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3827
      apply (rule span_add_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3828
      apply (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3829
      apply (rule span_setsum[OF C(1)])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3830
      apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3831
      apply (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3832
      by (rule span_superset)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3833
  then have SC: "span ?C = span (insert a B)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3834
    unfolding expand_set_eq span_breakdown_eq C(3)[symmetric] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3835
  thm pairwise_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3836
  {fix x y assume xC: "x \<in> ?C" and yC: "y \<in> ?C" and xy: "x \<noteq> y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3837
    {assume xa: "x = ?a" and ya: "y = ?a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3838
      have "orthogonal x y" using xa ya xy by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3839
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3840
    {assume xa: "x = ?a" and ya: "y \<noteq> ?a" "y \<in> C"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3841
      from ya have Cy: "C = insert y (C - {y})" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3842
      have fth: "finite (C - {y})" using C by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3843
      have "orthogonal x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3844
        using xa ya
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3845
        unfolding orthogonal_def xa inner_simps diff_eq_0_iff_eq
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3846
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3847
        apply (subst Cy)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3848
        using C(1) fth
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3849
        apply (simp only: setsum_clauses) unfolding smult_conv_scaleR
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3850
        apply (auto simp add: inner_simps inner_eq_zero_iff inner_commute[of y a] dot_lsum[OF fth])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3851
        apply (rule setsum_0')
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3852
        apply clarsimp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3853
        apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3854
        by auto}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3855
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3856
    {assume xa: "x \<noteq> ?a" "x \<in> C" and ya: "y = ?a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3857
      from xa have Cx: "C = insert x (C - {x})" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3858
      have fth: "finite (C - {x})" using C by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3859
      have "orthogonal x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3860
        using xa ya
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3861
        unfolding orthogonal_def ya inner_simps diff_eq_0_iff_eq
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3862
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3863
        apply (subst Cx)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3864
        using C(1) fth
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3865
        apply (simp only: setsum_clauses) unfolding smult_conv_scaleR
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3866
        apply (subst inner_commute[of x])
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3867
        apply (auto simp add: inner_simps inner_eq_zero_iff inner_commute[of x a] dot_rsum[OF fth])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3868
        apply (rule setsum_0')
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3869
        apply clarsimp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3870
        apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3871
        by auto}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3872
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3873
    {assume xa: "x \<in> C" and ya: "y \<in> C"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3874
      have "orthogonal x y" using xa ya xy C(4) unfolding pairwise_def by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3875
    ultimately have "orthogonal x y" using xC yC by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3876
  then have CPO: "pairwise orthogonal ?C" unfolding pairwise_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3877
  from fC cC SC CPO have "?P (insert a B) ?C" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3878
  then show ?case by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3879
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3880
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3881
lemma orthogonal_basis_exists:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3882
  fixes V :: "(real ^'n) set"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3883
  shows "\<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> (card B = dim V) \<and> pairwise orthogonal B"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3884
proof-
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3885
  from basis_exists[of V] obtain B where B: "B \<subseteq> V" "independent B" "V \<subseteq> span B" "card B = dim V" by blast
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3886
  from B have fB: "finite B" "card B = dim V" using independent_bound by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3887
  from basis_orthogonal[OF fB(1)] obtain C where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3888
    C: "finite C" "card C \<le> card B" "span C = span B" "pairwise orthogonal C" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3889
  from C B
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3890
  have CSV: "C \<subseteq> span V" by (metis span_inc span_mono subset_trans)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3891
  from span_mono[OF B(3)]  C have SVC: "span V \<subseteq> span C" by (simp add: span_span)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3892
  from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3893
  have iC: "independent C" by (simp add: dim_span)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3894
  from C fB have "card C \<le> dim V" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3895
  moreover have "dim V \<le> card C" using span_card_ge_dim[OF CSV SVC C(1)]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3896
    by (simp add: dim_span)
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3897
  ultimately have CdV: "card C = dim V" using C(1) by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3898
  from C B CSV CdV iC show ?thesis by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3899
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3900
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3901
lemma span_eq: "span S = span T \<longleftrightarrow> S \<subseteq> span T \<and> T \<subseteq> span S"
35541
himmelma
parents: 35540
diff changeset
  3902
  using span_inc[unfolded subset_eq] using span_mono[of T "span S"] span_mono[of S "span T"]
himmelma
parents: 35540
diff changeset
  3903
  by(auto simp add: span_span)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3904
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3905
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3906
(* Low-dimensional subset is in a hyperplane (weak orthogonal complement).   *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3907
(* ------------------------------------------------------------------------- *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3908
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3909
lemma span_not_univ_orthogonal:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3910
  assumes sU: "span S \<noteq> UNIV"
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3911
  shows "\<exists>(a:: real ^'n). a \<noteq>0 \<and> (\<forall>x \<in> span S. a \<bullet> x = 0)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3912
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3913
  from sU obtain a where a: "a \<notin> span S" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3914
  from orthogonal_basis_exists obtain B where
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3915
    B: "independent B" "B \<subseteq> span S" "S \<subseteq> span B" "card B = dim S" "pairwise orthogonal B"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3916
    by blast
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  3917
  from B have fB: "finite B" "card B = dim S" using independent_bound by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3918
  from span_mono[OF B(2)] span_mono[OF B(3)]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3919
  have sSB: "span S = span B" by (simp add: span_span)
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3920
  let ?a = "a - setsum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *s b) B"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3921
  have "setsum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *s b) B \<in> span S"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3922
    unfolding sSB
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3923
    apply (rule span_setsum[OF fB(1)])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3924
    apply clarsimp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3925
    apply (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3926
    by (rule span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3927
  with a have a0:"?a  \<noteq> 0" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3928
  have "\<forall>x\<in>span B. ?a \<bullet> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3929
  proof(rule span_induct')
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3930
    show "subspace (\<lambda>x. ?a \<bullet> x = 0)" by (auto simp add: subspace_def mem_def inner_simps smult_conv_scaleR)
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3931
  
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3932
next
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3933
    {fix x assume x: "x \<in> B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3934
      from x have B': "B = insert x (B - {x})" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3935
      have fth: "finite (B - {x})" using fB by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3936
      have "?a \<bullet> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3937
        apply (subst B') using fB fth
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3938
        unfolding setsum_clauses(2)[OF fth]
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3939
        apply simp unfolding inner_simps smult_conv_scaleR
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3940
        apply (clarsimp simp add: inner_simps inner_eq_zero_iff smult_conv_scaleR dot_lsum)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3941
        apply (rule setsum_0', rule ballI)
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3942
        unfolding inner_commute
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  3943
        by (auto simp add: x field_simps inner_eq_zero_iff intro: B(5)[unfolded pairwise_def orthogonal_def, rule_format])}
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3944
    then show "\<forall>x \<in> B. ?a \<bullet> x = 0" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3945
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3946
  with a0 show ?thesis unfolding sSB by (auto intro: exI[where x="?a"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3947
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3948
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3949
lemma span_not_univ_subset_hyperplane:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3950
  assumes SU: "span S \<noteq> (UNIV ::(real^'n) set)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3951
  shows "\<exists> a. a \<noteq>0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3952
  using span_not_univ_orthogonal[OF SU] by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3953
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3954
lemma lowdim_subset_hyperplane:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3955
  assumes d: "dim S < CARD('n::finite)"
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  3956
  shows "\<exists>(a::real ^'n). a  \<noteq> 0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3957
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3958
  {assume "span S = UNIV"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3959
    hence "dim (span S) = dim (UNIV :: (real ^'n) set)" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3960
    hence "dim S = CARD('n)" by (simp add: dim_span dim_univ)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3961
    with d have False by arith}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3962
  hence th: "span S \<noteq> UNIV" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3963
  from span_not_univ_subset_hyperplane[OF th] show ?thesis .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3964
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3965
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3966
(* We can extend a linear basis-basis injection to the whole set.            *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3967
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3968
lemma linear_indep_image_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3969
  assumes lf: "linear f" and fB: "finite B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3970
  and ifB: "independent (f ` B)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3971
  and fi: "inj_on f B" and xsB: "x \<in> span B"
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  3972
  and fx: "f (x::'a::field^_) = 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3973
  shows "x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3974
  using fB ifB fi xsB fx
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3975
proof(induct arbitrary: x rule: finite_induct[OF fB])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3976
  case 1 thus ?case by (auto simp add:  span_empty)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3977
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3978
  case (2 a b x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3979
  have fb: "finite b" using "2.prems" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3980
  have th0: "f ` b \<subseteq> f ` (insert a b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3981
    apply (rule image_mono) by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3982
  from independent_mono[ OF "2.prems"(2) th0]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3983
  have ifb: "independent (f ` b)"  .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3984
  have fib: "inj_on f b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3985
    apply (rule subset_inj_on [OF "2.prems"(3)])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3986
    by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3987
  from span_breakdown[of a "insert a b", simplified, OF "2.prems"(4)]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3988
  obtain k where k: "x - k*s a \<in> span (b -{a})" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3989
  have "f (x - k*s a) \<in> span (f ` b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3990
    unfolding span_linear_image[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3991
    apply (rule imageI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3992
    using k span_mono[of "b-{a}" b] by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3993
  hence "f x - k*s f a \<in> span (f ` b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3994
    by (simp add: linear_sub[OF lf] linear_cmul[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3995
  hence th: "-k *s f a \<in> span (f ` b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3996
    using "2.prems"(5) by (simp add: vector_smult_lneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3997
  {assume k0: "k = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3998
    from k0 k have "x \<in> span (b -{a})" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  3999
    then have "x \<in> span b" using span_mono[of "b-{a}" b]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4000
      by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4001
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4002
  {assume k0: "k \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4003
    from span_mul[OF th, of "- 1/ k"] k0
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4004
    have th1: "f a \<in> span (f ` b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4005
      by (auto simp add: vector_smult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4006
    from inj_on_image_set_diff[OF "2.prems"(3), of "insert a b " "{a}", symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4007
    have tha: "f ` insert a b - f ` {a} = f ` (insert a b - {a})" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4008
    from "2.prems"(2)[unfolded dependent_def bex_simps(10), rule_format, of "f a"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4009
    have "f a \<notin> span (f ` b)" using tha
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4010
      using "2.hyps"(2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4011
      "2.prems"(3) by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4012
    with th1 have False by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4013
    then have "x \<in> span b" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4014
  ultimately have xsb: "x \<in> span b" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4015
  from "2.hyps"(3)[OF fb ifb fib xsb "2.prems"(5)]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4016
  show "x = 0" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4017
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4018
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4019
(* We can extend a linear mapping from basis.                                *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4020
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4021
lemma linear_independent_extend_lemma:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4022
  assumes fi: "finite B" and ib: "independent B"
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4023
  shows "\<exists>g. (\<forall>x\<in> span B. \<forall>y\<in> span B. g ((x::'a::field^'n) + y) = g x + g y)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4024
           \<and> (\<forall>x\<in> span B. \<forall>c. g (c*s x) = c *s g x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4025
           \<and> (\<forall>x\<in> B. g x = f x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4026
using ib fi
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4027
proof(induct rule: finite_induct[OF fi])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4028
  case 1 thus ?case by (auto simp add: span_empty)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4029
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4030
  case (2 a b)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4031
  from "2.prems" "2.hyps" have ibf: "independent b" "finite b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4032
    by (simp_all add: independent_insert)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4033
  from "2.hyps"(3)[OF ibf] obtain g where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4034
    g: "\<forall>x\<in>span b. \<forall>y\<in>span b. g (x + y) = g x + g y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4035
    "\<forall>x\<in>span b. \<forall>c. g (c *s x) = c *s g x" "\<forall>x\<in>b. g x = f x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4036
  let ?h = "\<lambda>z. SOME k. (z - k *s a) \<in> span b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4037
  {fix z assume z: "z \<in> span (insert a b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4038
    have th0: "z - ?h z *s a \<in> span b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4039
      apply (rule someI_ex)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4040
      unfolding span_breakdown_eq[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4041
      using z .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4042
    {fix k assume k: "z - k *s a \<in> span b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4043
      have eq: "z - ?h z *s a - (z - k*s a) = (k - ?h z) *s a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4044
        by (simp add: ring_simps vector_sadd_rdistrib[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4045
      from span_sub[OF th0 k]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4046
      have khz: "(k - ?h z) *s a \<in> span b" by (simp add: eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4047
      {assume "k \<noteq> ?h z" hence k0: "k - ?h z \<noteq> 0" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4048
        from k0 span_mul[OF khz, of "1 /(k - ?h z)"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4049
        have "a \<in> span b" by (simp add: vector_smult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4050
        with "2.prems"(1) "2.hyps"(2) have False
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4051
          by (auto simp add: dependent_def)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4052
      then have "k = ?h z" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4053
    with th0 have "z - ?h z *s a \<in> span b \<and> (\<forall>k. z - k *s a \<in> span b \<longrightarrow> k = ?h z)" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4054
  note h = this
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4055
  let ?g = "\<lambda>z. ?h z *s f a + g (z - ?h z *s a)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4056
  {fix x y assume x: "x \<in> span (insert a b)" and y: "y \<in> span (insert a b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4057
    have tha: "\<And>(x::'a^'n) y a k l. (x + y) - (k + l) *s a = (x - k *s a) + (y - l *s a)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4058
      by (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4059
    have addh: "?h (x + y) = ?h x + ?h y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4060
      apply (rule conjunct2[OF h, rule_format, symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4061
      apply (rule span_add[OF x y])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4062
      unfolding tha
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4063
      by (metis span_add x y conjunct1[OF h, rule_format])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4064
    have "?g (x + y) = ?g x + ?g y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4065
      unfolding addh tha
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4066
      g(1)[rule_format,OF conjunct1[OF h, OF x] conjunct1[OF h, OF y]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4067
      by (simp add: vector_sadd_rdistrib)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4068
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4069
  {fix x:: "'a^'n" and c:: 'a  assume x: "x \<in> span (insert a b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4070
    have tha: "\<And>(x::'a^'n) c k a. c *s x - (c * k) *s a = c *s (x - k *s a)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4071
      by (vector ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4072
    have hc: "?h (c *s x) = c * ?h x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4073
      apply (rule conjunct2[OF h, rule_format, symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4074
      apply (metis span_mul x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4075
      by (metis tha span_mul x conjunct1[OF h])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4076
    have "?g (c *s x) = c*s ?g x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4077
      unfolding hc tha g(2)[rule_format, OF conjunct1[OF h, OF x]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4078
      by (vector ring_simps)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4079
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4080
  {fix x assume x: "x \<in> (insert a b)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4081
    {assume xa: "x = a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4082
      have ha1: "1 = ?h a"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4083
        apply (rule conjunct2[OF h, rule_format])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4084
        apply (metis span_superset insertI1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4085
        using conjunct1[OF h, OF span_superset, OF insertI1]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4086
        by (auto simp add: span_0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4087
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4088
      from xa ha1[symmetric] have "?g x = f x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4089
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4090
        using g(2)[rule_format, OF span_0, of 0]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4091
        by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4092
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4093
    {assume xb: "x \<in> b"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4094
      have h0: "0 = ?h x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4095
        apply (rule conjunct2[OF h, rule_format])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4096
        apply (metis  span_superset insertI1 xb x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4097
        apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4098
        apply (metis span_superset xb)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4099
        done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4100
      have "?g x = f x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4101
        by (simp add: h0[symmetric] g(3)[rule_format, OF xb])}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4102
    ultimately have "?g x = f x" using x by blast }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4103
  ultimately show ?case apply - apply (rule exI[where x="?g"]) by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4104
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4105
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4106
lemma linear_independent_extend:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4107
  assumes iB: "independent (B:: (real ^'n) set)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4108
  shows "\<exists>g. linear g \<and> (\<forall>x\<in>B. g x = f x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4109
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4110
  from maximal_independent_subset_extend[of B UNIV] iB
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4111
  obtain C where C: "B \<subseteq> C" "independent C" "\<And>x. x \<in> span C" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4112
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4113
  from C(2) independent_bound[of C] linear_independent_extend_lemma[of C f]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4114
  obtain g where g: "(\<forall>x\<in> span C. \<forall>y\<in> span C. g (x + y) = g x + g y)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4115
           \<and> (\<forall>x\<in> span C. \<forall>c. g (c*s x) = c *s g x)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4116
           \<and> (\<forall>x\<in> C. g x = f x)" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4117
  from g show ?thesis unfolding linear_def using C
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4118
    apply clarsimp by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4119
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4120
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4121
(* Can construct an isomorphism between spaces of same dimension.            *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4122
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4123
lemma card_le_inj: assumes fA: "finite A" and fB: "finite B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4124
  and c: "card A \<le> card B" shows "(\<exists>f. f ` A \<subseteq> B \<and> inj_on f A)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4125
using fB c
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4126
proof(induct arbitrary: B rule: finite_induct[OF fA])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4127
  case 1 thus ?case by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4128
next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4129
  case (2 x s t)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4130
  thus ?case
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4131
  proof(induct rule: finite_induct[OF "2.prems"(1)])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4132
    case 1    then show ?case by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4133
  next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4134
    case (2 y t)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4135
    from "2.prems"(1,2,5) "2.hyps"(1,2) have cst:"card s \<le> card t" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4136
    from "2.prems"(3) [OF "2.hyps"(1) cst] obtain f where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4137
      f: "f ` s \<subseteq> t \<and> inj_on f s" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4138
    from f "2.prems"(2) "2.hyps"(2) show ?case
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4139
      apply -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4140
      apply (rule exI[where x = "\<lambda>z. if z = x then y else f z"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4141
      by (auto simp add: inj_on_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4142
  qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4143
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4144
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4145
lemma card_subset_eq: assumes fB: "finite B" and AB: "A \<subseteq> B" and
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4146
  c: "card A = card B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4147
  shows "A = B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4148
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4149
  from fB AB have fA: "finite A" by (auto intro: finite_subset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4150
  from fA fB have fBA: "finite (B - A)" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4151
  have e: "A \<inter> (B - A) = {}" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4152
  have eq: "A \<union> (B - A) = B" using AB by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4153
  from card_Un_disjoint[OF fA fBA e, unfolded eq c]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4154
  have "card (B - A) = 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4155
  hence "B - A = {}" unfolding card_eq_0_iff using fA fB by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4156
  with AB show "A = B" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4157
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4158
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4159
lemma subspace_isomorphism:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4160
  assumes s: "subspace (S:: (real ^'n) set)"
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4161
  and t: "subspace (T :: (real ^'m) set)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4162
  and d: "dim S = dim T"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4163
  shows "\<exists>f. linear f \<and> f ` S = T \<and> inj_on f S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4164
proof-
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4165
  from basis_exists[of S] independent_bound obtain B where
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4166
    B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "card B = dim S" and fB: "finite B" by blast
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4167
  from basis_exists[of T] independent_bound obtain C where
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4168
    C: "C \<subseteq> T" "independent C" "T \<subseteq> span C" "card C = dim T" and fC: "finite C" by blast
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4169
  from B(4) C(4) card_le_inj[of B C] d obtain f where
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4170
    f: "f ` B \<subseteq> C" "inj_on f B" using `finite B` `finite C` by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4171
  from linear_independent_extend[OF B(2)] obtain g where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4172
    g: "linear g" "\<forall>x\<in> B. g x = f x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4173
  from inj_on_iff_eq_card[OF fB, of f] f(2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4174
  have "card (f ` B) = card B" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4175
  with B(4) C(4) have ceq: "card (f ` B) = card C" using d
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4176
    by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4177
  have "g ` B = f ` B" using g(2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4178
    by (auto simp add: image_iff)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4179
  also have "\<dots> = C" using card_subset_eq[OF fC f(1) ceq] .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4180
  finally have gBC: "g ` B = C" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4181
  have gi: "inj_on g B" using f(2) g(2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4182
    by (auto simp add: inj_on_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4183
  note g0 = linear_indep_image_lemma[OF g(1) fB, unfolded gBC, OF C(2) gi]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4184
  {fix x y assume x: "x \<in> S" and y: "y \<in> S" and gxy:"g x = g y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4185
    from B(3) x y have x': "x \<in> span B" and y': "y \<in> span B" by blast+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4186
    from gxy have th0: "g (x - y) = 0" by (simp add: linear_sub[OF g(1)])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4187
    have th1: "x - y \<in> span B" using x' y' by (metis span_sub)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4188
    have "x=y" using g0[OF th1 th0] by simp }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4189
  then have giS: "inj_on g S"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4190
    unfolding inj_on_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4191
  from span_subspace[OF B(1,3) s]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4192
  have "g ` S = span (g ` B)" by (simp add: span_linear_image[OF g(1)])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4193
  also have "\<dots> = span C" unfolding gBC ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4194
  also have "\<dots> = T" using span_subspace[OF C(1,3) t] .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4195
  finally have gS: "g ` S = T" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4196
  from g(1) gS giS show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4197
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4198
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4199
(* linear functions are equal on a subspace if they are on a spanning set.   *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4200
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4201
lemma subspace_kernel:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4202
  assumes lf: "linear (f::'a::semiring_1 ^_ \<Rightarrow> _)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4203
  shows "subspace {x. f x = 0}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4204
apply (simp add: subspace_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4205
by (simp add: linear_add[OF lf] linear_cmul[OF lf] linear_0[OF lf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4206
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4207
lemma linear_eq_0_span:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4208
  assumes lf: "linear f" and f0: "\<forall>x\<in>B. f x = 0"
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4209
  shows "\<forall>x \<in> span B. f x = (0::'a::semiring_1 ^_)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4210
proof
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4211
  fix x assume x: "x \<in> span B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4212
  let ?P = "\<lambda>x. f x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4213
  from subspace_kernel[OF lf] have "subspace ?P" unfolding Collect_def .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4214
  with x f0 span_induct[of B "?P" x] show "f x = 0" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4215
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4216
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4217
lemma linear_eq_0:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4218
  assumes lf: "linear f" and SB: "S \<subseteq> span B" and f0: "\<forall>x\<in>B. f x = 0"
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4219
  shows "\<forall>x \<in> S. f x = (0::'a::semiring_1^_)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4220
  by (metis linear_eq_0_span[OF lf] subset_eq SB f0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4221
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4222
lemma linear_eq:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4223
  assumes lf: "linear (f::'a::ring_1^_ \<Rightarrow> _)" and lg: "linear g" and S: "S \<subseteq> span B"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4224
  and fg: "\<forall> x\<in> B. f x = g x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4225
  shows "\<forall>x\<in> S. f x = g x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4226
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4227
  let ?h = "\<lambda>x. f x - g x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4228
  from fg have fg': "\<forall>x\<in> B. ?h x = 0" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4229
  from linear_eq_0[OF linear_compose_sub[OF lf lg] S fg']
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4230
  show ?thesis by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4231
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4232
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4233
lemma linear_eq_stdbasis:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4234
  assumes lf: "linear (f::'a::ring_1^'m \<Rightarrow> 'a^'n)" and lg: "linear g"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4235
  and fg: "\<forall>i. f (basis i) = g(basis i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4236
  shows "f = g"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4237
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4238
  let ?U = "UNIV :: 'm set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4239
  let ?I = "{basis i:: 'a^'m|i. i \<in> ?U}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4240
  {fix x assume x: "x \<in> (UNIV :: ('a^'m) set)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4241
    from equalityD2[OF span_stdbasis]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4242
    have IU: " (UNIV :: ('a^'m) set) \<subseteq> span ?I" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4243
    from linear_eq[OF lf lg IU] fg x
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4244
    have "f x = g x" unfolding Collect_def  Ball_def mem_def by metis}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4245
  then show ?thesis by (auto intro: ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4246
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4247
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4248
(* Similar results for bilinear functions.                                   *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4249
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4250
lemma bilinear_eq:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4251
  assumes bf: "bilinear (f:: 'a::ring^_ \<Rightarrow> 'a^_ \<Rightarrow> 'a^_)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4252
  and bg: "bilinear g"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4253
  and SB: "S \<subseteq> span B" and TC: "T \<subseteq> span C"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4254
  and fg: "\<forall>x\<in> B. \<forall>y\<in> C. f x y = g x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4255
  shows "\<forall>x\<in>S. \<forall>y\<in>T. f x y = g x y "
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4256
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4257
  let ?P = "\<lambda>x. \<forall>y\<in> span C. f x y = g x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4258
  from bf bg have sp: "subspace ?P"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4259
    unfolding bilinear_def linear_def subspace_def bf bg
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4260
    by(auto simp add: span_0 mem_def bilinear_lzero[OF bf] bilinear_lzero[OF bg] span_add Ball_def intro:  bilinear_ladd[OF bf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4261
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4262
  have "\<forall>x \<in> span B. \<forall>y\<in> span C. f x y = g x y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4263
    apply -
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4264
    apply (rule ballI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4265
    apply (rule span_induct[of B ?P])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4266
    defer
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4267
    apply (rule sp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4268
    apply assumption
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4269
    apply (clarsimp simp add: Ball_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4270
    apply (rule_tac P="\<lambda>y. f xa y = g xa y" and S=C in span_induct)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4271
    using fg
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4272
    apply (auto simp add: subspace_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4273
    using bf bg unfolding bilinear_def linear_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4274
    by(auto simp add: span_0 mem_def bilinear_rzero[OF bf] bilinear_rzero[OF bg] span_add Ball_def intro:  bilinear_ladd[OF bf])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4275
  then show ?thesis using SB TC by (auto intro: ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4276
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4277
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4278
lemma bilinear_eq_stdbasis:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4279
  assumes bf: "bilinear (f:: 'a::ring_1^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^_)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4280
  and bg: "bilinear g"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4281
  and fg: "\<forall>i j. f (basis i) (basis j) = g (basis i) (basis j)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4282
  shows "f = g"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4283
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4284
  from fg have th: "\<forall>x \<in> {basis i| i. i\<in> (UNIV :: 'm set)}. \<forall>y\<in>  {basis j |j. j \<in> (UNIV :: 'n set)}. f x y = g x y" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4285
  from bilinear_eq[OF bf bg equalityD2[OF span_stdbasis] equalityD2[OF span_stdbasis] th] show ?thesis by (blast intro: ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4286
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4287
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4288
(* Detailed theorems about left and right invertibility in general case.     *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4289
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4290
lemma left_invertible_transpose:
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4291
  "(\<exists>(B). B ** transpose (A) = mat (1::'a::comm_semiring_1)) \<longleftrightarrow> (\<exists>(B). A ** B = mat 1)"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4292
  by (metis matrix_transpose_mul transpose_mat transpose_transpose)
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4293
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4294
lemma right_invertible_transpose:
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4295
  "(\<exists>(B). transpose (A) ** B = mat (1::'a::comm_semiring_1)) \<longleftrightarrow> (\<exists>(B). B ** A = mat 1)"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4296
  by (metis matrix_transpose_mul transpose_mat transpose_transpose)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4297
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4298
lemma linear_injective_left_inverse:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4299
  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)" and fi: "inj f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4300
  shows "\<exists>g. linear g \<and> g o f = id"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4301
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4302
  from linear_independent_extend[OF independent_injective_image, OF independent_stdbasis, OF lf fi]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4303
  obtain h:: "real ^'m \<Rightarrow> real ^'n" where h: "linear h" " \<forall>x \<in> f ` {basis i|i. i \<in> (UNIV::'n set)}. h x = inv f x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4304
  from h(2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4305
  have th: "\<forall>i. (h \<circ> f) (basis i) = id (basis i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4306
    using inv_o_cancel[OF fi, unfolded stupid_ext[symmetric] id_def o_def]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4307
    by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4308
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4309
  from linear_eq_stdbasis[OF linear_compose[OF lf h(1)] linear_id th]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4310
  have "h o f = id" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4311
  then show ?thesis using h(1) by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4312
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4313
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4314
lemma linear_surjective_right_inverse:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4315
  assumes lf: "linear (f:: real ^'m \<Rightarrow> real ^'n)" and sf: "surj f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4316
  shows "\<exists>g. linear g \<and> f o g = id"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4317
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4318
  from linear_independent_extend[OF independent_stdbasis]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4319
  obtain h:: "real ^'n \<Rightarrow> real ^'m" where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4320
    h: "linear h" "\<forall> x\<in> {basis i| i. i\<in> (UNIV :: 'n set)}. h x = inv f x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4321
  from h(2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4322
  have th: "\<forall>i. (f o h) (basis i) = id (basis i)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4323
    using sf
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4324
    apply (auto simp add: surj_iff o_def stupid_ext[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4325
    apply (erule_tac x="basis i" in allE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4326
    by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4327
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4328
  from linear_eq_stdbasis[OF linear_compose[OF h(1) lf] linear_id th]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4329
  have "f o h = id" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4330
  then show ?thesis using h(1) by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4331
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4332
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4333
lemma matrix_left_invertible_injective:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4334
"(\<exists>B. (B::real^'m^'n) ** (A::real^'n^'m) = mat 1) \<longleftrightarrow> (\<forall>x y. A *v x = A *v y \<longrightarrow> x = y)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4335
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4336
  {fix B:: "real^'m^'n" and x y assume B: "B ** A = mat 1" and xy: "A *v x = A*v y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4337
    from xy have "B*v (A *v x) = B *v (A*v y)" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4338
    hence "x = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4339
      unfolding matrix_vector_mul_assoc B matrix_vector_mul_lid .}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4340
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4341
  {assume A: "\<forall>x y. A *v x = A *v y \<longrightarrow> x = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4342
    hence i: "inj (op *v A)" unfolding inj_on_def by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4343
    from linear_injective_left_inverse[OF matrix_vector_mul_linear i]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4344
    obtain g where g: "linear g" "g o op *v A = id" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4345
    have "matrix g ** A = mat 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4346
      unfolding matrix_eq matrix_vector_mul_lid matrix_vector_mul_assoc[symmetric] matrix_works[OF g(1)]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4347
      using g(2) by (simp add: o_def id_def stupid_ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4348
    then have "\<exists>B. (B::real ^'m^'n) ** A = mat 1" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4349
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4350
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4351
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4352
lemma matrix_left_invertible_ker:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4353
  "(\<exists>B. (B::real ^'m^'n) ** (A::real^'n^'m) = mat 1) \<longleftrightarrow> (\<forall>x. A *v x = 0 \<longrightarrow> x = 0)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4354
  unfolding matrix_left_invertible_injective
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4355
  using linear_injective_0[OF matrix_vector_mul_linear, of A]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4356
  by (simp add: inj_on_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4357
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4358
lemma matrix_right_invertible_surjective:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4359
"(\<exists>B. (A::real^'n^'m) ** (B::real^'m^'n) = mat 1) \<longleftrightarrow> surj (\<lambda>x. A *v x)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4360
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4361
  {fix B :: "real ^'m^'n"  assume AB: "A ** B = mat 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4362
    {fix x :: "real ^ 'm"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4363
      have "A *v (B *v x) = x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4364
        by (simp add: matrix_vector_mul_lid matrix_vector_mul_assoc AB)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4365
    hence "surj (op *v A)" unfolding surj_def by metis }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4366
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4367
  {assume sf: "surj (op *v A)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4368
    from linear_surjective_right_inverse[OF matrix_vector_mul_linear sf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4369
    obtain g:: "real ^'m \<Rightarrow> real ^'n" where g: "linear g" "op *v A o g = id"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4370
      by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4371
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4372
    have "A ** (matrix g) = mat 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4373
      unfolding matrix_eq  matrix_vector_mul_lid
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4374
        matrix_vector_mul_assoc[symmetric] matrix_works[OF g(1)]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4375
      using g(2) unfolding o_def stupid_ext[symmetric] id_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4376
      .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4377
    hence "\<exists>B. A ** (B::real^'m^'n) = mat 1" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4378
  }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4379
  ultimately show ?thesis unfolding surj_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4380
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4381
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4382
lemma matrix_left_invertible_independent_columns:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4383
  fixes A :: "real^'n^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4384
  shows "(\<exists>(B::real ^'m^'n). B ** A = mat 1) \<longleftrightarrow> (\<forall>c. setsum (\<lambda>i. c i *s column i A) (UNIV :: 'n set) = 0 \<longrightarrow> (\<forall>i. c i = 0))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4385
   (is "?lhs \<longleftrightarrow> ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4386
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4387
  let ?U = "UNIV :: 'n set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4388
  {assume k: "\<forall>x. A *v x = 0 \<longrightarrow> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4389
    {fix c i assume c: "setsum (\<lambda>i. c i *s column i A) ?U = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4390
      and i: "i \<in> ?U"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4391
      let ?x = "\<chi> i. c i"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4392
      have th0:"A *v ?x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4393
        using c
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4394
        unfolding matrix_mult_vsum Cart_eq
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4395
        by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4396
      from k[rule_format, OF th0] i
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4397
      have "c i = 0" by (vector Cart_eq)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4398
    hence ?rhs by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4399
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4400
  {assume H: ?rhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4401
    {fix x assume x: "A *v x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4402
      let ?c = "\<lambda>i. ((x$i ):: real)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4403
      from H[rule_format, of ?c, unfolded matrix_mult_vsum[symmetric], OF x]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4404
      have "x = 0" by vector}}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4405
  ultimately show ?thesis unfolding matrix_left_invertible_ker by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4406
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4407
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4408
lemma matrix_right_invertible_independent_rows:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4409
  fixes A :: "real^'n^'m"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4410
  shows "(\<exists>(B::real^'m^'n). A ** B = mat 1) \<longleftrightarrow> (\<forall>c. setsum (\<lambda>i. c i *s row i A) (UNIV :: 'm set) = 0 \<longrightarrow> (\<forall>i. c i = 0))"
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4411
  unfolding left_invertible_transpose[symmetric]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4412
    matrix_left_invertible_independent_columns
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4413
  by (simp add: column_transpose)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4414
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4415
lemma matrix_right_invertible_span_columns:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4416
  "(\<exists>(B::real ^'n^'m). (A::real ^'m^'n) ** B = mat 1) \<longleftrightarrow> span (columns A) = UNIV" (is "?lhs = ?rhs")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4417
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4418
  let ?U = "UNIV :: 'm set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4419
  have fU: "finite ?U" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4420
  have lhseq: "?lhs \<longleftrightarrow> (\<forall>y. \<exists>(x::real^'m). setsum (\<lambda>i. (x$i) *s column i A) ?U = y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4421
    unfolding matrix_right_invertible_surjective matrix_mult_vsum surj_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4422
    apply (subst eq_commute) ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4423
  have rhseq: "?rhs \<longleftrightarrow> (\<forall>x. x \<in> span (columns A))" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4424
  {assume h: ?lhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4425
    {fix x:: "real ^'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4426
        from h[unfolded lhseq, rule_format, of x] obtain y:: "real ^'m"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4427
          where y: "setsum (\<lambda>i. (y$i) *s column i A) ?U = x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4428
        have "x \<in> span (columns A)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4429
          unfolding y[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4430
          apply (rule span_setsum[OF fU])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4431
          apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4432
          apply (rule span_mul)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4433
          apply (rule span_superset)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4434
          unfolding columns_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4435
          by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4436
    then have ?rhs unfolding rhseq by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4437
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4438
  {assume h:?rhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4439
    let ?P = "\<lambda>(y::real ^'n). \<exists>(x::real^'m). setsum (\<lambda>i. (x$i) *s column i A) ?U = y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4440
    {fix y have "?P y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4441
      proof(rule span_induct_alt[of ?P "columns A"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4442
        show "\<exists>x\<Colon>real ^ 'm. setsum (\<lambda>i. (x$i) *s column i A) ?U = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4443
          apply (rule exI[where x=0])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4444
          by (simp add: zero_index vector_smult_lzero)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4445
      next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4446
        fix c y1 y2 assume y1: "y1 \<in> columns A" and y2: "?P y2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4447
        from y1 obtain i where i: "i \<in> ?U" "y1 = column i A"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4448
          unfolding columns_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4449
        from y2 obtain x:: "real ^'m" where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4450
          x: "setsum (\<lambda>i. (x$i) *s column i A) ?U = y2" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4451
        let ?x = "(\<chi> j. if j = i then c + (x$i) else (x$j))::real^'m"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4452
        show "?P (c*s y1 + y2)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4453
          proof(rule exI[where x= "?x"], vector, auto simp add: i x[symmetric] cond_value_iff right_distrib cond_application_beta cong del: if_weak_cong)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4454
            fix j
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4455
            have th: "\<forall>xa \<in> ?U. (if xa = i then (c + (x$i)) * ((column xa A)$j)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4456
           else (x$xa) * ((column xa A$j))) = (if xa = i then c * ((column i A)$j) else 0) + ((x$xa) * ((column xa A)$j))" using i(1)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4457
              by (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4458
            have "setsum (\<lambda>xa. if xa = i then (c + (x$i)) * ((column xa A)$j)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4459
           else (x$xa) * ((column xa A$j))) ?U = setsum (\<lambda>xa. (if xa = i then c * ((column i A)$j) else 0) + ((x$xa) * ((column xa A)$j))) ?U"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4460
              apply (rule setsum_cong[OF refl])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4461
              using th by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4462
            also have "\<dots> = setsum (\<lambda>xa. if xa = i then c * ((column i A)$j) else 0) ?U + setsum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4463
              by (simp add: setsum_addf)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4464
            also have "\<dots> = c * ((column i A)$j) + setsum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4465
              unfolding setsum_delta[OF fU]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4466
              using i(1) by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4467
            finally show "setsum (\<lambda>xa. if xa = i then (c + (x$i)) * ((column xa A)$j)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4468
           else (x$xa) * ((column xa A$j))) ?U = c * ((column i A)$j) + setsum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U" .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4469
          qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4470
        next
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4471
          show "y \<in> span (columns A)" unfolding h by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4472
        qed}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4473
    then have ?lhs unfolding lhseq ..}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4474
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4475
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4476
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4477
lemma matrix_left_invertible_span_rows:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4478
  "(\<exists>(B::real^'m^'n). B ** (A::real^'n^'m) = mat 1) \<longleftrightarrow> span (rows A) = UNIV"
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4479
  unfolding right_invertible_transpose[symmetric]
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4480
  unfolding columns_transpose[symmetric]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4481
  unfolding matrix_right_invertible_span_columns
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4482
 ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4483
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4484
(* An injective map real^'n->real^'n is also surjective.                       *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4485
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4486
lemma linear_injective_imp_surjective:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4487
  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and fi: "inj f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4488
  shows "surj f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4489
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4490
  let ?U = "UNIV :: (real ^'n) set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4491
  from basis_exists[of ?U] obtain B
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4492
    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "card B = dim ?U"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4493
    by blast
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4494
  from B(4) have d: "dim ?U = card B" by simp
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4495
  have th: "?U \<subseteq> span (f ` B)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4496
    apply (rule card_ge_dim_independent)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4497
    apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4498
    apply (rule independent_injective_image[OF B(2) lf fi])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4499
    apply (rule order_eq_refl)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4500
    apply (rule sym)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4501
    unfolding d
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4502
    apply (rule card_image)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4503
    apply (rule subset_inj_on[OF fi])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4504
    by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4505
  from th show ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4506
    unfolding span_linear_image[OF lf] surj_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4507
    using B(3) by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4508
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4509
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4510
(* And vice versa.                                                           *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4511
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4512
lemma surjective_iff_injective_gen:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4513
  assumes fS: "finite S" and fT: "finite T" and c: "card S = card T"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4514
  and ST: "f ` S \<subseteq> T"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4515
  shows "(\<forall>y \<in> T. \<exists>x \<in> S. f x = y) \<longleftrightarrow> inj_on f S" (is "?lhs \<longleftrightarrow> ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4516
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4517
  {assume h: "?lhs"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4518
    {fix x y assume x: "x \<in> S" and y: "y \<in> S" and f: "f x = f y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4519
      from x fS have S0: "card S \<noteq> 0" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4520
      {assume xy: "x \<noteq> y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4521
        have th: "card S \<le> card (f ` (S - {y}))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4522
          unfolding c
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4523
          apply (rule card_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4524
          apply (rule finite_imageI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4525
          using fS apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4526
          using h xy x y f unfolding subset_eq image_iff
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4527
          apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4528
          apply (case_tac "xa = f x")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4529
          apply (rule bexI[where x=x])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4530
          apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4531
          done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4532
        also have " \<dots> \<le> card (S -{y})"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4533
          apply (rule card_image_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4534
          using fS by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4535
        also have "\<dots> \<le> card S - 1" using y fS by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4536
        finally have False  using S0 by arith }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4537
      then have "x = y" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4538
    then have ?rhs unfolding inj_on_def by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4539
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4540
  {assume h: ?rhs
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4541
    have "f ` S = T"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4542
      apply (rule card_subset_eq[OF fT ST])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4543
      unfolding card_image[OF h] using c .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4544
    then have ?lhs by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4545
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4546
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4547
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4548
lemma linear_surjective_imp_injective:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4549
  assumes lf: "linear (f::real ^'n => real ^'n)" and sf: "surj f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4550
  shows "inj f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4551
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4552
  let ?U = "UNIV :: (real ^'n) set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4553
  from basis_exists[of ?U] obtain B
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4554
    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" and d: "card B = dim ?U"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4555
    by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4556
  {fix x assume x: "x \<in> span B" and fx: "f x = 0"
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4557
    from B(2) have fB: "finite B" using independent_bound by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4558
    have fBi: "independent (f ` B)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4559
      apply (rule card_le_dim_spanning[of "f ` B" ?U])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4560
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4561
      using sf B(3)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4562
      unfolding span_linear_image[OF lf] surj_def subset_eq image_iff
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4563
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4564
      using fB apply (blast intro: finite_imageI)
33715
8cce3a34c122 removed hassize predicate
hoelzl
parents: 33714
diff changeset
  4565
      unfolding d[symmetric]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4566
      apply (rule card_image_le)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4567
      apply (rule fB)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4568
      done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4569
    have th0: "dim ?U \<le> card (f ` B)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4570
      apply (rule span_card_ge_dim)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4571
      apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4572
      unfolding span_linear_image[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4573
      apply (rule subset_trans[where B = "f ` UNIV"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4574
      using sf unfolding surj_def apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4575
      apply (rule image_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4576
      apply (rule B(3))
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4577
      apply (metis finite_imageI fB)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4578
      done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4579
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4580
    moreover have "card (f ` B) \<le> card B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4581
      by (rule card_image_le, rule fB)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4582
    ultimately have th1: "card B = card (f ` B)" unfolding d by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4583
    have fiB: "inj_on f B"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4584
      unfolding surjective_iff_injective_gen[OF fB finite_imageI[OF fB] th1 subset_refl, symmetric] by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4585
    from linear_indep_image_lemma[OF lf fB fBi fiB x] fx
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4586
    have "x = 0" by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4587
  note th = this
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4588
  from th show ?thesis unfolding linear_injective_0[OF lf]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4589
    using B(3) by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4590
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4591
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4592
(* Hence either is enough for isomorphism.                                   *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4593
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4594
lemma left_right_inverse_eq:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4595
  assumes fg: "f o g = id" and gh: "g o h = id"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4596
  shows "f = h"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4597
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4598
  have "f = f o (g o h)" unfolding gh by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4599
  also have "\<dots> = (f o g) o h" by (simp add: o_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4600
  finally show "f = h" unfolding fg by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4601
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4602
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4603
lemma isomorphism_expand:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4604
  "f o g = id \<and> g o f = id \<longleftrightarrow> (\<forall>x. f(g x) = x) \<and> (\<forall>x. g(f x) = x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4605
  by (simp add: expand_fun_eq o_def id_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4606
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4607
lemma linear_injective_isomorphism:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4608
  assumes lf: "linear (f :: real^'n \<Rightarrow> real ^'n)" and fi: "inj f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4609
  shows "\<exists>f'. linear f' \<and> (\<forall>x. f' (f x) = x) \<and> (\<forall>x. f (f' x) = x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4610
unfolding isomorphism_expand[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4611
using linear_surjective_right_inverse[OF lf linear_injective_imp_surjective[OF lf fi]] linear_injective_left_inverse[OF lf fi]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4612
by (metis left_right_inverse_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4613
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4614
lemma linear_surjective_isomorphism:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4615
  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'n)" and sf: "surj f"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4616
  shows "\<exists>f'. linear f' \<and> (\<forall>x. f' (f x) = x) \<and> (\<forall>x. f (f' x) = x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4617
unfolding isomorphism_expand[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4618
using linear_surjective_right_inverse[OF lf sf] linear_injective_left_inverse[OF lf linear_surjective_imp_injective[OF lf sf]]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4619
by (metis left_right_inverse_eq)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4620
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4621
(* Left and right inverses are the same for R^N->R^N.                        *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4622
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4623
lemma linear_inverse_left:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4624
  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'n)" and lf': "linear f'"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4625
  shows "f o f' = id \<longleftrightarrow> f' o f = id"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4626
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4627
  {fix f f':: "real ^'n \<Rightarrow> real ^'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4628
    assume lf: "linear f" "linear f'" and f: "f o f' = id"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4629
    from f have sf: "surj f"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4630
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4631
      apply (auto simp add: o_def stupid_ext[symmetric] id_def surj_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4632
      by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4633
    from linear_surjective_isomorphism[OF lf(1) sf] lf f
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4634
    have "f' o f = id" unfolding stupid_ext[symmetric] o_def id_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4635
      by metis}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4636
  then show ?thesis using lf lf' by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4637
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4638
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4639
(* Moreover, a one-sided inverse is automatically linear.                    *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4640
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4641
lemma left_inverse_linear:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4642
  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'n)" and gf: "g o f = id"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4643
  shows "linear g"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4644
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4645
  from gf have fi: "inj f" apply (auto simp add: inj_on_def o_def id_def stupid_ext[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4646
    by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4647
  from linear_injective_isomorphism[OF lf fi]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4648
  obtain h:: "real ^'n \<Rightarrow> real ^'n" where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4649
    h: "linear h" "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4650
  have "h = g" apply (rule ext) using gf h(2,3)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4651
    apply (simp add: o_def id_def stupid_ext[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4652
    by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4653
  with h(1) show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4654
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4655
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4656
lemma right_inverse_linear:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4657
  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and gf: "f o g = id"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4658
  shows "linear g"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4659
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4660
  from gf have fi: "surj f" apply (auto simp add: surj_def o_def id_def stupid_ext[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4661
    by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4662
  from linear_surjective_isomorphism[OF lf fi]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4663
  obtain h:: "real ^'n \<Rightarrow> real ^'n" where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4664
    h: "linear h" "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4665
  have "h = g" apply (rule ext) using gf h(2,3)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4666
    apply (simp add: o_def id_def stupid_ext[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4667
    by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4668
  with h(1) show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4669
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4670
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4671
(* The same result in terms of square matrices.                              *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4672
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4673
lemma matrix_left_right_inverse:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4674
  fixes A A' :: "real ^'n^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4675
  shows "A ** A' = mat 1 \<longleftrightarrow> A' ** A = mat 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4676
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4677
  {fix A A' :: "real ^'n^'n" assume AA': "A ** A' = mat 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4678
    have sA: "surj (op *v A)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4679
      unfolding surj_def
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4680
      apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4681
      apply (rule_tac x="(A' *v y)" in exI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4682
      by (simp add: matrix_vector_mul_assoc AA' matrix_vector_mul_lid)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4683
    from linear_surjective_isomorphism[OF matrix_vector_mul_linear sA]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4684
    obtain f' :: "real ^'n \<Rightarrow> real ^'n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4685
      where f': "linear f'" "\<forall>x. f' (A *v x) = x" "\<forall>x. A *v f' x = x" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4686
    have th: "matrix f' ** A = mat 1"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4687
      by (simp add: matrix_eq matrix_works[OF f'(1)] matrix_vector_mul_assoc[symmetric] matrix_vector_mul_lid f'(2)[rule_format])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4688
    hence "(matrix f' ** A) ** A' = mat 1 ** A'" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4689
    hence "matrix f' = A'" by (simp add: matrix_mul_assoc[symmetric] AA' matrix_mul_rid matrix_mul_lid)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4690
    hence "matrix f' ** A = A' ** A" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4691
    hence "A' ** A = mat 1" by (simp add: th)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4692
  then show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4693
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4694
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4695
(* Considering an n-element vector as an n-by-1 or 1-by-n matrix.            *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4696
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4697
definition "rowvector v = (\<chi> i j. (v$j))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4698
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4699
definition "columnvector v = (\<chi> i j. (v$i))"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4700
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4701
lemma transpose_columnvector:
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4702
 "transpose(columnvector v) = rowvector v"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4703
  by (simp add: transpose_def rowvector_def columnvector_def Cart_eq)
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4704
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4705
lemma transpose_rowvector: "transpose(rowvector v) = columnvector v"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4706
  by (simp add: transpose_def columnvector_def rowvector_def Cart_eq)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4707
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4708
lemma dot_rowvector_columnvector:
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4709
  "columnvector (A *v v) = A ** columnvector v"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4710
  by (vector columnvector_def matrix_matrix_mult_def matrix_vector_mult_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4711
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4712
lemma dot_matrix_product: "(x::real^'n) \<bullet> y = (((rowvector x ::real^'n^1) ** (columnvector y :: real^1^'n))$1)$1"
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4713
  by (vector matrix_matrix_mult_def rowvector_def columnvector_def inner_vector_def)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4714
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4715
lemma dot_matrix_vector_mul:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4716
  fixes A B :: "real ^'n ^'n" and x y :: "real ^'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4717
  shows "(A *v x) \<bullet> (B *v y) =
35150
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4718
      (((rowvector x :: real^'n^1) ** ((transpose A ** B) ** (columnvector y :: real ^1^'n)))$1)$1"
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4719
unfolding dot_matrix_product transpose_columnvector[symmetric]
082fa4bd403d Rename transp to transpose in HOL-Multivariate_Analysis. (by himmelma)
hoelzl
parents: 35043
diff changeset
  4720
  dot_rowvector_columnvector matrix_transpose_mul matrix_mul_assoc ..
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4721
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4722
(* Infinity norm.                                                            *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4723
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4724
definition "infnorm (x::real^'n) = Sup {abs(x$i) |i. i\<in> (UNIV :: 'n set)}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4725
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4726
lemma numseg_dimindex_nonempty: "\<exists>i. i \<in> (UNIV :: 'n set)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4727
  by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4728
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4729
lemma infnorm_set_image:
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4730
  "{abs(x$i) |i. i\<in> (UNIV :: _ set)} =
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4731
  (\<lambda>i. abs(x$i)) ` (UNIV)" by blast
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4732
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4733
lemma infnorm_set_lemma:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4734
  shows "finite {abs((x::'a::abs ^'n)$i) |i. i\<in> (UNIV :: 'n set)}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4735
  and "{abs(x$i) |i. i\<in> (UNIV :: 'n::finite set)} \<noteq> {}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4736
  unfolding infnorm_set_image
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4737
  by (auto intro: finite_imageI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4738
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4739
lemma infnorm_pos_le: "0 \<le> infnorm (x::real^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4740
  unfolding infnorm_def
33270
paulson
parents: 33175
diff changeset
  4741
  unfolding Sup_finite_ge_iff[ OF infnorm_set_lemma]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4742
  unfolding infnorm_set_image
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4743
  by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4744
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4745
lemma infnorm_triangle: "infnorm ((x::real^'n) + y) \<le> infnorm x + infnorm y"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4746
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4747
  have th: "\<And>x y (z::real). x - y <= z \<longleftrightarrow> x - z <= y" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4748
  have th1: "\<And>S f. f ` S = { f i| i. i \<in> S}" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4749
  have th2: "\<And>x (y::real). abs(x + y) - abs(x) <= abs(y)" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4750
  show ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4751
  unfolding infnorm_def
33270
paulson
parents: 33175
diff changeset
  4752
  unfolding Sup_finite_le_iff[ OF infnorm_set_lemma]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4753
  apply (subst diff_le_eq[symmetric])
33270
paulson
parents: 33175
diff changeset
  4754
  unfolding Sup_finite_ge_iff[ OF infnorm_set_lemma]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4755
  unfolding infnorm_set_image bex_simps
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4756
  apply (subst th)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4757
  unfolding th1
33270
paulson
parents: 33175
diff changeset
  4758
  unfolding Sup_finite_ge_iff[ OF infnorm_set_lemma]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4759
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4760
  unfolding infnorm_set_image ball_simps bex_simps
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4761
  apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4762
  apply (metis th2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4763
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4764
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4765
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4766
lemma infnorm_eq_0: "infnorm x = 0 \<longleftrightarrow> (x::real ^'n) = 0"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4767
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4768
  have "infnorm x <= 0 \<longleftrightarrow> x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4769
    unfolding infnorm_def
33270
paulson
parents: 33175
diff changeset
  4770
    unfolding Sup_finite_le_iff[OF infnorm_set_lemma]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4771
    unfolding infnorm_set_image ball_simps
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4772
    by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4773
  then show ?thesis using infnorm_pos_le[of x] by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4774
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4775
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4776
lemma infnorm_0: "infnorm 0 = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4777
  by (simp add: infnorm_eq_0)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4778
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4779
lemma infnorm_neg: "infnorm (- x) = infnorm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4780
  unfolding infnorm_def
33270
paulson
parents: 33175
diff changeset
  4781
  apply (rule cong[of "Sup" "Sup"])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4782
  apply blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4783
  apply (rule set_ext)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4784
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4785
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4786
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4787
lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4788
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4789
  have "y - x = - (x - y)" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4790
  then show ?thesis  by (metis infnorm_neg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4791
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4792
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4793
lemma real_abs_sub_infnorm: "\<bar> infnorm x - infnorm y\<bar> \<le> infnorm (x - y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4794
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4795
  have th: "\<And>(nx::real) n ny. nx <= n + ny \<Longrightarrow> ny <= n + nx ==> \<bar>nx - ny\<bar> <= n"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4796
    by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4797
  from infnorm_triangle[of "x - y" " y"] infnorm_triangle[of "x - y" "-x"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4798
  have ths: "infnorm x \<le> infnorm (x - y) + infnorm y"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4799
    "infnorm y \<le> infnorm (x - y) + infnorm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4800
    by (simp_all add: ring_simps infnorm_neg diff_def[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4801
  from th[OF ths]  show ?thesis .
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4802
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4803
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4804
lemma real_abs_infnorm: " \<bar>infnorm x\<bar> = infnorm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4805
  using infnorm_pos_le[of x] by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4806
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4807
lemma component_le_infnorm:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4808
  shows "\<bar>x$i\<bar> \<le> infnorm (x::real^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4809
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4810
  let ?U = "UNIV :: 'n set"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4811
  let ?S = "{\<bar>x$i\<bar> |i. i\<in> ?U}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4812
  have fS: "finite ?S" unfolding image_Collect[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4813
    apply (rule finite_imageI) unfolding Collect_def mem_def by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4814
  have S0: "?S \<noteq> {}" by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4815
  have th1: "\<And>S f. f ` S = { f i| i. i \<in> S}" by blast
33270
paulson
parents: 33175
diff changeset
  4816
  from Sup_finite_in[OF fS S0] 
paulson
parents: 33175
diff changeset
  4817
  show ?thesis unfolding infnorm_def infnorm_set_image 
paulson
parents: 33175
diff changeset
  4818
    by (metis Sup_finite_ge_iff finite finite_imageI UNIV_not_empty image_is_empty 
paulson
parents: 33175
diff changeset
  4819
              rangeI real_le_refl)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4820
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4821
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4822
lemma infnorm_mul_lemma: "infnorm(a *s x) <= \<bar>a\<bar> * infnorm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4823
  apply (subst infnorm_def)
33270
paulson
parents: 33175
diff changeset
  4824
  unfolding Sup_finite_le_iff[OF infnorm_set_lemma]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4825
  unfolding infnorm_set_image ball_simps
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4826
  apply (simp add: abs_mult)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4827
  apply (rule allI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4828
  apply (cut_tac component_le_infnorm[of x])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4829
  apply (rule mult_mono)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4830
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4831
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4832
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4833
lemma infnorm_mul: "infnorm(a *s x) = abs a * infnorm x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4834
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4835
  {assume a0: "a = 0" hence ?thesis by (simp add: infnorm_0) }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4836
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4837
  {assume a0: "a \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4838
    from a0 have th: "(1/a) *s (a *s x) = x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4839
      by (simp add: vector_smult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4840
    from a0 have ap: "\<bar>a\<bar> > 0" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4841
    from infnorm_mul_lemma[of "1/a" "a *s x"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4842
    have "infnorm x \<le> 1/\<bar>a\<bar> * infnorm (a*s x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4843
      unfolding th by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4844
    with ap have "\<bar>a\<bar> * infnorm x \<le> \<bar>a\<bar> * (1/\<bar>a\<bar> * infnorm (a *s x))" by (simp add: field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4845
    then have "\<bar>a\<bar> * infnorm x \<le> infnorm (a*s x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4846
      using ap by (simp add: field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4847
    with infnorm_mul_lemma[of a x] have ?thesis by arith }
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4848
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4849
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4850
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4851
lemma infnorm_pos_lt: "infnorm x > 0 \<longleftrightarrow> x \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4852
  using infnorm_pos_le[of x] infnorm_eq_0[of x] by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4853
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4854
(* Prove that it differs only up to a bound from Euclidean norm.             *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4855
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4856
lemma infnorm_le_norm: "infnorm x \<le> norm x"
33270
paulson
parents: 33175
diff changeset
  4857
  unfolding infnorm_def Sup_finite_le_iff[OF infnorm_set_lemma]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4858
  unfolding infnorm_set_image  ball_simps
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4859
  by (metis component_le_norm)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4860
lemma card_enum: "card {1 .. n} = n" by auto
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4861
lemma norm_le_infnorm: "norm(x) <= sqrt(real CARD('n)) * infnorm(x::real ^'n)"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4862
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4863
  let ?d = "CARD('n)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4864
  have "real ?d \<ge> 0" by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4865
  hence d2: "(sqrt (real ?d))^2 = real ?d"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4866
    by (auto intro: real_sqrt_pow2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4867
  have th: "sqrt (real ?d) * infnorm x \<ge> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4868
    by (simp add: zero_le_mult_iff real_sqrt_ge_0_iff infnorm_pos_le)
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4869
  have th1: "x \<bullet> x \<le> (sqrt (real ?d) * infnorm x)^2"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4870
    unfolding power_mult_distrib d2
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4871
    unfolding real_of_nat_def inner_vector_def
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4872
    apply (subst power2_abs[symmetric]) 
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4873
    apply (rule setsum_bounded)
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4874
    apply(auto simp add: power2_eq_square[symmetric])
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4875
    apply (subst power2_abs[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4876
    apply (rule power_mono)
33270
paulson
parents: 33175
diff changeset
  4877
    unfolding infnorm_def  Sup_finite_ge_iff[OF infnorm_set_lemma]
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4878
    unfolding infnorm_set_image bex_simps apply(rule_tac x=i in exI) by auto
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4879
  from real_le_lsqrt[OF inner_ge_zero th th1]
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4880
  show ?thesis unfolding norm_eq_sqrt_inner id_def .
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4881
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4882
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4883
(* Equality in Cauchy-Schwarz and triangle inequalities.                     *)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4884
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4885
lemma norm_cauchy_schwarz_eq: "(x::real ^'n) \<bullet> y = norm x * norm y \<longleftrightarrow> norm x *s y = norm y *s x" (is "?lhs \<longleftrightarrow> ?rhs")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4886
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4887
  {assume h: "x = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4888
    hence ?thesis by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4889
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4890
  {assume h: "y = 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4891
    hence ?thesis by simp}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4892
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4893
  {assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4894
    from inner_eq_zero_iff[of "norm y *s x - norm x *s y"]
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4895
    have "?rhs \<longleftrightarrow> (norm y * (norm y * norm x * norm x - norm x * (x \<bullet> y)) - norm x * (norm y * (y \<bullet> x) - norm x * norm y * norm y) =  0)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4896
      using x y
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4897
      unfolding inner_simps smult_conv_scaleR
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4898
      unfolding power2_norm_eq_inner[symmetric] power2_eq_square diff_eq_0_iff_eq apply (simp add: inner_commute)
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4899
      apply (simp add: ring_simps) by metis
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4900
    also have "\<dots> \<longleftrightarrow> (2 * norm x * norm y * (norm x * norm y - x \<bullet> y) = 0)" using x y
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4901
      by (simp add: ring_simps inner_commute)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4902
    also have "\<dots> \<longleftrightarrow> ?lhs" using x y
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4903
      apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4904
      by metis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4905
    finally have ?thesis by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4906
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4907
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4908
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4909
lemma norm_cauchy_schwarz_abs_eq:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4910
  fixes x y :: "real ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4911
  shows "abs(x \<bullet> y) = norm x * norm y \<longleftrightarrow>
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4912
                norm x *s y = norm y *s x \<or> norm(x) *s y = - norm y *s x" (is "?lhs \<longleftrightarrow> ?rhs")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4913
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4914
  have th: "\<And>(x::real) a. a \<ge> 0 \<Longrightarrow> abs x = a \<longleftrightarrow> x = a \<or> x = - a" by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4915
  have "?rhs \<longleftrightarrow> norm x *s y = norm y *s x \<or> norm (- x) *s y = norm y *s (- x)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4916
    apply simp by vector
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4917
  also have "\<dots> \<longleftrightarrow>(x \<bullet> y = norm x * norm y \<or>
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4918
     (-x) \<bullet> y = norm x * norm y)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4919
    unfolding norm_cauchy_schwarz_eq[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4920
    unfolding norm_minus_cancel
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4921
      norm_mul by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4922
  also have "\<dots> \<longleftrightarrow> ?lhs"
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4923
    unfolding th[OF mult_nonneg_nonneg, OF norm_ge_zero[of x] norm_ge_zero[of y]] inner_simps by auto
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4924
  finally show ?thesis ..
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4925
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4926
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4927
lemma norm_triangle_eq:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  4928
  fixes x y :: "real ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4929
  shows "norm(x + y) = norm x + norm y \<longleftrightarrow> norm x *s y = norm y *s x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4930
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4931
  {assume x: "x =0 \<or> y =0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4932
    hence ?thesis by (cases "x=0", simp_all)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4933
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4934
  {assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4935
    hence "norm x \<noteq> 0" "norm y \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4936
      by simp_all
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4937
    hence n: "norm x > 0" "norm y > 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4938
      using norm_ge_zero[of x] norm_ge_zero[of y]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4939
      by arith+
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4940
    have th: "\<And>(a::real) b c. a + b + c \<noteq> 0 ==> (a = b + c \<longleftrightarrow> a^2 = (b + c)^2)" by algebra
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4941
    have "norm(x + y) = norm x + norm y \<longleftrightarrow> norm(x + y)^ 2 = (norm x + norm y) ^2"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4942
      apply (rule th) using n norm_ge_zero[of "x + y"]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4943
      by arith
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4944
    also have "\<dots> \<longleftrightarrow> norm x *s y = norm y *s x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4945
      unfolding norm_cauchy_schwarz_eq[symmetric]
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4946
      unfolding power2_norm_eq_inner inner_simps
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  4947
      by (simp add: power2_norm_eq_inner[symmetric] power2_eq_square inner_commute ring_simps)
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4948
    finally have ?thesis .}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4949
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4950
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4951
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4952
(* Collinearity.*)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4953
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4954
definition "collinear S \<longleftrightarrow> (\<exists>u. \<forall>x \<in> S. \<forall> y \<in> S. \<exists>c. x - y = c *s u)"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4955
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4956
lemma collinear_empty:  "collinear {}" by (simp add: collinear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4957
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4958
lemma collinear_sing: "collinear {(x::'a::ring_1^_)}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4959
  apply (simp add: collinear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4960
  apply (rule exI[where x=0])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4961
  by simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4962
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4963
lemma collinear_2: "collinear {(x::'a::ring_1^_),y}"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4964
  apply (simp add: collinear_def)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4965
  apply (rule exI[where x="x - y"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4966
  apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4967
  apply (rule exI[where x=0], simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4968
  apply (rule exI[where x=1], simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4969
  apply (rule exI[where x="- 1"], simp add: vector_sneg_minus1[symmetric])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4970
  apply (rule exI[where x=0], simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4971
  done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4972
34289
c9c14c72d035 Made finite cartesian products finite
himmelma
parents: 33758
diff changeset
  4973
lemma collinear_lemma: "collinear {(0::real^_),x,y} \<longleftrightarrow> x = 0 \<or> y = 0 \<or> (\<exists>c. y = c *s x)" (is "?lhs \<longleftrightarrow> ?rhs")
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4974
proof-
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4975
  {assume "x=0 \<or> y = 0" hence ?thesis
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4976
      by (cases "x = 0", simp_all add: collinear_2 insert_commute)}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4977
  moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4978
  {assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4979
    {assume h: "?lhs"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4980
      then obtain u where u: "\<forall> x\<in> {0,x,y}. \<forall>y\<in> {0,x,y}. \<exists>c. x - y = c *s u" unfolding collinear_def by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4981
      from u[rule_format, of x 0] u[rule_format, of y 0]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4982
      obtain cx and cy where
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4983
        cx: "x = cx*s u" and cy: "y = cy*s u"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4984
        by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4985
      from cx x have cx0: "cx \<noteq> 0" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4986
      from cy y have cy0: "cy \<noteq> 0" by auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4987
      let ?d = "cy / cx"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4988
      from cx cy cx0 have "y = ?d *s x"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4989
        by (simp add: vector_smult_assoc)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4990
      hence ?rhs using x y by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4991
    moreover
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4992
    {assume h: "?rhs"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4993
      then obtain c where c: "y = c*s x" using x y by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4994
      have ?lhs unfolding collinear_def c
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4995
        apply (rule exI[where x=x])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4996
        apply auto
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4997
        apply (rule exI[where x="- 1"], simp only: vector_smult_lneg vector_smult_lid)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4998
        apply (rule exI[where x= "-c"], simp only: vector_smult_lneg)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  4999
        apply (rule exI[where x=1], simp)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5000
        apply (rule exI[where x="1 - c"], simp add: vector_smult_lneg vector_sub_rdistrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5001
        apply (rule exI[where x="c - 1"], simp add: vector_smult_lneg vector_sub_rdistrib)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5002
        done}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5003
    ultimately have ?thesis by blast}
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5004
  ultimately show ?thesis by blast
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5005
qed
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5006
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5007
lemma norm_cauchy_schwarz_equal:
34291
4e896680897e finite annotation on cartesian product is now implicit.
hoelzl
parents: 34289
diff changeset
  5008
  fixes x y :: "real ^ 'n"
33175
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5009
  shows "abs(x \<bullet> y) = norm x * norm y \<longleftrightarrow> collinear {(0::real^'n),x,y}"
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5010
unfolding norm_cauchy_schwarz_abs_eq
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5011
apply (cases "x=0", simp_all add: collinear_2)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5012
apply (cases "y=0", simp_all add: collinear_2 insert_commute)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5013
unfolding collinear_lemma
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5014
apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5015
apply (subgoal_tac "norm x \<noteq> 0")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5016
apply (subgoal_tac "norm y \<noteq> 0")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5017
apply (rule iffI)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5018
apply (cases "norm x *s y = norm y *s x")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5019
apply (rule exI[where x="(1/norm x) * norm y"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5020
apply (drule sym)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5021
unfolding vector_smult_assoc[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5022
apply (simp add: vector_smult_assoc field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5023
apply (rule exI[where x="(1/norm x) * - norm y"])
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5024
apply clarify
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5025
apply (drule sym)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5026
unfolding vector_smult_assoc[symmetric]
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5027
apply (simp add: vector_smult_assoc field_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5028
apply (erule exE)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5029
apply (erule ssubst)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5030
unfolding vector_smult_assoc
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5031
unfolding norm_mul
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5032
apply (subgoal_tac "norm x * c = \<bar>c\<bar> * norm x \<or> norm x * c = - \<bar>c\<bar> * norm x")
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5033
apply (case_tac "c <= 0", simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5034
apply (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5035
apply (case_tac "c <= 0", simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5036
apply (simp add: ring_simps)
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5037
apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5038
apply simp
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5039
done
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5040
2083bde13ce1 distinguished session for multivariate analysis
himmelma
parents:
diff changeset
  5041
end
35542
8f97d8caabfd replaced \<bullet> with inner
himmelma
parents: 35541
diff changeset
  5042