src/HOL/Analysis/Linear_Algebra.thy
author immler
Wed, 02 May 2018 13:49:38 +0200
changeset 68072 493b818e8e10
parent 67982 7643b005b29a
child 68073 fad29d2a17a5
permissions -rw-r--r--
added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63627
6ddb43c6b711 rename HOL-Multivariate_Analysis to HOL-Analysis.
hoelzl
parents: 63469
diff changeset
     1
(*  Title:      HOL/Analysis/Linear_Algebra.thy
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     2
    Author:     Amine Chaieb, University of Cambridge
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     3
*)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     4
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
     5
section \<open>Elementary linear algebra on Euclidean spaces\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     6
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     7
theory Linear_Algebra
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     8
imports
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
     9
  Euclidean_Space
66453
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 66447
diff changeset
    10
  "HOL-Library.Infinite_Set"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    11
begin
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    12
63886
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    13
lemma linear_simps:
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    14
  assumes "bounded_linear f"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    15
  shows
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    16
    "f (a + b) = f a + f b"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    17
    "f (a - b) = f a - f b"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    18
    "f 0 = 0"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    19
    "f (- a) = - f a"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    20
    "f (s *\<^sub>R v) = s *\<^sub>R (f v)"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    21
proof -
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    22
  interpret f: bounded_linear f by fact
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    23
  show "f (a + b) = f a + f b" by (rule f.add)
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    24
  show "f (a - b) = f a - f b" by (rule f.diff)
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    25
  show "f 0 = 0" by (rule f.zero)
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
    26
  show "f (- a) = - f a" by (rule f.neg)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
    27
  show "f (s *\<^sub>R v) = s *\<^sub>R (f v)" by (rule f.scale)
63886
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    28
qed
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    29
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    30
lemma bounded_linearI:
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    31
  assumes "\<And>x y. f (x + y) = f x + f y"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    32
    and "\<And>r x. f (r *\<^sub>R x) = r *\<^sub>R f x"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    33
    and "\<And>x. norm (f x) \<le> norm x * K"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    34
  shows "bounded_linear f"
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    35
  using assms by (rule bounded_linear_intro) (* FIXME: duplicate *)
