src/HOL/Library/Product_Vector.thy
author huffman
Mon, 01 Jun 2009 16:59:56 -0700
changeset 31388 e0c05b595d1f
parent 31339 b4660351e8e7
child 31405 1f72869f1a2e
permissions -rw-r--r--
limits of Pair using filters
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     1
(*  Title:      HOL/Library/Product_Vector.thy
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     3
*)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     4
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     5
header {* Cartesian Products as Vector Spaces *}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     6
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     7
theory Product_Vector
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     8
imports Inner_Product Product_plus
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     9
begin
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    10
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    11
subsection {* Product is a real vector space *}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    12
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    13
instantiation "*" :: (real_vector, real_vector) real_vector
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    14
begin
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    15
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    16
definition scaleR_prod_def:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    17
  "scaleR r A = (scaleR r (fst A), scaleR r (snd A))"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    18
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    19
lemma fst_scaleR [simp]: "fst (scaleR r A) = scaleR r (fst A)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    20
  unfolding scaleR_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    21
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    22
lemma snd_scaleR [simp]: "snd (scaleR r A) = scaleR r (snd A)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    23
  unfolding scaleR_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    24
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    25
lemma scaleR_Pair [simp]: "scaleR r (a, b) = (scaleR r a, scaleR r b)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    26
  unfolding scaleR_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    27
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    28
instance proof
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    29
  fix a b :: real and x y :: "'a \<times> 'b"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    30
  show "scaleR a (x + y) = scaleR a x + scaleR a y"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    31
    by (simp add: expand_prod_eq scaleR_right_distrib)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    32
  show "scaleR (a + b) x = scaleR a x + scaleR b x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    33
    by (simp add: expand_prod_eq scaleR_left_distrib)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    34
  show "scaleR a (scaleR b x) = scaleR (a * b) x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    35
    by (simp add: expand_prod_eq)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    36
  show "scaleR 1 x = x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    37
    by (simp add: expand_prod_eq)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    38
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    39
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    40
end
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    41
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    42
subsection {* Product is a metric space *}
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    43
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    44
instantiation
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    45
  "*" :: (metric_space, metric_space) metric_space
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    46
begin
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    47
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    48
definition dist_prod_def:
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    49
  "dist (x::'a \<times> 'b) y = sqrt ((dist (fst x) (fst y))\<twosuperior> + (dist (snd x) (snd y))\<twosuperior>)"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    50
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    51
lemma dist_Pair_Pair: "dist (a, b) (c, d) = sqrt ((dist a c)\<twosuperior> + (dist b d)\<twosuperior>)"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    52
  unfolding dist_prod_def by simp
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    53
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    54
instance proof
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    55
  fix x y :: "'a \<times> 'b"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    56
  show "dist x y = 0 \<longleftrightarrow> x = y"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    57
    unfolding dist_prod_def
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    58
    by (simp add: expand_prod_eq)
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    59
next
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    60
  fix x y z :: "'a \<times> 'b"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    61
  show "dist x y \<le> dist x z + dist y z"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    62
    unfolding dist_prod_def
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    63
    apply (rule order_trans [OF _ real_sqrt_sum_squares_triangle_ineq])
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    64
    apply (rule real_sqrt_le_mono)
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    65
    apply (rule order_trans [OF add_mono])
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    66
    apply (rule power_mono [OF dist_triangle2 [of _ _ "fst z"] zero_le_dist])
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    67
    apply (rule power_mono [OF dist_triangle2 [of _ _ "snd z"] zero_le_dist])
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    68
    apply (simp only: real_sum_squared_expand)
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    69
    done
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    70
qed
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    71
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    72
end
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
    73
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    74
subsection {* Product is a normed vector space *}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    75
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    76
instantiation
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    77
  "*" :: (real_normed_vector, real_normed_vector) real_normed_vector
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    78
begin
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    79
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    80
definition norm_prod_def:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    81
  "norm x = sqrt ((norm (fst x))\<twosuperior> + (norm (snd x))\<twosuperior>)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    82
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    83
definition sgn_prod_def:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    84
  "sgn (x::'a \<times> 'b) = scaleR (inverse (norm x)) x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    85
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    86
lemma norm_Pair: "norm (a, b) = sqrt ((norm a)\<twosuperior> + (norm b)\<twosuperior>)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    87
  unfolding norm_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    88
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    89
instance proof
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    90
  fix r :: real and x y :: "'a \<times> 'b"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    91
  show "0 \<le> norm x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    92
    unfolding norm_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    93
  show "norm x = 0 \<longleftrightarrow> x = 0"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    94
    unfolding norm_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    95
    by (simp add: expand_prod_eq)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    96
  show "norm (x + y) \<le> norm x + norm y"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    97
    unfolding norm_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    98
    apply (rule order_trans [OF _ real_sqrt_sum_squares_triangle_ineq])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    99
    apply (simp add: add_mono power_mono norm_triangle_ineq)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   100
    done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   101
  show "norm (scaleR r x) = \<bar>r\<bar> * norm x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   102
    unfolding norm_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   103
    apply (simp add: norm_scaleR power_mult_distrib)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   104
    apply (simp add: right_distrib [symmetric])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   105
    apply (simp add: real_sqrt_mult_distrib)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   106
    done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   107
  show "sgn x = scaleR (inverse (norm x)) x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   108
    by (rule sgn_prod_def)