685fb01256af move Henstock-Kurzweil integration after Lebesgue_Measure; replace content by abbreviation measure lborel
hoelzl
parents: 63881
diff changeset
    36
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    37
lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x\<in> (UNIV::'a::finite set)}"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
    38
proof -
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
    39
  have eq: "{f x |x. x\<in> UNIV} = f ` UNIV"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
    40
    by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    41
  show ?thesis unfolding eq
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    42
    apply (rule finite_imageI)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    43
    apply (rule finite)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    44
    done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    45
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
    46
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
    47
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
    48
subsection%unimportant \<open>More interesting properties of the norm.\<close>
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    49
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    50
notation inner (infix "\<bullet>" 70)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    51
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66804
diff changeset
    52
text\<open>Equality of vectors in terms of @{term "(\<bullet>)"} products.\<close>
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    53
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    54
lemma linear_componentwise:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    55
  fixes f:: "'a::euclidean_space \<Rightarrow> 'b::real_inner"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    56
  assumes lf: "linear f"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    57
  shows "(f x) \<bullet> j = (\<Sum>i\<in>Basis. (x\<bullet>i) * (f i\<bullet>j))" (is "?lhs = ?rhs")
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    58
proof -
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
    59
  interpret linear f by fact
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    60
  have "?rhs = (\<Sum>i\<in>Basis. (x\<bullet>i) *\<^sub>R (f i))\<bullet>j"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
    61
    by (simp add: inner_sum_left)
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    62
  then show ?thesis
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
    63
    by (simp add: euclidean_representation sum[symmetric] scale[symmetric])
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    64
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    65
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    66
lemma vector_eq: "x = y \<longleftrightarrow> x \<bullet> x = x \<bullet> y \<and> y \<bullet> y = x \<bullet> x"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    67
  (is "?lhs \<longleftrightarrow> ?rhs")
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    68
proof
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    69
  assume ?lhs
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    70
  then show ?rhs by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    71
next
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    72
  assume ?rhs
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    73
  then have "x \<bullet> x - x \<bullet> y = 0 \<and> x \<bullet> y - y \<bullet> y = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    74
    by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    75
  then have "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    76
    by (simp add: inner_diff inner_commute)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    77
  then have "(x - y) \<bullet> (x - y) = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    78
    by (simp add: field_simps inner_diff inner_commute)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    79
  then show "x = y" by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    80
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    81
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    82
lemma norm_triangle_half_r:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    83
  "norm (y - x1) < e / 2 \<Longrightarrow> norm (y - x2) < e / 2 \<Longrightarrow> norm (x1 - x2) < e"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    84
  using dist_triangle_half_r unfolding dist_norm[symmetric] by auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    85
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    86
lemma norm_triangle_half_l:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    87
  assumes "norm (x - y) < e / 2"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    88
    and "norm (x' - y) < e / 2"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    89
  shows "norm (x - x') < e"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    90
  using dist_triangle_half_l[OF assms[unfolded dist_norm[symmetric]]]
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    91
  unfolding dist_norm[symmetric] .
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    92
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    93
lemma norm_triangle_le: "norm x + norm y \<le> e \<Longrightarrow> norm (x + y) \<le> e"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    94
  by (rule norm_triangle_ineq [THEN order_trans])
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    95
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    96
lemma norm_triangle_lt: "norm x + norm y < e \<Longrightarrow> norm (x + y) < e"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    97
  by (rule norm_triangle_ineq [THEN le_less_trans])
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
    98
66420
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
    99
lemma abs_triangle_half_r:
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   100
  fixes y :: "'a::linordered_field"
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   101
  shows "abs (y - x1) < e / 2 \<Longrightarrow> abs (y - x2) < e / 2 \<Longrightarrow> abs (x1 - x2) < e"
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   102
  by linarith
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   103
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   104
lemma abs_triangle_half_l:
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   105
  fixes y :: "'a::linordered_field"
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   106
  assumes "abs (x - y) < e / 2"
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   107
    and "abs (x' - y) < e / 2"
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   108
  shows "abs (x - x') < e"
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   109
  using assms by linarith
bc0dab0e7b40 further Hensock tidy-up
paulson <lp15@cam.ac.uk>
parents: 66297
diff changeset
   110
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   111
lemma sum_clauses:
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   112
  shows "sum f {} = 0"
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   113
    and "finite S \<Longrightarrow> sum f (insert x S) = (if x \<in> S then sum f S else f x + sum f S)"
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   114
  by (auto simp add: insert_absorb)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   115
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   116
lemma sum_norm_bound:
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   117
  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
   118
  assumes K: "\<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> K"
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
   119
  shows "norm (sum f S) \<le> of_nat (card S)*K"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   120
  using sum_norm_le[OF K] sum_constant[symmetric]
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   121
  by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   122
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   123
lemma sum_group:
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   124
  assumes fS: "finite S" and fT: "finite T" and fST: "f ` S \<subseteq> T"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   125
  shows "sum (\<lambda>y. sum g {x. x \<in> S \<and> f x = y}) T = sum g S"
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   126
  apply (subst sum_image_gen[OF fS, of g f])
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   127
  apply (rule sum.mono_neutral_right[OF fT fST])
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   128
  apply (auto intro: sum.neutral)
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   129
  done
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   130
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   131
lemma vector_eq_ldot: "(\<forall>x. x \<bullet> y = x \<bullet> z) \<longleftrightarrow> y = z"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   132
proof
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   133
  assume "\<forall>x. x \<bullet> y = x \<bullet> z"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   134
  then have "\<forall>x. x \<bullet> (y - z) = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   135
    by (simp add: inner_diff)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   136
  then have "(y - z) \<bullet> (y - z) = 0" ..
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   137
  then show "y = z" by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   138
qed simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   139
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   140
lemma vector_eq_rdot: "(\<forall>z. x \<bullet> z = y \<bullet> z) \<longleftrightarrow> x = y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   141
proof
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   142
  assume "\<forall>z. x \<bullet> z = y \<bullet> z"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   143
  then have "\<forall>z. (x - y) \<bullet> z = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   144
    by (simp add: inner_diff)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   145
  then have "(x - y) \<bullet> (x - y) = 0" ..
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   146
  then show "x = y" by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   147
qed simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   148
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   149
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   150
subsection \<open>Orthogonality.\<close>
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   151
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   152
definition%important (in real_inner) "orthogonal x y \<longleftrightarrow> x \<bullet> y = 0"
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   153
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   154
context real_inner
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   155
begin
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   156
63072
eb5d493a9e03 renamings and refinements
paulson <lp15@cam.ac.uk>
parents: 63053
diff changeset
   157
lemma orthogonal_self: "orthogonal x x \<longleftrightarrow> x = 0"
eb5d493a9e03 renamings and refinements
paulson <lp15@cam.ac.uk>
parents: 63053
diff changeset
   158
  by (simp add: orthogonal_def)
eb5d493a9e03 renamings and refinements
paulson <lp15@cam.ac.uk>
parents: 63053
diff changeset
   159
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   160
lemma orthogonal_clauses:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   161
  "orthogonal a 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   162
  "orthogonal a x \<Longrightarrow> orthogonal a (c *\<^sub>R x)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   163
  "orthogonal a x \<Longrightarrow> orthogonal a (- x)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   164
  "orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x + y)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   165
  "orthogonal a x \<Longrightarrow> orthogonal a y \<Longrightarrow> orthogonal a (x - y)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   166
  "orthogonal 0 a"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   167
  "orthogonal x a \<Longrightarrow> orthogonal (c *\<^sub>R x) a"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   168
  "orthogonal x a \<Longrightarrow> orthogonal (- x) a"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   169
  "orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x + y) a"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   170
  "orthogonal x a \<Longrightarrow> orthogonal y a \<Longrightarrow> orthogonal (x - y) a"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   171
  unfolding orthogonal_def inner_add inner_diff by auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   172
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   173
end
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   174
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   175
lemma orthogonal_commute: "orthogonal x y \<longleftrightarrow> orthogonal y x"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   176
  by (simp add: orthogonal_def inner_commute)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   177
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   178
lemma orthogonal_scaleR [simp]: "c \<noteq> 0 \<Longrightarrow> orthogonal (c *\<^sub>R x) = orthogonal x"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   179
  by (rule ext) (simp add: orthogonal_def)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   180
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   181
lemma pairwise_ortho_scaleR:
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   182
    "pairwise (\<lambda>i j. orthogonal (f i) (g j)) B
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   183
    \<Longrightarrow> pairwise (\<lambda>i j. orthogonal (a i *\<^sub>R f i) (a j *\<^sub>R g j)) B"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   184
  by (auto simp: pairwise_def orthogonal_clauses)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   185
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   186
lemma orthogonal_rvsum:
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   187
    "\<lbrakk>finite s; \<And>y. y \<in> s \<Longrightarrow> orthogonal x (f y)\<rbrakk> \<Longrightarrow> orthogonal x (sum f s)"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   188
  by (induction s rule: finite_induct) (auto simp: orthogonal_clauses)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   189
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   190
lemma orthogonal_lvsum:
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   191
    "\<lbrakk>finite s; \<And>x. x \<in> s \<Longrightarrow> orthogonal (f x) y\<rbrakk> \<Longrightarrow> orthogonal (sum f s) y"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   192
  by (induction s rule: finite_induct) (auto simp: orthogonal_clauses)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   193
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   194
lemma norm_add_Pythagorean:
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   195
  assumes "orthogonal a b"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   196
    shows "norm(a + b) ^ 2 = norm a ^ 2 + norm b ^ 2"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   197
proof -
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   198
  from assms have "(a - (0 - b)) \<bullet> (a - (0 - b)) = a \<bullet> a - (0 - b \<bullet> b)"
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   199
    by (simp add: algebra_simps orthogonal_def inner_commute)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   200
  then show ?thesis
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   201
    by (simp add: power2_norm_eq_inner)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   202
qed
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   203
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   204
lemma norm_sum_Pythagorean:
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   205
  assumes "finite I" "pairwise (\<lambda>i j. orthogonal (f i) (f j)) I"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   206
    shows "(norm (sum f I))\<^sup>2 = (\<Sum>i\<in>I. (norm (f i))\<^sup>2)"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   207
using assms
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   208
proof (induction I rule: finite_induct)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   209
  case empty then show ?case by simp
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   210
next
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   211
  case (insert x I)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   212
  then have "orthogonal (f x) (sum f I)"
63114
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   213
    by (metis pairwise_insert orthogonal_rvsum)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   214
  with insert show ?case
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   215
    by (simp add: pairwise_insert norm_add_Pythagorean)
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   216
qed
27afe7af7379 Lots of new material for multivariate analysis
paulson <lp15@cam.ac.uk>
parents: 63075
diff changeset
   217
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   218
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   219
subsection \<open>Bilinear functions.\<close>
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   220
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   221
definition%important "bilinear f \<longleftrightarrow> (\<forall>x. linear (\<lambda>y. f x y)) \<and> (\<forall>y. linear (\<lambda>x. f x y))"
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   222
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   223
lemma bilinear_ladd: "bilinear h \<Longrightarrow> h (x + y) z = h x z + h y z"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   224
  by (simp add: bilinear_def linear_iff)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   225
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   226
lemma bilinear_radd: "bilinear h \<Longrightarrow> h x (y + z) = h x y + h x z"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   227
  by (simp add: bilinear_def linear_iff)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   228
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   229
lemma bilinear_lmul: "bilinear h \<Longrightarrow> h (c *\<^sub>R x) y = c *\<^sub>R h x y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   230
  by (simp add: bilinear_def linear_iff)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   231
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   232
lemma bilinear_rmul: "bilinear h \<Longrightarrow> h x (c *\<^sub>R y) = c *\<^sub>R h x y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   233
  by (simp add: bilinear_def linear_iff)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   234
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   235
lemma bilinear_lneg: "bilinear h \<Longrightarrow> h (- x) y = - h x y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   236
  by (drule bilinear_lmul [of _ "- 1"]) simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   237
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   238
lemma bilinear_rneg: "bilinear h \<Longrightarrow> h x (- y) = - h x y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   239
  by (drule bilinear_rmul [of _ _ "- 1"]) simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   240
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   241
lemma (in ab_group_add) eq_add_iff: "x = x + y \<longleftrightarrow> y = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   242
  using add_left_imp_eq[of x y 0] by auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   243
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   244
lemma bilinear_lzero:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   245
  assumes "bilinear h"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   246
  shows "h 0 x = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   247
  using bilinear_ladd [OF assms, of 0 0 x] by (simp add: eq_add_iff field_simps)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   248
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   249
lemma bilinear_rzero:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   250
  assumes "bilinear h"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   251
  shows "h x 0 = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   252
  using bilinear_radd [OF assms, of x 0 0 ] by (simp add: eq_add_iff field_simps)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   253
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   254
lemma bilinear_lsub: "bilinear h \<Longrightarrow> h (x - y) z = h x z - h y z"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   255
  using bilinear_ladd [of h x "- y"] by (simp add: bilinear_lneg)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   256
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   257
lemma bilinear_rsub: "bilinear h \<Longrightarrow> h z (x - y) = h z x - h z y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   258
  using bilinear_radd [of h _ x "- y"] by (simp add: bilinear_rneg)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   259
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   260
lemma bilinear_sum:
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   261
  assumes "bilinear h"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   262
  shows "h (sum f S) (sum g T) = sum (\<lambda>(i,j). h (f i) (g j)) (S \<times> T) "
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   263
proof -
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   264
  interpret l: linear "\<lambda>x. h x y" for y using assms by (simp add: bilinear_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   265
  interpret r: linear "\<lambda>y. h x y" for x using assms by (simp add: bilinear_def)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   266
  have "h (sum f S) (sum g T) = sum (\<lambda>x. h (f x) (sum g T)) S"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   267
    by (simp add: l.sum)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   268
  also have "\<dots> = sum (\<lambda>x. sum (\<lambda>y. h (f x) (g y)) T) S"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   269
    by (rule sum.cong) (simp_all add: r.sum)
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   270
  finally show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   271
    unfolding sum.cartesian_product .
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   272
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   273
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   274
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   275
subsection \<open>Adjoints.\<close>
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   276
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   277
definition%important "adjoint f = (SOME f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y)"
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   278
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   279
lemma adjoint_unique:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   280
  assumes "\<forall>x y. inner (f x) y = inner x (g y)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   281
  shows "adjoint f = g"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   282
  unfolding adjoint_def
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   283
proof (rule some_equality)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   284
  show "\<forall>x y. inner (f x) y = inner x (g y)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   285
    by (rule assms)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   286
next
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   287
  fix h
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   288
  assume "\<forall>x y. inner (f x) y = inner x (h y)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   289
  then have "\<forall>x y. inner x (g y) = inner x (h y)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   290
    using assms by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   291
  then have "\<forall>x y. inner x (g y - h y) = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   292
    by (simp add: inner_diff_right)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   293
  then have "\<forall>y. inner (g y - h y) (g y - h y) = 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   294
    by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   295
  then have "\<forall>y. h y = g y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   296
    by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   297
  then show "h = g" by (simp add: ext)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   298
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   299
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   300
text \<open>TODO: The following lemmas about adjoints should hold for any
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 63627
diff changeset
   301
  Hilbert space (i.e. complete inner product space).
6e1e8b5abbfa more symbols;
wenzelm
parents: 63627
diff changeset
   302
  (see \<^url>\<open>http://en.wikipedia.org/wiki/Hermitian_adjoint\<close>)
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   303
\<close>
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   304
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   305
lemma adjoint_works:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   306
  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   307
  assumes lf: "linear f"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   308
  shows "x \<bullet> adjoint f y = f x \<bullet> y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   309
proof -
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   310
  interpret linear f by fact
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   311
  have "\<forall>y. \<exists>w. \<forall>x. f x \<bullet> y = x \<bullet> w"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   312
  proof (intro allI exI)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   313
    fix y :: "'m" and x
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   314
    let ?w = "(\<Sum>i\<in>Basis. (f i \<bullet> y) *\<^sub>R i) :: 'n"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   315
    have "f x \<bullet> y = f (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R i) \<bullet> y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   316
      by (simp add: euclidean_representation)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   317
    also have "\<dots> = (\<Sum>i\<in>Basis. (x \<bullet> i) *\<^sub>R f i) \<bullet> y"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   318
      by (simp add: sum scale)
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   319
    finally show "f x \<bullet> y = x \<bullet> ?w"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   320
      by (simp add: inner_sum_left inner_sum_right mult.commute)
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   321
  qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   322
  then show ?thesis
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   323
    unfolding adjoint_def choice_iff
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   324
    by (intro someI2_ex[where Q="\<lambda>f'. x \<bullet> f' y = f x \<bullet> y"]) auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   325
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   326
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   327
lemma adjoint_clauses:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   328
  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   329
  assumes lf: "linear f"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   330
  shows "x \<bullet> adjoint f y = f x \<bullet> y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   331
    and "adjoint f y \<bullet> x = y \<bullet> f x"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   332
  by (simp_all add: adjoint_works[OF lf] inner_commute)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   333
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   334
lemma adjoint_linear:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   335
  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   336
  assumes lf: "linear f"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   337
  shows "linear (adjoint f)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   338
  by (simp add: lf linear_iff euclidean_eq_iff[where 'a='n] euclidean_eq_iff[where 'a='m]
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   339
    adjoint_clauses[OF lf] inner_distrib)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   340
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   341
lemma adjoint_adjoint:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   342
  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   343
  assumes lf: "linear f"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   344
  shows "adjoint (adjoint f) = f"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   345
  by (rule adjoint_unique, simp add: adjoint_clauses [OF lf])
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   346
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   347
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   348
subsection%unimportant \<open>Interlude: Some properties of real sets\<close>
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   349
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   350
lemma seq_mono_lemma:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   351
  assumes "\<forall>(n::nat) \<ge> m. (d n :: real) < e n"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   352
    and "\<forall>n \<ge> m. e n \<le> e m"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   353
  shows "\<forall>n \<ge> m. d n < e m"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   354
  using assms
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   355
  apply auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   356
  apply (erule_tac x="n" in allE)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   357
  apply (erule_tac x="n" in allE)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   358
  apply auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   359
  done
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   360
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   361
lemma infinite_enumerate:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   362
  assumes fS: "infinite S"
66447
a1f5c5c26fa6 Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents: 66420
diff changeset
   363
  shows "\<exists>r::nat\<Rightarrow>nat. strict_mono r \<and> (\<forall>n. r n \<in> S)"
a1f5c5c26fa6 Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents: 66420
diff changeset
   364
  unfolding strict_mono_def
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   365
  using enumerate_in_set[OF fS] enumerate_mono[of _ _ S] fS by auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   366
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   367
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)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   368
  apply auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   369
  apply (rule_tac x="d/2" in exI)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   370
  apply auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   371
  done
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   372
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 67399
diff changeset
   373
lemma approachable_lt_le2:  \<comment> \<open>like the above, but pushes aside an extra formula\<close>
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   374
    "(\<exists>(d::real) > 0. \<forall>x. Q x \<longrightarrow> f x < d \<longrightarrow> P x) \<longleftrightarrow> (\<exists>d>0. \<forall>x. f x \<le> d \<longrightarrow> Q x \<longrightarrow> P x)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   375
  apply auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   376
  apply (rule_tac x="d/2" in exI, auto)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   377
  done
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   378
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   379
lemma triangle_lemma:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   380
  fixes x y z :: real
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   381
  assumes x: "0 \<le> x"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   382
    and y: "0 \<le> y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   383
    and z: "0 \<le> z"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   384
    and xy: "x\<^sup>2 \<le> y\<^sup>2 + z\<^sup>2"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   385
  shows "x \<le> y + z"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   386
proof -
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   387
  have "y\<^sup>2 + z\<^sup>2 \<le> y\<^sup>2 + 2 * y * z + z\<^sup>2"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   388
    using z y by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   389
  with xy have th: "x\<^sup>2 \<le> (y + z)\<^sup>2"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   390
    by (simp add: power2_eq_square field_simps)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   391
  from y z have yz: "y + z \<ge> 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   392
    by arith
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   393
  from power2_le_imp_le[OF th yz] show ?thesis .
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   394
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   395
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   396
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   397
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   398
subsection \<open>Archimedean properties and useful consequences\<close>
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   399
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   400
text\<open>Bernoulli's inequality\<close>
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   401
proposition%important Bernoulli_inequality:
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   402
  fixes x :: real
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   403
  assumes "-1 \<le> x"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   404
    shows "1 + n * x \<le> (1 + x) ^ n"
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   405
proof%unimportant (induct n)
63050
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   406
  case 0
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   407
  then show ?case by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   408
next
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   409
  case (Suc n)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   410
  have "1 + Suc n * x \<le> 1 + (Suc n)*x + n * x^2"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   411
    by (simp add: algebra_simps)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   412
  also have "... = (1 + x) * (1 + n*x)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   413
    by (auto simp: power2_eq_square algebra_simps  of_nat_Suc)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   414
  also have "... \<le> (1 + x) ^ Suc n"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   415
    using Suc.hyps assms mult_left_mono by fastforce
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   416
  finally show ?case .
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   417
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   418
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   419
corollary Bernoulli_inequality_even:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   420
  fixes x :: real
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   421
  assumes "even n"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   422
    shows "1 + n * x \<le> (1 + x) ^ n"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   423
proof (cases "-1 \<le> x \<or> n=0")
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   424
  case True
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   425
  then show ?thesis
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   426
    by (auto simp: Bernoulli_inequality)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   427
next
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   428
  case False
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   429
  then have "real n \<ge> 1"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   430
    by simp
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   431
  with False have "n * x \<le> -1"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   432
    by (metis linear minus_zero mult.commute mult.left_neutral mult_left_mono_neg neg_le_iff_le order_trans zero_le_one)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   433
  then have "1 + n * x \<le> 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   434
    by auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   435
  also have "... \<le> (1 + x) ^ n"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   436
    using assms
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   437
    using zero_le_even_power by blast
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   438
  finally show ?thesis .
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   439
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   440
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   441
corollary real_arch_pow:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   442
  fixes x :: real
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   443
  assumes x: "1 < x"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   444
  shows "\<exists>n. y < x^n"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   445
proof -
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   446
  from x have x0: "x - 1 > 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   447
    by arith
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   448
  from reals_Archimedean3[OF x0, rule_format, of y]
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   449
  obtain n :: nat where n: "y < real n * (x - 1)" by metis
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   450
  from x0 have x00: "x- 1 \<ge> -1" by arith
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   451
  from Bernoulli_inequality[OF x00, of n] n
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   452
  have "y < x^n" by auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   453
  then show ?thesis by metis
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   454
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   455
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   456
corollary real_arch_pow_inv:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   457
  fixes x y :: real
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   458
  assumes y: "y > 0"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   459
    and x1: "x < 1"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   460
  shows "\<exists>n. x^n < y"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   461
proof (cases "x > 0")
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   462
  case True
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   463
  with x1 have ix: "1 < 1/x" by (simp add: field_simps)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   464
  from real_arch_pow[OF ix, of "1/y"]
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   465
  obtain n where n: "1/y < (1/x)^n" by blast
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   466
  then show ?thesis using y \<open>x > 0\<close>
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   467
    by (auto simp add: field_simps)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   468
next
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   469
  case False
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   470
  with y x1 show ?thesis
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   471
    apply auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   472
    apply (rule exI[where x=1])
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   473
    apply auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   474
    done
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   475
qed
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   476
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   477
lemma forall_pos_mono:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   478
  "(\<And>d e::real. d < e \<Longrightarrow> P d \<Longrightarrow> P e) \<Longrightarrow>
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   479
    (\<And>n::nat. n \<noteq> 0 \<Longrightarrow> P (inverse (real n))) \<Longrightarrow> (\<And>e. 0 < e \<Longrightarrow> P e)"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   480
  by (metis real_arch_inverse)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   481
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   482
lemma forall_pos_mono_1:
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   483
  "(\<And>d e::real. d < e \<Longrightarrow> P d \<Longrightarrow> P e) \<Longrightarrow>
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   484
    (\<And>n. P (inverse (real (Suc n)))) \<Longrightarrow> 0 < e \<Longrightarrow> P e"
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   485
  apply (rule forall_pos_mono)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   486
  apply auto
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   487
  apply (metis Suc_pred of_nat_Suc)
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   488
  done
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   489
ca4cce24c75d Linear_Algebra: move abstract concepts to front
hoelzl
parents: 63007
diff changeset
   490
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   491
subsection%unimportant \<open>Euclidean Spaces as Typeclass\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   492
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   493
lemma independent_Basis: "independent Basis"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   494
  by (rule independent_Basis)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   495
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   496
lemma span_Basis [simp]: "span Basis = UNIV"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   497
  by (rule span_Basis)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   498
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   499
lemma in_span_Basis: "x \<in> span Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   500
  unfolding span_Basis ..
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   501
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   502
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   503
subsection%unimportant \<open>Linearity and Bilinearity continued\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   504
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   505
lemma linear_bounded:
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   506
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   507
  assumes lf: "linear f"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   508
  shows "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x"
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   509
proof
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   510
  interpret linear f by fact
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   511
  let ?B = "\<Sum>b\<in>Basis. norm (f b)"
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   512
  show "\<forall>x. norm (f x) \<le> ?B * norm x"
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   513
  proof
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   514
    fix x :: 'a
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   515
    let ?g = "\<lambda>b. (x \<bullet> b) *\<^sub>R f b"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   516
    have "norm (f x) = norm (f (\<Sum>b\<in>Basis. (x \<bullet> b) *\<^sub>R b))"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   517
      unfolding euclidean_representation ..
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   518
    also have "\<dots> = norm (sum ?g Basis)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   519
      by (simp add: sum scale)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   520
    finally have th0: "norm (f x) = norm (sum ?g Basis)" .
64773
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
   521
    have th: "norm (?g i) \<le> norm (f i) * norm x" if "i \<in> Basis" for i
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
   522
    proof -
223b2ebdda79 Many new theorems, and more tidying
paulson <lp15@cam.ac.uk>
parents: 64267
diff changeset
   523
      from Basis_le_norm[OF that, of x]
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   524
      show "norm (?g i) \<le> norm (f i) * norm x"
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   525
        unfolding norm_scaleR
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
   526
        apply (subst mult.commute)
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   527
        apply (rule mult_mono)
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   528
        apply (auto simp add: field_simps)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   529
        done
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   530
    qed
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   531
    from sum_norm_le[of _ ?g, OF th]
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   532
    show "norm (f x) \<le> ?B * norm x"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   533
      unfolding th0 sum_distrib_right by metis
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   534
  qed
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   535
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   536
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   537
lemma linear_conv_bounded_linear:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   538
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   539
  shows "linear f \<longleftrightarrow> bounded_linear f"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   540
proof
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   541
  assume "linear f"
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   542
  then interpret f: linear f .
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   543
  show "bounded_linear f"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   544
  proof
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   545
    have "\<exists>B. \<forall>x. norm (f x) \<le> B * norm x"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   546
      using \<open>linear f\<close> by (rule linear_bounded)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   547
    then show "\<exists>K. \<forall>x. norm (f x) \<le> norm x * K"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
   548
      by (simp add: mult.commute)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   549
  qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   550
next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   551
  assume "bounded_linear f"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   552
  then interpret f: bounded_linear f .
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   553
  show "linear f" ..
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   554
qed
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   555
61518
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61306
diff changeset
   556
lemmas linear_linear = linear_conv_bounded_linear[symmetric]
ff12606337e9 new lemmas about topology, etc., for Cauchy integral formula
paulson
parents: 61306
diff changeset
   557
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   558
lemma linear_bounded_pos:
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   559
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   560
  assumes lf: "linear f"
67982
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   561
 obtains B where "B > 0" "\<And>x. norm (f x) \<le> B * norm x"
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   562
proof -
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   563
  have "\<exists>B > 0. \<forall>x. norm (f x) \<le> norm x * B"
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   564
    using lf unfolding linear_conv_bounded_linear
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   565
    by (rule bounded_linear.pos_bounded)
67982
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   566
  with that show ?thesis
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   567
    by (auto simp: mult.commute)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   568
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   569
67982
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   570
lemma linear_invertible_bounded_below_pos:
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   571
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::euclidean_space"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   572
  assumes "linear f" "linear g" "g \<circ> f = id"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   573
  obtains B where "B > 0" "\<And>x. B * norm x \<le> norm(f x)"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   574
proof -
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   575
  obtain B where "B > 0" and B: "\<And>x. norm (g x) \<le> B * norm x"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   576
    using linear_bounded_pos [OF \<open>linear g\<close>] by blast
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   577
  show thesis
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   578
  proof
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   579
    show "0 < 1/B"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   580
      by (simp add: \<open>B > 0\<close>)
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   581
    show "1/B * norm x \<le> norm (f x)" for x
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   582
    proof -
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   583
      have "1/B * norm x = 1/B * norm (g (f x))"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   584
        using assms by (simp add: pointfree_idE)
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   585
      also have "\<dots> \<le> norm (f x)"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   586
        using B [of "f x"] by (simp add: \<open>B > 0\<close> mult.commute pos_divide_le_eq)
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   587
      finally show ?thesis .
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   588
    qed
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   589
  qed
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   590
qed
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   591
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   592
lemma linear_inj_bounded_below_pos:
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   593
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::euclidean_space"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   594
  assumes "linear f" "inj f"
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   595
  obtains B where "B > 0" "\<And>x. B * norm x \<le> norm(f x)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   596
  using linear_injective_left_inverse [OF assms]
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   597
    linear_invertible_bounded_below_pos assms by blast
67982
7643b005b29a various new results on measures, integrals, etc., and some simplified proofs
paulson <lp15@cam.ac.uk>
parents: 67962
diff changeset
   598
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   599
lemma bounded_linearI':
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   600
  fixes f ::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   601
  assumes "\<And>x y. f (x + y) = f x + f y"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   602
    and "\<And>c x. f (c *\<^sub>R x) = c *\<^sub>R f x"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   603
  shows "bounded_linear f"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   604
  using assms linearI linear_conv_bounded_linear by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   605
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   606
lemma bilinear_bounded:
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   607
  fixes h :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space \<Rightarrow> 'k::real_normed_vector"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   608
  assumes bh: "bilinear h"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   609
  shows "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   610
proof (clarify intro!: exI[of _ "\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. norm (h i j)"])
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   611
  fix x :: 'm
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   612
  fix y :: 'n
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   613
  have "norm (h x y) = norm (h (sum (\<lambda>i. (x \<bullet> i) *\<^sub>R i) Basis) (sum (\<lambda>i. (y \<bullet> i) *\<^sub>R i) Basis))"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   614
    apply (subst euclidean_representation[where 'a='m])
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   615
    apply (subst euclidean_representation[where 'a='n])
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   616
    apply rule
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   617
    done
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   618
  also have "\<dots> = norm (sum (\<lambda> (i,j). h ((x \<bullet> i) *\<^sub>R i) ((y \<bullet> j) *\<^sub>R j)) (Basis \<times> Basis))"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   619
    unfolding bilinear_sum[OF bh] ..
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   620
  finally have th: "norm (h x y) = \<dots>" .
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   621
  show "norm (h x y) \<le> (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. norm (h i j)) * norm x * norm y"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   622
    apply (auto simp add: sum_distrib_right th sum.cartesian_product)
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   623
    apply (rule sum_norm_le)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   624
    apply (auto simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh]
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   625
      field_simps simp del: scaleR_scaleR)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   626
    apply (rule mult_mono)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   627
    apply (auto simp add: zero_le_mult_iff Basis_le_norm)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   628
    apply (rule mult_mono)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   629
    apply (auto simp add: zero_le_mult_iff Basis_le_norm)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   630
    done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   631
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   632
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   633
lemma bilinear_conv_bounded_bilinear:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   634
  fixes h :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> 'c::real_normed_vector"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   635
  shows "bilinear h \<longleftrightarrow> bounded_bilinear h"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   636
proof
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   637
  assume "bilinear h"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   638
  show "bounded_bilinear h"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   639
  proof
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   640
    fix x y z
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   641
    show "h (x + y) z = h x z + h y z"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   642
      using \<open>bilinear h\<close> unfolding bilinear_def linear_iff by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   643
  next
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   644
    fix x y z
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   645
    show "h x (y + z) = h x y + h x z"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   646
      using \<open>bilinear h\<close> unfolding bilinear_def linear_iff by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   647
  next
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   648
    fix r x y
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   649
    show "h (scaleR r x) y = scaleR r (h x y)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   650
      using \<open>bilinear h\<close> unfolding bilinear_def linear_iff
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   651
      by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   652
  next
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   653
    fix r x y
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   654
    show "h x (scaleR r y) = scaleR r (h x y)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   655
      using \<open>bilinear h\<close> unfolding bilinear_def linear_iff
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   656
      by simp
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   657
  next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   658
    have "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   659
      using \<open>bilinear h\<close> by (rule bilinear_bounded)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   660
    then show "\<exists>K. \<forall>x y. norm (h x y) \<le> norm x * norm y * K"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   661
      by (simp add: ac_simps)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   662
  qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   663
next
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   664
  assume "bounded_bilinear h"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   665
  then interpret h: bounded_bilinear h .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   666
  show "bilinear h"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   667
    unfolding bilinear_def linear_conv_bounded_linear
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   668
    using h.bounded_linear_left h.bounded_linear_right by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   669
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   670
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   671
lemma bilinear_bounded_pos:
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   672
  fixes h :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> 'c::real_normed_vector"
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   673
  assumes bh: "bilinear h"
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   674
  shows "\<exists>B > 0. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   675
proof -
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   676
  have "\<exists>B > 0. \<forall>x y. norm (h x y) \<le> norm x * norm y * B"
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   677
    using bh [unfolded bilinear_conv_bounded_bilinear]
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   678
    by (rule bounded_bilinear.pos_bounded)
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   679
  then show ?thesis
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   680
    by (simp only: ac_simps)
53939
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   681
qed
eb25bddf6a22 tuned proofs
huffman
parents: 53938
diff changeset
   682
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   683
lemma bounded_linear_imp_has_derivative: "bounded_linear f \<Longrightarrow> (f has_derivative f) net"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   684
  by (auto simp add: has_derivative_def linear_diff linear_linear linear_def
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   685
      dest: bounded_linear.linear)
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   686
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   687
lemma linear_imp_has_derivative:
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   688
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   689
  shows "linear f \<Longrightarrow> (f has_derivative f) net"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   690
  by (simp add: bounded_linear_imp_has_derivative linear_conv_bounded_linear)
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   691
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   692
lemma bounded_linear_imp_differentiable: "bounded_linear f \<Longrightarrow> f differentiable net"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   693
  using bounded_linear_imp_has_derivative differentiable_def by blast
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   694
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   695
lemma linear_imp_differentiable:
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   696
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   697
  shows "linear f \<Longrightarrow> f differentiable net"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   698
  by (metis linear_imp_has_derivative differentiable_def)
63469
b6900858dcb9 lots of new theorems about differentiable_on, retracts, ANRs, etc.
paulson <lp15@cam.ac.uk>
parents: 63170
diff changeset
   699
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   700
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   701
subsection%unimportant \<open>We continue.\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   702
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   703
lemma independent_bound:
53716
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
   704
  fixes S :: "'a::euclidean_space set"
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
   705
  shows "independent S \<Longrightarrow> finite S \<and> card S \<le> DIM('a)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   706
  by (metis dim_subset_UNIV finiteI_independent dim_span_eq_card_independent)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   707
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   708
lemmas independent_imp_finite = finiteI_independent
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   709
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61520
diff changeset
   710
corollary
60303
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60162
diff changeset
   711
  fixes S :: "'a::euclidean_space set"
00c06f1315d0 New material about paths, and some lemmas
paulson
parents: 60162
diff changeset
   712
  assumes "independent S"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   713
  shows independent_card_le:"card S \<le> DIM('a)"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   714
  using assms independent_bound by auto
63075
60a42a4166af lemmas about dimension, hyperplanes, span, etc.
paulson <lp15@cam.ac.uk>
parents: 63072
diff changeset
   715
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   716
lemma dependent_biggerset:
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   717
  fixes S :: "'a::euclidean_space set"
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   718
  shows "(finite S \<Longrightarrow> card S > DIM('a)) \<Longrightarrow> dependent S"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   719
  by (metis independent_bound not_less)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   720
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   721
text \<open>Picking an orthogonal replacement for a spanning set.\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   722
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   723
lemma vector_sub_project_orthogonal:
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   724
  fixes b x :: "'a::euclidean_space"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   725
  shows "b \<bullet> (x - ((b \<bullet> x) / (b \<bullet> b)) *\<^sub>R b) = 0"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   726
  unfolding inner_simps by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   727
44528
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   728
lemma pairwise_orthogonal_insert:
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   729
  assumes "pairwise orthogonal S"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   730
    and "\<And>y. y \<in> S \<Longrightarrow> orthogonal x y"
44528
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   731
  shows "pairwise orthogonal (insert x S)"
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   732
  using assms unfolding pairwise_def
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   733
  by (auto simp add: orthogonal_commute)
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   734
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   735
lemma basis_orthogonal:
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   736
  fixes B :: "'a::real_inner set"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   737
  assumes fB: "finite B"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   738
  shows "\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   739
  (is " \<exists>C. ?P B C")
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   740
  using fB
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   741
proof (induct rule: finite_induct)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   742
  case empty
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   743
  then show ?case
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   744
    apply (rule exI[where x="{}"])
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   745
    apply (auto simp add: pairwise_def)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   746
    done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   747
next
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   748
  case (insert a B)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   749
  note fB = \<open>finite B\<close> and aB = \<open>a \<notin> B\<close>
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   750
  from \<open>\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   751
  obtain C where C: "finite C" "card C \<le> card B"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   752
    "span C = span B" "pairwise orthogonal C" by blast
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   753
  let ?a = "a - sum (\<lambda>x. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x) C"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   754
  let ?C = "insert ?a C"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   755
  from C(1) have fC: "finite ?C"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   756
    by simp
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   757
  from fB aB C(1,2) have cC: "card ?C \<le> card (insert a B)"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   758
    by (simp add: card_insert_if)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   759
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   760
    fix x k
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   761
    have th0: "\<And>(a::'a) b c. a - (b - c) = c + (a - b)"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   762
      by (simp add: field_simps)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   763
    have "x - k *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C \<longleftrightarrow> x - k *\<^sub>R a \<in> span C"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   764
      apply (simp only: scaleR_right_diff_distrib th0)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   765
      apply (rule span_add_eq)
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   766
      apply (rule span_scale)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   767
      apply (rule span_sum)
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   768
      apply (rule span_scale)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   769
      apply (rule span_base)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   770
      apply assumption
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   771
      done
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   772
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   773
  then have SC: "span ?C = span (insert a B)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   774
    unfolding set_eq_iff span_breakdown_eq C(3)[symmetric] by auto
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   775
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   776
    fix y
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   777
    assume yC: "y \<in> C"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   778
    then have Cy: "C = insert y (C - {y})"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   779
      by blast
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   780
    have fth: "finite (C - {y})"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   781
      using C by simp
44528
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   782
    have "orthogonal ?a y"
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   783
      unfolding orthogonal_def
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   784
      unfolding inner_diff inner_sum_left right_minus_eq
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   785
      unfolding sum.remove [OF \<open>finite C\<close> \<open>y \<in> C\<close>]
44528
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   786
      apply (clarsimp simp add: inner_commute[of y a])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   787
      apply (rule sum.neutral)
44528
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   788
      apply clarsimp
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   789
      apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format])
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   790
      using \<open>y \<in> C\<close> by auto
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   791
  }
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   792
  with \<open>pairwise orthogonal C\<close> have CPO: "pairwise orthogonal ?C"
44528
0b8e0dbb2bdd generalize and shorten proof of basis_orthogonal
huffman
parents: 44527
diff changeset
   793
    by (rule pairwise_orthogonal_insert)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   794
  from fC cC SC CPO have "?P (insert a B) ?C"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   795
    by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   796
  then show ?case by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   797
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   798
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   799
lemma orthogonal_basis_exists:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   800
  fixes V :: "('a::euclidean_space) set"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   801
  shows "\<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and>
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   802
  (card B = dim V) \<and> pairwise orthogonal B"
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   803
proof -
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   804
  from basis_exists[of V] obtain B where
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   805
    B: "B \<subseteq> V" "independent B" "V \<subseteq> span B" "card B = dim V"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   806
    by blast
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   807
  from B have fB: "finite B" "card B = dim V"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   808
    using independent_bound by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   809
  from basis_orthogonal[OF fB(1)] obtain C where
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   810
    C: "finite C" "card C \<le> card B" "span C = span B" "pairwise orthogonal C"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   811
    by blast
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   812
  from C B have CSV: "C \<subseteq> span V"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   813
    by (metis span_superset span_mono subset_trans)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   814
  from span_mono[OF B(3)] C have SVC: "span V \<subseteq> span C"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   815
    by (simp add: span_span)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   816
  from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   817
  have iC: "independent C"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   818
    by (simp add: dim_span)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   819
  from C fB have "card C \<le> dim V"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   820
    by simp
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   821
  moreover have "dim V \<le> card C"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   822
    using span_card_ge_dim[OF CSV SVC C(1)]
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   823
    by simp
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   824
  ultimately have CdV: "card C = dim V"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   825
    using C(1) by simp
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   826
  from C B CSV CdV iC show ?thesis
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   827
    by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   828
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   829
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   830
text \<open>Low-dimensional subset is in a hyperplane (weak orthogonal complement).\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   831
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   832
lemma span_not_univ_orthogonal:
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   833
  fixes S :: "'a::euclidean_space set"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   834
  assumes sU: "span S \<noteq> UNIV"
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   835
  shows "\<exists>a::'a. a \<noteq> 0 \<and> (\<forall>x \<in> span S. a \<bullet> x = 0)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   836