31290
f41c023d90bc define dist for products
huffman
parents: 30729
diff changeset
   109
  show "dist x y = norm (x - y)"
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   110
    unfolding dist_prod_def norm_prod_def
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   111
    by (simp add: dist_norm)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   112
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   113
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   114
end
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   115
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   116
subsection {* Product is an inner product space *}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   117
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   118
instantiation "*" :: (real_inner, real_inner) real_inner
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   119
begin
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   120
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   121
definition inner_prod_def:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   122
  "inner x y = inner (fst x) (fst y) + inner (snd x) (snd y)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   123
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   124
lemma inner_Pair [simp]: "inner (a, b) (c, d) = inner a c + inner b d"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   125
  unfolding inner_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   126
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   127
instance proof
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   128
  fix r :: real
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   129
  fix x y z :: "'a::real_inner * 'b::real_inner"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   130
  show "inner x y = inner y x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   131
    unfolding inner_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   132
    by (simp add: inner_commute)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   133
  show "inner (x + y) z = inner x z + inner y z"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   134
    unfolding inner_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   135
    by (simp add: inner_left_distrib)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   136
  show "inner (scaleR r x) y = r * inner x y"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   137
    unfolding inner_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   138
    by (simp add: inner_scaleR_left right_distrib)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   139
  show "0 \<le> inner x x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   140
    unfolding inner_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   141
    by (intro add_nonneg_nonneg inner_ge_zero)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   142
  show "inner x x = 0 \<longleftrightarrow> x = 0"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   143
    unfolding inner_prod_def expand_prod_eq
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   144
    by (simp add: add_nonneg_eq_0_iff)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   145
  show "norm x = sqrt (inner x x)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   146
    unfolding norm_prod_def inner_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   147
    by (simp add: power2_norm_eq_inner)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   148
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   149
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   150
end
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   151
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   152
subsection {* Pair operations are linear and continuous *}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   153
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 30019
diff changeset
   154
interpretation fst: bounded_linear fst
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   155
  apply (unfold_locales)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   156
  apply (rule fst_add)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   157
  apply (rule fst_scaleR)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   158
  apply (rule_tac x="1" in exI, simp add: norm_Pair)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   159
  done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   160
30729
461ee3e49ad3 interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents: 30019
diff changeset
   161