proof -
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   837
  from sU obtain a where a: "a \<notin> span S"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   838
    by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   839
  from orthogonal_basis_exists obtain B where
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   840
    B: "independent B" "B \<subseteq> span S" "S \<subseteq> span B"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   841
    "card B = dim S" "pairwise orthogonal B"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   842
    by blast
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   843
  from B have fB: "finite B" "card B = dim S"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   844
    using independent_bound by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   845
  from span_mono[OF B(2)] span_mono[OF B(3)]
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   846
  have sSB: "span S = span B"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   847
    by (simp add: span_span)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   848
  let ?a = "a - sum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B"
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   849
  have "sum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B \<in> span S"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   850
    unfolding sSB
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   851
    apply (rule span_sum)
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   852
    apply (rule span_scale)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   853
    apply (rule span_base)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   854
    apply assumption
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   855
    done
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   856
  with a have a0:"?a  \<noteq> 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   857
    by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   858
  have "\<forall>x\<in>span B. ?a \<bullet> x = 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   859
  proof (rule span_induct')
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   860
    show "subspace {x. ?a \<bullet> x = 0}"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   861
      by (auto simp add: subspace_def inner_add)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   862
  next
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   863
    {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   864
      fix x
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   865
      assume x: "x \<in> B"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   866
      from x have B': "B = insert x (B - {x})"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   867
        by blast
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   868
      have fth: "finite (B - {x})"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   869
        using fB by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   870
      have "?a \<bullet> x = 0"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   871
        apply (subst B')
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   872
        using fB fth
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   873
        unfolding sum_clauses(2)[OF fth]
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   874
        apply simp unfolding inner_simps
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   875
        apply (clarsimp simp add: inner_add inner_sum_left)
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
   876
        apply (rule sum.neutral, rule ballI)
63170
eae6549dbea2 tuned proofs, to allow unfold_abs_def;
wenzelm
parents: 63148
diff changeset
   877
        apply (simp only: inner_commute)
49711
e5aaae7eadc9 tuned proofs;
wenzelm
parents: 49663
diff changeset
   878
        apply (auto simp add: x field_simps
e5aaae7eadc9 tuned proofs;
wenzelm
parents: 49663
diff changeset
   879
          intro: B(5)[unfolded pairwise_def orthogonal_def, rule_format])
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   880
        done
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   881
    }
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   882
    then show "\<forall>x \<in> B. ?a \<bullet> x = 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   883
      by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   884
  qed
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   885
  with a0 show ?thesis
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   886
    unfolding sSB by (auto intro: exI[where x="?a"])
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   887
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   888
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   889
lemma span_not_univ_subset_hyperplane:
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   890
  fixes S :: "'a::euclidean_space set"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   891
  assumes SU: "span S \<noteq> UNIV"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   892
  shows "\<exists> a. a \<noteq>0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   893
  using span_not_univ_orthogonal[OF SU] by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   894
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   895
lemma lowdim_subset_hyperplane:
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   896
  fixes S :: "'a::euclidean_space set"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   897
  assumes d: "dim S < DIM('a)"
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   898
  shows "\<exists>a::'a. a \<noteq> 0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   899
proof -
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   900
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   901
    assume "span S = UNIV"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   902
    then have "dim (span S) = dim (UNIV :: ('a) set)"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   903
      by simp
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   904
    then have "dim S = DIM('a)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   905
      by (metis Euclidean_Space.dim_UNIV dim_span)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   906
    with d have False by arith
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   907
  }
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   908
  then have th: "span S \<noteq> UNIV"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   909
    by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   910
  from span_not_univ_subset_hyperplane[OF th] show ?thesis .
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   911
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   912
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   913
lemma linear_eq_stdbasis:
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   914
  fixes f :: "'a::euclidean_space \<Rightarrow> _"
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   915
  assumes lf: "linear f"
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   916
    and lg: "linear g"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   917
    and fg: "\<And>b. b \<in> Basis \<Longrightarrow> f b = g b"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   918
  shows "f = g"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   919
  using linear_eq_on_span[OF lf lg, of Basis] fg
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   920
  by auto
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   921
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   922
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   923
text \<open>Similar results for bilinear functions.\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   924
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   925
lemma bilinear_eq:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   926
  assumes bf: "bilinear f"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   927
    and bg: "bilinear g"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   928
    and SB: "S \<subseteq> span B"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   929
    and TC: "T \<subseteq> span C"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   930
    and fg: "\<forall>x\<in> B. \<forall>y\<in> C. f x y = g x y"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   931
  shows "\<forall>x\<in>S. \<forall>y\<in>T. f x y = g x y "
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   932
proof -
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   933
  let ?P = "{x. \<forall>y\<in> span C. f x y = g x y}"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   934
  from bf bg have sp: "subspace ?P"
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53596
diff changeset
   935
    unfolding bilinear_def linear_iff subspace_def bf bg
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   936
    by (auto simp add: span_zero bilinear_lzero[OF bf] bilinear_lzero[OF bg]
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   937
        span_add Ball_def
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   938
      intro: bilinear_ladd[OF bf])
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   939
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   940
  have "\<forall>x \<in> span B. \<forall>y\<in> span C. f x y = g x y"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   941
    apply (rule span_induct' [OF _ sp])
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   942
    apply (rule ballI)
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   943
    apply (rule span_induct')
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44166
diff changeset
   944
    apply (simp add: fg)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   945
    apply (auto simp add: subspace_def)
53600
8fda7ad57466 make 'linear' into a sublocale of 'bounded_linear';
huffman
parents: 53596
diff changeset
   946
    using bf bg unfolding bilinear_def linear_iff
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   947
      apply (auto simp add: span_zero bilinear_rzero[OF bf] bilinear_rzero[OF bg]
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
   948
        span_add Ball_def
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
   949
      intro: bilinear_ladd[OF bf])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   950
    done
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   951
  then show ?thesis
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   952
    using SB TC by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   953
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   954
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   955
lemma bilinear_eq_stdbasis:
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   956
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> _"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   957
  assumes bf: "bilinear f"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   958
    and bg: "bilinear g"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   959
    and fg: "\<forall>i\<in>Basis. \<forall>j\<in>Basis. f i j = g i j"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   960
  shows "f = g"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   961
  using bilinear_eq[OF bf bg equalityD2[OF span_Basis] equalityD2[OF span_Basis] fg] by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   962
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
   963
subsection \<open>Infinity norm\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   964
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
   965
definition%important "infnorm (x::'a::euclidean_space) = Sup {\<bar>x \<bullet> b\<bar> |b. b \<in> Basis}"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   966
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   967
lemma infnorm_set_image:
53716
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
   968
  fixes x :: "'a::euclidean_space"
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   969
  shows "{\<bar>x \<bullet> i\<bar> |i. i \<in> Basis} = (\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
   970
  by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   971
53716
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
   972
lemma infnorm_Max:
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
   973
  fixes x :: "'a::euclidean_space"
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   974
  shows "infnorm x = Max ((\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis)"
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 61973
diff changeset
   975
  by (simp add: infnorm_def infnorm_set_image cSup_eq_Max)
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
   976
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   977
lemma infnorm_set_lemma:
53716
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
   978
  fixes x :: "'a::euclidean_space"
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   979
  shows "finite {\<bar>x \<bullet> i\<bar> |i. i \<in> Basis}"
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
   980
    and "{\<bar>x \<bullet> i\<bar> |i. i \<in> Basis} \<noteq> {}"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   981
  unfolding infnorm_set_image
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   982
  by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   983
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   984
lemma infnorm_pos_le:
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   985
  fixes x :: "'a::euclidean_space"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   986
  shows "0 \<le> infnorm x"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
   987
  by (simp add: infnorm_Max Max_ge_iff ex_in_conv)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   988
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   989
lemma infnorm_triangle:
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   990
  fixes x :: "'a::euclidean_space"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   991
  shows "infnorm (x + y) \<le> infnorm x + infnorm y"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
   992
proof -
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
   993
  have *: "\<And>a b c d :: real. \<bar>a\<bar> \<le> c \<Longrightarrow> \<bar>b\<bar> \<le> d \<Longrightarrow> \<bar>a + b\<bar> \<le> c + d"
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
   994
    by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   995
  show ?thesis
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
   996
    by (auto simp: infnorm_Max inner_add_left intro!: *)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   997
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
   998
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
   999
lemma infnorm_eq_0:
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1000
  fixes x :: "'a::euclidean_space"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1001
  shows "infnorm x = 0 \<longleftrightarrow> x = 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1002
proof -
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1003
  have "infnorm x \<le> 0 \<longleftrightarrow> x = 0"
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1004
    unfolding infnorm_Max by (simp add: euclidean_all_zero_iff)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1005
  then show ?thesis
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1006
    using infnorm_pos_le[of x] by simp
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1007
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1008
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1009
lemma infnorm_0: "infnorm 0 = 0"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1010
  by (simp add: infnorm_eq_0)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1011
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1012
lemma infnorm_neg: "infnorm (- x) = infnorm x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1013
  unfolding infnorm_def
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1014
  apply (rule cong[of "Sup" "Sup"])
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1015
  apply blast
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1016
  apply auto
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1017
  done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1018
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1019
lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1020
proof -
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1021
  have "y - x = - (x - y)" by simp
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1022
  then show ?thesis
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1023
    by (metis infnorm_neg)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1024
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1025
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1026
lemma real_abs_sub_infnorm: "\<bar>infnorm x - infnorm y\<bar> \<le> infnorm (x - y)"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1027
proof -
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
  1028
  have th: "\<And>(nx::real) n ny. nx \<le> n + ny \<Longrightarrow> ny \<le> n + nx \<Longrightarrow> \<bar>nx - ny\<bar> \<le> n"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1029
    by arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1030
  from infnorm_triangle[of "x - y" " y"] infnorm_triangle[of "x - y" "-x"]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1031
  have ths: "infnorm x \<le> infnorm (x - y) + infnorm y"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1032
    "infnorm y \<le> infnorm (x - y) + infnorm x"
44454
6f28f96a09bf avoid warnings
huffman
parents: 44451
diff changeset
  1033
    by (simp_all add: field_simps infnorm_neg)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1034
  from th[OF ths] show ?thesis .
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1035
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1036
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1037
lemma real_abs_infnorm: "\<bar>infnorm x\<bar> = infnorm x"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1038
  using infnorm_pos_le[of x] by arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1039
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
  1040
lemma Basis_le_infnorm:
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1041
  fixes x :: "'a::euclidean_space"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1042
  shows "b \<in> Basis \<Longrightarrow> \<bar>x \<bullet> b\<bar> \<le> infnorm x"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1043
  by (simp add: infnorm_Max)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1044
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
  1045
lemma infnorm_mul: "infnorm (a *\<^sub>R x) = \<bar>a\<bar> * infnorm x"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1046
  unfolding infnorm_Max
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1047
proof (safe intro!: Max_eqI)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1048
  let ?B = "(\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1049
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1050
    fix b :: 'a
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1051
    assume "b \<in> Basis"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1052
    then show "\<bar>a *\<^sub>R x \<bullet> b\<bar> \<le> \<bar>a\<bar> * Max ?B"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1053
      by (simp add: abs_mult mult_left_mono)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1054
  next
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1055
    from Max_in[of ?B] obtain b where "b \<in> Basis" "Max ?B = \<bar>x \<bullet> b\<bar>"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1056
      by (auto simp del: Max_in)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1057
    then show "\<bar>a\<bar> * Max ((\<lambda>i. \<bar>x \<bullet> i\<bar>) ` Basis) \<in> (\<lambda>i. \<bar>a *\<^sub>R x \<bullet> i\<bar>) ` Basis"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1058
      by (intro image_eqI[where x=b]) (auto simp: abs_mult)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1059
  }
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1060
qed simp
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1061
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1062
lemma infnorm_mul_lemma: "infnorm (a *\<^sub>R x) \<le> \<bar>a\<bar> * infnorm x"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1063
  unfolding infnorm_mul ..
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1064
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1065
lemma infnorm_pos_lt: "infnorm x > 0 \<longleftrightarrow> x \<noteq> 0"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1066
  using infnorm_pos_le[of x] infnorm_eq_0[of x] by arith
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1067
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1068
text \<open>Prove that it differs only up to a bound from Euclidean norm.\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1069
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1070
lemma infnorm_le_norm: "infnorm x \<le> norm x"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1071
  by (simp add: Basis_le_norm infnorm_Max)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50105
diff changeset
  1072
53716
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
  1073
lemma norm_le_infnorm:
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
  1074
  fixes x :: "'a::euclidean_space"
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
  1075
  shows "norm x \<le> sqrt DIM('a) * infnorm x"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1076
proof -
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1077
  let ?d = "DIM('a)"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1078
  have "real ?d \<ge> 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1079
    by simp
53077
a1b3784f8129 more symbols;
wenzelm
parents: 53015
diff changeset
  1080
  then have d2: "(sqrt (real ?d))\<^sup>2 = real ?d"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1081
    by (auto intro: real_sqrt_pow2)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1082
  have th: "sqrt (real ?d) * infnorm x \<ge> 0"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1083
    by (simp add: zero_le_mult_iff infnorm_pos_le)
53077
a1b3784f8129 more symbols;
wenzelm
parents: 53015
diff changeset
  1084
  have th1: "x \<bullet> x \<le> (sqrt (real ?d) * infnorm x)\<^sup>2"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1085
    unfolding power_mult_distrib d2
53716
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
  1086
    apply (subst euclidean_inner)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1087
    apply (subst power2_abs[symmetric])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64122
diff changeset
  1088
    apply (rule order_trans[OF sum_bounded_above[where K="\<bar>infnorm x\<bar>\<^sup>2"]])
49663
b84fafaea4bb tuned proofs;
wenzelm
parents: 49652
diff changeset
  1089
    apply (auto simp add: power2_eq_square[symmetric])
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1090
    apply (subst power2_abs[symmetric])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1091
    apply (rule power_mono)
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 50526
diff changeset
  1092
    apply (auto simp: infnorm_Max)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1093
    done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1094
  from real_le_lsqrt[OF inner_ge_zero th th1]
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1095
  show ?thesis
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1096
    unfolding norm_eq_sqrt_inner id_def .
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1097
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1098
44646
a6047ddd9377 add lemma tendsto_infnorm
huffman
parents: 44629
diff changeset
  1099
lemma tendsto_infnorm [tendsto_intros]:
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61915
diff changeset
  1100
  assumes "(f \<longlongrightarrow> a) F"
0c7e865fa7cb more symbols;
wenzelm
parents: 61915
diff changeset
  1101
  shows "((\<lambda>x. infnorm (f x)) \<longlongrightarrow> infnorm a) F"
44646
a6047ddd9377 add lemma tendsto_infnorm
huffman
parents: 44629
diff changeset
  1102
proof (rule tendsto_compose [OF LIM_I assms])
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1103
  fix r :: real
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1104
  assume "r > 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1105
  then show "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (infnorm x - infnorm a) < r"
44646
a6047ddd9377 add lemma tendsto_infnorm
huffman
parents: 44629
diff changeset
  1106
    by (metis real_norm_def le_less_trans real_abs_sub_infnorm infnorm_le_norm)
a6047ddd9377 add lemma tendsto_infnorm
huffman
parents: 44629
diff changeset
  1107
qed
a6047ddd9377 add lemma tendsto_infnorm
huffman
parents: 44629
diff changeset
  1108
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1109
text \<open>Equality in Cauchy-Schwarz and triangle inequalities.\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1110
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1111
lemma norm_cauchy_schwarz_eq: "x \<bullet> y = norm x * norm y \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1112
  (is "?lhs \<longleftrightarrow> ?rhs")
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1113
proof -
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1114
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1115
    assume h: "x = 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1116
    then have ?thesis by simp
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1117
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1118
  moreover
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1119
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1120
    assume h: "y = 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1121
    then have ?thesis by simp
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1122
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1123
  moreover
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1124
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1125
    assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1126
    from inner_eq_zero_iff[of "norm y *\<^sub>R x - norm x *\<^sub>R y"]
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1127
    have "?rhs \<longleftrightarrow>
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1128
      (norm y * (norm y * norm x * norm x - norm x * (x \<bullet> y)) -
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1129
        norm x * (norm y * (y \<bullet> x) - norm x * norm y * norm y) =  0)"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1130
      using x y
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1131
      unfolding inner_simps
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53939
diff changeset
  1132
      unfolding power2_norm_eq_inner[symmetric] power2_eq_square right_minus_eq
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1133
      apply (simp add: inner_commute)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1134
      apply (simp add: field_simps)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1135
      apply metis
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1136
      done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1137
    also have "\<dots> \<longleftrightarrow> (2 * norm x * norm y * (norm x * norm y - x \<bullet> y) = 0)" using x y
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1138
      by (simp add: field_simps inner_commute)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1139
    also have "\<dots> \<longleftrightarrow> ?lhs" using x y
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1140
      apply simp
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1141
      apply metis
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1142
      done
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1143
    finally have ?thesis by blast
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1144
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1145
  ultimately show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1146
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1147
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1148
lemma norm_cauchy_schwarz_abs_eq:
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
  1149
  "\<bar>x \<bullet> y\<bar> = norm x * norm y \<longleftrightarrow>
53716
b42d9a71fc1a tuned proofs;
wenzelm
parents: 53600
diff changeset
  1150
    norm x *\<^sub>R y = norm y *\<^sub>R x \<or> norm x *\<^sub>R y = - norm y *\<^sub>R x"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1151
  (is "?lhs \<longleftrightarrow> ?rhs")
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1152
proof -
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
  1153
  have th: "\<And>(x::real) a. a \<ge> 0 \<Longrightarrow> \<bar>x\<bar> = a \<longleftrightarrow> x = a \<or> x = - a"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1154
    by arith
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1155
  have "?rhs \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x \<or> norm (- x) *\<^sub>R y = norm y *\<^sub>R (- x)"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1156
    by simp
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1157
  also have "\<dots> \<longleftrightarrow>(x \<bullet> y = norm x * norm y \<or> (- x) \<bullet> y = norm x * norm y)"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1158
    unfolding norm_cauchy_schwarz_eq[symmetric]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1159
    unfolding norm_minus_cancel norm_scaleR ..
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1160
  also have "\<dots> \<longleftrightarrow> ?lhs"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1161
    unfolding th[OF mult_nonneg_nonneg, OF norm_ge_zero[of x] norm_ge_zero[of y]] inner_simps
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1162
    by auto
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1163
  finally show ?thesis ..
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1164
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1165
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1166
lemma norm_triangle_eq:
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1167
  fixes x y :: "'a::real_inner"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1168
  shows "norm (x + y) = norm x + norm y \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1169
proof -
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1170
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1171
    assume x: "x = 0 \<or> y = 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1172
    then have ?thesis
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1173
      by (cases "x = 0") simp_all
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1174
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1175
  moreover
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1176
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1177
    assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1178
    then have "norm x \<noteq> 0" "norm y \<noteq> 0"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1179
      by simp_all
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1180
    then have n: "norm x > 0" "norm y > 0"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1181
      using norm_ge_zero[of x] norm_ge_zero[of y] by arith+
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1182
    have th: "\<And>(a::real) b c. a + b + c \<noteq> 0 \<Longrightarrow> a = b + c \<longleftrightarrow> a\<^sup>2 = (b + c)\<^sup>2"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1183
      by algebra
53077
a1b3784f8129 more symbols;
wenzelm
parents: 53015
diff changeset
  1184
    have "norm (x + y) = norm x + norm y \<longleftrightarrow> (norm (x + y))\<^sup>2 = (norm x + norm y)\<^sup>2"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1185
      apply (rule th)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1186
      using n norm_ge_zero[of "x + y"]
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1187
      apply arith
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1188
      done
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1189
    also have "\<dots> \<longleftrightarrow> norm x *\<^sub>R y = norm y *\<^sub>R x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1190
      unfolding norm_cauchy_schwarz_eq[symmetric]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1191
      unfolding power2_norm_eq_inner inner_simps
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1192
      by (simp add: power2_norm_eq_inner[symmetric] power2_eq_square inner_commute field_simps)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1193
    finally have ?thesis .
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1194
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1195
  ultimately show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1196
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1197
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1198
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60307
diff changeset
  1199
subsection \<open>Collinearity\<close>
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1200
67962
0acdcd8f4ba1 a first shot at tagging for HOL-Analysis manual
immler
parents: 67685
diff changeset
  1201
definition%important collinear :: "'a::real_vector set \<Rightarrow> bool"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1202
  where "collinear S \<longleftrightarrow> (\<exists>u. \<forall>x \<in> S. \<forall> y \<in> S. \<exists>c. x - y = c *\<^sub>R u)"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1203
66287
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1204
lemma collinear_alt:
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1205
     "collinear S \<longleftrightarrow> (\<exists>u v. \<forall>x \<in> S. \<exists>c. x = u + c *\<^sub>R v)" (is "?lhs = ?rhs")
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1206
proof
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1207
  assume ?lhs
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1208
  then show ?rhs
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1209
    unfolding collinear_def by (metis Groups.add_ac(2) diff_add_cancel)
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1210
next
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1211
  assume ?rhs
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1212
  then obtain u v where *: "\<And>x. x \<in> S \<Longrightarrow> \<exists>c. x = u + c *\<^sub>R v"
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1213
    by (auto simp: )
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1214
  have "\<exists>c. x - y = c *\<^sub>R v" if "x \<in> S" "y \<in> S" for x y
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1215
        by (metis *[OF \<open>x \<in> S\<close>] *[OF \<open>y \<in> S\<close>] scaleR_left.diff add_diff_cancel_left)
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1216
  then show ?lhs
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1217
    using collinear_def by blast
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1218
qed
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1219
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1220
lemma collinear:
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1221
  fixes S :: "'a::{perfect_space,real_vector} set"
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1222
  shows "collinear S \<longleftrightarrow> (\<exists>u. u \<noteq> 0 \<and> (\<forall>x \<in> S. \<forall> y \<in> S. \<exists>c. x - y = c *\<^sub>R u))"
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1223
proof -
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1224
  have "\<exists>v. v \<noteq> 0 \<and> (\<forall>x\<in>S. \<forall>y\<in>S. \<exists>c. x - y = c *\<^sub>R v)"
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1225
    if "\<forall>x\<in>S. \<forall>y\<in>S. \<exists>c. x - y = c *\<^sub>R u" "u=0" for u
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1226
  proof -
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1227
    have "\<forall>x\<in>S. \<forall>y\<in>S. x = y"
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1228
      using that by auto
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1229
    moreover
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1230
    obtain v::'a where "v \<noteq> 0"
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1231
      using UNIV_not_singleton [of 0] by auto
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1232
    ultimately have "\<forall>x\<in>S. \<forall>y\<in>S. \<exists>c. x - y = c *\<^sub>R v"
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1233
      by auto
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1234
    then show ?thesis
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1235
      using \<open>v \<noteq> 0\<close> by blast
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1236
  qed
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1237
  then show ?thesis
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1238
    apply (clarsimp simp: collinear_def)
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67982
diff changeset
  1239
    by (metis scaleR_zero_right vector_fraction_eq_iff)
66287
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1240
qed
005a30862ed0 new material: Colinearity, convex sets, polytopes
paulson <lp15@cam.ac.uk>
parents: 65680
diff changeset
  1241
63881
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63680
diff changeset
  1242
lemma collinear_subset: "\<lbrakk>collinear T; S \<subseteq> T\<rbrakk> \<Longrightarrow> collinear S"
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63680
diff changeset
  1243
  by (meson collinear_def subsetCE)
b746b19197bd lots of new results about topology, affine dimension etc
paulson <lp15@cam.ac.uk>
parents: 63680
diff changeset
  1244
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60420
diff changeset
  1245
lemma collinear_empty [iff]: "collinear {}"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1246
  by (simp add: collinear_def)
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1247
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60420
diff changeset
  1248
lemma collinear_sing [iff]: "collinear {x}"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1249
  by (simp add: collinear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1250
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60420
diff changeset
  1251
lemma collinear_2 [iff]: "collinear {x, y}"
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1252
  apply (simp add: collinear_def)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1253
  apply (rule exI[where x="x - y"])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1254
  apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1255
  apply (rule exI[where x=1], simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1256
  apply (rule exI[where x="- 1"], simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1257
  done
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1258
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
  1259
lemma collinear_lemma: "collinear {0, x, y} \<longleftrightarrow> x = 0 \<or> y = 0 \<or> (\<exists>c. y = c *\<^sub>R x)"
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1260
  (is "?lhs \<longleftrightarrow> ?rhs")
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1261
proof -
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1262
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1263
    assume "x = 0 \<or> y = 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1264
    then have ?thesis
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1265
      by (cases "x = 0") (simp_all add: collinear_2 insert_commute)
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1266
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1267
  moreover
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1268
  {
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1269
    assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1270
    have ?thesis
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1271
    proof
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1272
      assume h: "?lhs"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1273
      then obtain u where u: "\<forall> x\<in> {0,x,y}. \<forall>y\<in> {0,x,y}. \<exists>c. x - y = c *\<^sub>R u"
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1274
        unfolding collinear_def by blast
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1275
      from u[rule_format, of x 0] u[rule_format, of y 0]
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1276
      obtain cx and cy where
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1277
        cx: "x = cx *\<^sub>R u" and cy: "y = cy *\<^sub>R u"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1278
        by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1279
      from cx x have cx0: "cx \<noteq> 0" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1280
      from cy y have cy0: "cy \<noteq> 0" by auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1281
      let ?d = "cy / cx"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1282
      from cx cy cx0 have "y = ?d *\<^sub>R x"
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1283
        by simp
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1284
      then show ?rhs using x y by blast
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1285
    next
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1286
      assume h: "?rhs"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1287
      then obtain c where c: "y = c *\<^sub>R x"
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1288
        using x y by blast
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1289
      show ?lhs
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1290
        unfolding collinear_def c
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1291
        apply (rule exI[where x=x])
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1292
        apply auto
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1293
        apply (rule exI[where x="- 1"], simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1294
        apply (rule exI[where x= "-c"], simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1295
        apply (rule exI[where x=1], simp)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1296
        apply (rule exI[where x="1 - c"], simp add: scaleR_left_diff_distrib)
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1297
        apply (rule exI[where x="c - 1"], simp add: scaleR_left_diff_distrib)
53406
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1298
        done
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1299
    qed
d4374a69ddff tuned proofs;
wenzelm
parents: 53077
diff changeset
  1300
  }
44133
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1301
  ultimately show ?thesis by blast
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1302
qed
691c52e900ca split Linear_Algebra.thy from Euclidean_Space.thy
huffman
parents:
diff changeset
  1303
56444
f944ae8c80a3 tuned proofs;
wenzelm
parents: 56409
diff changeset
  1304
lemma norm_cauchy_schwarz_equal: "\<bar>x \<bullet> y\<bar> = norm x * norm y \<longleftrightarrow> collinear {0, x, y}"
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1305
  unfolding norm_cauchy_schwarz_abs_eq
63075
60a42a4166af lemmas about dimension, hyperplanes, span, etc.
paulson <lp15@cam.ac.uk>
parents: 63072
diff changeset
  1306
  apply (cases "x=0", simp_all)
60a42a4166af lemmas about dimension, hyperplanes, span, etc.
paulson <lp15@cam.ac.uk>
parents: 63072
diff changeset
  1307
  apply (cases "y=0", simp_all add: insert_commute)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1308
  unfolding collinear_lemma
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1309
  apply simp
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1310
  apply (subgoal_tac "norm x \<noteq> 0")
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1311
  apply (subgoal_tac "norm y \<noteq> 0")
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1312
  apply (rule iffI)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1313
  apply (cases "norm x *\<^sub>R y = norm y *\<^sub>R x")
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1314
  apply (rule exI[where x="(1/norm x) * norm y"])
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1315
  apply (drule sym)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1316
  unfolding scaleR_scaleR[symmetric]
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1317
  apply (simp add: field_simps)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1318
  apply (rule exI[where x="(1/norm x) * - norm y"])
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1319
  apply clarify
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1320
  apply (drule sym)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1321
  unfolding scaleR_scaleR[symmetric]
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1322
  apply (simp add: field_simps)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1323
  apply (erule exE)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1324
  apply (erule ssubst)
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1325
  unfolding scaleR_scaleR
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1326
  unfolding norm_scaleR
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1327
  apply (subgoal_tac "norm x * c = \<bar>c\<bar> * norm x \<or> norm x * c = - \<bar>c\<bar> * norm x")
55775
1557a391a858 A bit of tidying up
paulson <lp15@cam.ac.uk>
parents: 55136
diff changeset
  1328
  apply (auto simp add: field_simps)
49522
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1329
  done
355f3d076924 tuned proofs;
wenzelm
parents: 44890
diff changeset
  1330
54776
db890d9fc5c2 ordered_euclidean_space compatible with more standard pointwise ordering on products; conditionally complete lattice with product order
immler
parents: 54703
diff changeset
  1331
end