interpretation snd: bounded_linear snd
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   162
  apply (unfold_locales)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   163
  apply (rule snd_add)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   164
  apply (rule snd_scaleR)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   165
  apply (rule_tac x="1" in exI, simp add: norm_Pair)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   166
  done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   167
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   168
text {* TODO: move to NthRoot *}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   169
lemma sqrt_add_le_add_sqrt:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   170
  assumes x: "0 \<le> x" and y: "0 \<le> y"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   171
  shows "sqrt (x + y) \<le> sqrt x + sqrt y"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   172
apply (rule power2_le_imp_le)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   173
apply (simp add: real_sum_squared_expand add_nonneg_nonneg x y)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   174
apply (simp add: mult_nonneg_nonneg x y)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   175
apply (simp add: add_nonneg_nonneg x y)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   176
done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   177
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   178
lemma bounded_linear_Pair:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   179
  assumes f: "bounded_linear f"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   180
  assumes g: "bounded_linear g"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   181
  shows "bounded_linear (\<lambda>x. (f x, g x))"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   182
proof
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   183
  interpret f: bounded_linear f by fact
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   184
  interpret g: bounded_linear g by fact
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   185
  fix x y and r :: real
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   186
  show "(f (x + y), g (x + y)) = (f x, g x) + (f y, g y)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   187
    by (simp add: f.add g.add)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   188
  show "(f (r *\<^sub>R x), g (r *\<^sub>R x)) = r *\<^sub>R (f x, g x)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   189
    by (simp add: f.scaleR g.scaleR)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   190
  obtain Kf where "0 < Kf" and norm_f: "\<And>x. norm (f x) \<le> norm x * Kf"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   191
    using f.pos_bounded by fast
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   192
  obtain Kg where "0 < Kg" and norm_g: "\<And>x. norm (g x) \<le> norm x * Kg"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   193
    using g.pos_bounded by fast
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   194
  have "\<forall>x. norm (f x, g x) \<le> norm x * (Kf + Kg)"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   195
    apply (rule allI)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   196
    apply (simp add: norm_Pair)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   197
    apply (rule order_trans [OF sqrt_add_le_add_sqrt], simp, simp)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   198
    apply (simp add: right_distrib)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   199
    apply (rule add_mono [OF norm_f norm_g])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   200
    done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   201
  then show "\<exists>K. \<forall>x. norm (f x, g x) \<le> norm x * K" ..
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   202
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   203
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   204
text {*
31388
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   205
  TODO: The "tendsto" notion generalizes LIM and LIMSEQ.
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   206
  But the Cauchy proof still requires a lot of duplication.
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   207
  Is there a good way to factor out the common parts?
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   208
*}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   209
31388
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   210
lemma tendsto_Pair:
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   211
  assumes "tendsto X a net" and "tendsto Y b net"
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   212
  shows "tendsto (\<lambda>i. (X i, Y i)) (a, b) net"
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   213
proof (rule tendstoI)
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   214
  fix r :: real assume "0 < r"
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   215
  then have "0 < r / sqrt 2" (is "0 < ?s")
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   216
    by (simp add: divide_pos_pos)
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   217
  have "eventually (\<lambda>i. dist (X i) a < ?s) net"
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   218
    using `tendsto X a net` `0 < ?s` by (rule tendstoD)
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   219
  moreover
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   220
  have "eventually (\<lambda>i. dist (Y i) b < ?s) net"
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   221
    using `tendsto Y b net` `0 < ?s` by (rule tendstoD)
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   222
  ultimately
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   223
  show "eventually (\<lambda>i. dist (X i, Y i) (a, b) < r) net"
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   224
    by (rule eventually_elim2)
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   225
       (simp add: real_sqrt_sum_squares_less dist_Pair_Pair)
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   226
qed
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   227
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   228
lemma LIMSEQ_Pair:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   229
  assumes "X ----> a" and "Y ----> b"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   230
  shows "(\<lambda>n. (X n, Y n)) ----> (a, b)"
31388
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   231
using assms unfolding LIMSEQ_conv_tendsto
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   232
by (rule tendsto_Pair)
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   233
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   234
lemma LIM_Pair:
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   235
  assumes "f -- x --> a" and "g -- x --> b"
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   236
  shows "(\<lambda>x. (f x, g x)) -- x --> (a, b)"
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   237
using assms unfolding LIM_conv_tendsto
e0c05b595d1f limits of Pair using filters
huffman
parents: 31339
diff changeset
   238
by (rule tendsto_Pair)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   239
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   240
lemma Cauchy_Pair:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   241
  assumes "Cauchy X" and "Cauchy Y"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   242
  shows "Cauchy (\<lambda>n. (X n, Y n))"
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   243
proof (rule metric_CauchyI)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   244
  fix r :: real assume "0 < r"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   245
  then have "0 < r / sqrt 2" (is "0 < ?s")
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   246
    by (simp add: divide_pos_pos)
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   247
  obtain M where M: "\<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < ?s"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   248
    using metric_CauchyD [OF `Cauchy X` `0 < ?s`] ..
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   249
  obtain N where N: "\<forall>m\<ge>N. \<forall>n\<ge>N. dist (Y m) (Y n) < ?s"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   250
    using metric_CauchyD [OF `Cauchy Y` `0 < ?s`] ..
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   251
  have "\<forall>m\<ge>max M N. \<forall>n\<ge>max M N. dist (X m, Y m) (X n, Y n) < r"
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   252
    using M N by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair)
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   253
  then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. dist (X m, Y m) (X n, Y n) < r" ..
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   254
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   255
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   256
lemma isCont_Pair [simp]:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   257
  "\<lbrakk>isCont f x; isCont g x\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. (f x, g x)) x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   258
  unfolding isCont_def by (rule LIM_Pair)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   259
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   260
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   261
subsection {* Product is a complete vector space *}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   262
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   263
instance "*" :: (banach, banach) banach
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   264
proof
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   265
  fix X :: "nat \<Rightarrow> 'a \<times> 'b" assume "Cauchy X"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   266
  have 1: "(\<lambda>n. fst (X n)) ----> lim (\<lambda>n. fst (X n))"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   267
    using fst.Cauchy [OF `Cauchy X`]
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   268
    by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   269
  have 2: "(\<lambda>n. snd (X n)) ----> lim (\<lambda>n. snd (X n))"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   270
    using snd.Cauchy [OF `Cauchy X`]
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   271
    by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   272
  have "X ----> (lim (\<lambda>n. fst (X n)), lim (\<lambda>n. snd (X n)))"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   273
    using LIMSEQ_Pair [OF 1 2] by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   274
  then show "convergent X"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   275
    by (rule convergentI)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   276
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   277
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   278
subsection {* Frechet derivatives involving pairs *}
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   279
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   280
lemma FDERIV_Pair:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   281
  assumes f: "FDERIV f x :> f'" and g: "FDERIV g x :> g'"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   282
  shows "FDERIV (\<lambda>x. (f x, g x)) x :> (\<lambda>h. (f' h, g' h))"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   283
apply (rule FDERIV_I)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   284
apply (rule bounded_linear_Pair)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   285
apply (rule FDERIV_bounded_linear [OF f])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   286
apply (rule FDERIV_bounded_linear [OF g])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   287
apply (simp add: norm_Pair)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   288
apply (rule real_LIM_sandwich_zero)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   289
apply (rule LIM_add_zero)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   290
apply (rule FDERIV_D [OF f])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   291
apply (rule FDERIV_D [OF g])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   292
apply (rename_tac h)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   293
apply (simp add: divide_nonneg_pos)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   294
apply (rename_tac h)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   295
apply (subst add_divide_distrib [symmetric])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   296
apply (rule divide_right_mono [OF _ norm_ge_zero])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   297
apply (rule order_trans [OF sqrt_add_le_add_sqrt])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   298
apply simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   299
apply simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   300
apply simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   301
done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   302
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   303
end