src/HOL/Analysis/Product_Vector.thy
author paulson <lp15@cam.ac.uk>
Thu, 09 Feb 2023 15:36:06 +0000
changeset 77228 8c093a4b8ccf
parent 74475 409ca22dee4c
permissions -rw-r--r--
Even more new material from Eberl and Li
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63971
da89140186e2 HOL-Analysis: move Product_Vector and Inner_Product from Library
hoelzl
parents: 63040
diff changeset
     1
(*  Title:      HOL/Analysis/Product_Vector.thy
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
     3
                Dominique Unruh, University of Tartu
30019
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
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
     6
section \<open>Cartesian Products as Vector Spaces\<close>
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     7
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
     8
theory Product_Vector
69511
4cc5e4a528f8 moved dependency
immler
parents: 69260
diff changeset
     9
  imports
4cc5e4a528f8 moved dependency
immler
parents: 69260
diff changeset
    10
    Complex_Main
4cc5e4a528f8 moved dependency
immler
parents: 69260
diff changeset
    11
    "HOL-Library.Product_Plus"
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    12
begin
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    13
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    14
lemma Times_eq_image_sum:
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    15
  fixes S :: "'a :: comm_monoid_add set" and T :: "'b :: comm_monoid_add set"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    16
  shows "S \<times> T = {u + v |u v. u \<in> (\<lambda>x. (x, 0)) ` S \<and> v \<in> Pair 0 ` T}"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    17
  by force
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    18
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    19
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
    20
subsection \<open>Product is a Module\<close>
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    21
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    22
locale module_prod = module_pair begin
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    23
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    24
definition scale :: "'a \<Rightarrow> 'b \<times> 'c \<Rightarrow> 'b \<times> 'c"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    25
  where "scale a v = (s1 a (fst v), s2 a (snd v))"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    26
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
    27
lemma\<^marker>\<open>tag important\<close> scale_prod: "scale x (a, b) = (s1 x a, s2 x b)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    28
  by (auto simp: scale_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    29
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
    30
sublocale\<^marker>\<open>tag important\<close> p: module scale
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    31
proof qed (simp_all add: scale_def
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    32
  m1.scale_left_distrib m1.scale_right_distrib m2.scale_left_distrib m2.scale_right_distrib)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    33
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    34
lemma subspace_Times: "m1.subspace A \<Longrightarrow> m2.subspace B \<Longrightarrow> p.subspace (A \<times> B)"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    35
  unfolding m1.subspace_def m2.subspace_def p.subspace_def
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    36
  by (auto simp: zero_prod_def scale_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    37
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    38
lemma module_hom_fst: "module_hom scale s1 fst"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    39
  by unfold_locales (auto simp: scale_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    40
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    41
lemma module_hom_snd: "module_hom scale s2 snd"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    42
  by unfold_locales (auto simp: scale_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    43
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    44
end
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    45
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    46
locale vector_space_prod = vector_space_pair begin
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    47
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    48
sublocale module_prod s1 s2
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    49
  rewrites "module_hom = Vector_Spaces.linear"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    50
  by unfold_locales (fact module_hom_eq_linear)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    51
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    52
sublocale p: vector_space scale by unfold_locales (auto simp: algebra_simps)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    53
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    54
lemmas linear_fst = module_hom_fst
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    55
  and linear_snd = module_hom_snd
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    56
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    57
end
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    58
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    59
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
    60
subsection \<open>Product is a Real Vector Space\<close>
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    61
68617
75129a73aca3 more economic tagging
nipkow
parents: 68611
diff changeset
    62
instantiation prod :: (real_vector, real_vector) real_vector
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    63
begin
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    64
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    65
definition scaleR_prod_def:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    66
  "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
    67
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    68
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
    69
  unfolding scaleR_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    70
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    71
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
    72
  unfolding scaleR_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    73
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
    74
proposition scaleR_Pair [simp]: "scaleR r (a, b) = (scaleR r a, scaleR r b)"
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    75
  unfolding scaleR_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    76
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60615
diff changeset
    77
instance
ade12ef2773c tuned proofs;
wenzelm
parents: 60615
diff changeset
    78
proof
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    79
  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
    80
  show "scaleR a (x + y) = scaleR a x + scaleR a y"
44066
d74182c93f04 rename Pair_fst_snd_eq to prod_eq_iff (keeping old name too)
huffman
parents: 37678
diff changeset
    81
    by (simp add: prod_eq_iff scaleR_right_distrib)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    82
  show "scaleR (a + b) x = scaleR a x + scaleR b x"
44066
d74182c93f04 rename Pair_fst_snd_eq to prod_eq_iff (keeping old name too)
huffman
parents: 37678
diff changeset
    83
    by (simp add: prod_eq_iff scaleR_left_distrib)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    84
  show "scaleR a (scaleR b x) = scaleR (a * b) x"
44066
d74182c93f04 rename Pair_fst_snd_eq to prod_eq_iff (keeping old name too)
huffman
parents: 37678
diff changeset
    85
    by (simp add: prod_eq_iff)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    86
  show "scaleR 1 x = x"
44066
d74182c93f04 rename Pair_fst_snd_eq to prod_eq_iff (keeping old name too)
huffman
parents: 37678
diff changeset
    87
    by (simp add: prod_eq_iff)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    88
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    89
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    90
end
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
    91
69064
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
    92
lemma module_prod_scale_eq_scaleR: "module_prod.scale (*\<^sub>R) (*\<^sub>R) = scaleR"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    93
  apply (rule ext) apply (rule ext)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    94
  apply (subst module_prod.scale_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    95
  subgoal by unfold_locales
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    96
  by (simp add: scaleR_prod_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    97
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
    98
interpretation real_vector?: vector_space_prod "scaleR::_\<Rightarrow>_\<Rightarrow>'a::real_vector" "scaleR::_\<Rightarrow>_\<Rightarrow>'b::real_vector"
69064
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
    99
  rewrites "scale = ((*\<^sub>R)::_\<Rightarrow>_\<Rightarrow>('a \<times> 'b))"
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   100
    and "module.dependent (*\<^sub>R) = dependent"
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   101
    and "module.representation (*\<^sub>R) = representation"
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   102
    and "module.subspace (*\<^sub>R) = subspace"
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   103
    and "module.span (*\<^sub>R) = span"
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   104
    and "vector_space.extend_basis (*\<^sub>R) = extend_basis"
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   105
    and "vector_space.dim (*\<^sub>R) = dim"
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   106
    and "Vector_Spaces.linear (*\<^sub>R) (*\<^sub>R) = linear"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   107
  subgoal by unfold_locales
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   108
  subgoal by (fact module_prod_scale_eq_scaleR)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   109
  unfolding dependent_raw_def representation_raw_def subspace_raw_def span_raw_def
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   110
    extend_basis_raw_def dim_raw_def linear_def
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   111
  by (rule refl)+
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   112
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   113
subsection \<open>Product is a Metric Space\<close>
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   114
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   115
(* TODO: Product of uniform spaces and compatibility with metric_spaces! *)
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   116
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
   117
instantiation\<^marker>\<open>tag unimportant\<close> prod :: (metric_space, metric_space) dist
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   118
begin
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   119
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   120
definition dist_prod_def[code del]:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51644
diff changeset
   121
  "dist x y = sqrt ((dist (fst x) (fst y))\<^sup>2 + (dist (snd x) (snd y))\<^sup>2)"
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   122
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   123
instance ..
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   124
end
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   125
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   126
instantiation\<^marker>\<open>tag unimportant\<close> prod :: (uniformity, uniformity) uniformity begin
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   127
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   128
definition [code del]: \<open>(uniformity :: (('a \<times> 'b) \<times> ('a \<times> 'b)) filter) = 
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   129
        filtermap (\<lambda>((x1,x2),(y1,y2)). ((x1,y1),(x2,y2))) (uniformity \<times>\<^sub>F uniformity)\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   130
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   131
instance..
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   132
end
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   133
77228
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   134
subsubsection \<open>Uniform spaces\<close>
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   135
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   136
instantiation\<^marker>\<open>tag unimportant\<close> prod :: (uniform_space, uniform_space) uniform_space 
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   137
begin
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   138
instance 
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   139
proof standard
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   140
  fix U :: \<open>('a \<times> 'b) set\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   141
  show \<open>open U \<longleftrightarrow> (\<forall>x\<in>U. \<forall>\<^sub>F (x', y) in uniformity. x' = x \<longrightarrow> y \<in> U)\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   142
  proof (intro iffI ballI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   143
    fix x assume \<open>open U\<close> and \<open>x \<in> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   144
    then obtain A B where \<open>open A\<close> \<open>open B\<close> \<open>x \<in> A\<times>B\<close> \<open>A\<times>B \<subseteq> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   145
      by (metis open_prod_elim)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   146
    define UA where \<open>UA = (\<lambda>(x'::'a,y). x' = fst x \<longrightarrow> y \<in> A)\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   147
    from \<open>open A\<close> \<open>x \<in> A\<times>B\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   148
    have \<open>eventually UA uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   149
      unfolding open_uniformity UA_def by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   150
    define UB where \<open>UB = (\<lambda>(x'::'b,y). x' = snd x \<longrightarrow> y \<in> B)\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   151
    from \<open>open A\<close> \<open>open B\<close> \<open>x \<in> A\<times>B\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   152
    have \<open>eventually UA uniformity\<close> \<open>eventually UB uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   153
      unfolding open_uniformity UA_def UB_def by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   154
    then have \<open>\<forall>\<^sub>F ((x'1, y1), (x'2, y2)) in uniformity \<times>\<^sub>F uniformity. (x'1,x'2) = x \<longrightarrow> (y1,y2) \<in> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   155
      apply (auto intro!: exI[of _ UA] exI[of _ UB] simp add: eventually_prod_filter)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   156
      using \<open>A\<times>B \<subseteq> U\<close> by (auto simp: UA_def UB_def)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   157
    then show \<open>\<forall>\<^sub>F (x', y) in uniformity. x' = x \<longrightarrow> y \<in> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   158
      by (simp add: uniformity_prod_def eventually_filtermap case_prod_unfold)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   159
  next
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   160
    assume asm: \<open>\<forall>x\<in>U. \<forall>\<^sub>F (x', y) in uniformity. x' = x \<longrightarrow> y \<in> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   161
    show \<open>open U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   162
    proof (unfold open_prod_def, intro ballI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   163
      fix x assume \<open>x \<in> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   164
      with asm have \<open>\<forall>\<^sub>F (x', y) in uniformity. x' = x \<longrightarrow> y \<in> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   165
        by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   166
      then have \<open>\<forall>\<^sub>F ((x'1, y1), (x'2, y2)) in uniformity \<times>\<^sub>F uniformity. (x'1,x'2) = x \<longrightarrow> (y1,y2) \<in> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   167
        by (simp add: uniformity_prod_def eventually_filtermap case_prod_unfold)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   168
      then obtain UA UB where \<open>eventually UA uniformity\<close> and \<open>eventually UB uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   169
               and UA_UB_U: \<open>UA (a1, a2) \<Longrightarrow> UB (b1, b2) \<Longrightarrow> (a1, b1) = x \<Longrightarrow> (a2, b2) \<in> U\<close> for a1 a2 b1 b2
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   170
        apply atomize_elim by (simp add: case_prod_beta eventually_prod_filter)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   171
      have \<open>eventually (\<lambda>a. UA (fst x, a)) (nhds (fst x))\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   172
        using \<open>eventually UA uniformity\<close> eventually_mono eventually_nhds_uniformity by fastforce
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   173
      then obtain A where \<open>open A\<close> and A_UA: \<open>A \<subseteq> {a. UA (fst x, a)}\<close> and \<open>fst x \<in> A\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   174
        by (metis (mono_tags, lifting) eventually_nhds mem_Collect_eq subsetI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   175
      have \<open>eventually (\<lambda>b. UB (snd x, b)) (nhds (snd x))\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   176
        using \<open>eventually UB uniformity\<close> eventually_mono eventually_nhds_uniformity by fastforce
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   177
      then obtain B where \<open>open B\<close> and B_UB: \<open>B \<subseteq> {b. UB (snd x, b)}\<close> and \<open>snd x \<in> B\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   178
        by (metis (mono_tags, lifting) eventually_nhds mem_Collect_eq subsetI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   179
      have \<open>x \<in> A \<times> B\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   180
        by (simp add: \<open>fst x \<in> A\<close> \<open>snd x \<in> B\<close> mem_Times_iff)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   181
      have \<open>A \<times> B \<subseteq> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   182
        using A_UA B_UB UA_UB_U by fastforce
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   183
      show \<open>\<exists>A B. open A \<and> open B \<and> x \<in> A \<times> B \<and> A \<times> B \<subseteq> U\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   184
        using \<open>A \<times> B \<subseteq> U\<close> \<open>open A\<close> \<open>open B\<close> \<open>x \<in> A \<times> B\<close> by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   185
    qed
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   186
  qed
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   187
next
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   188
  show \<open>eventually E uniformity \<Longrightarrow> E (x, x)\<close> for E and x :: \<open>'a \<times> 'b\<close> 
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   189
    apply (simp add: uniformity_prod_def eventually_filtermap case_prod_unfold eventually_prod_filter)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   190
    by (metis surj_pair uniformity_refl)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   191
next
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   192
  show \<open>eventually E uniformity \<Longrightarrow> \<forall>\<^sub>F (x::'a\<times>'b, y) in uniformity. E (y, x)\<close> for E
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   193
    apply (simp only: uniformity_prod_def eventually_filtermap case_prod_unfold eventually_prod_filter)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   194
    apply (erule exE, erule exE, rename_tac Pf Pg)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   195
    apply (rule_tac x=\<open>\<lambda>(x,y). Pf (y,x)\<close> in exI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   196
    apply (rule_tac x=\<open>\<lambda>(x,y). Pg (y,x)\<close> in exI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   197
    by (auto simp add: uniformity_sym)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   198
next
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   199
  show \<open>\<exists>D. eventually D uniformity \<and> (\<forall>x y z. D (x::'a\<times>'b, y) \<longrightarrow> D (y, z) \<longrightarrow> E (x, z))\<close> 
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   200
    if \<open>eventually E uniformity\<close> for E
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   201
  proof -
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   202
    from that
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   203
    obtain EA EB where \<open>eventually EA uniformity\<close> and \<open>eventually EB uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   204
               and EA_EB_E: \<open>EA (a1, a2) \<Longrightarrow> EB (b1, b2) \<Longrightarrow> E ((a1, b1), (a2, b2))\<close> for a1 a2 b1 b2
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   205
      by (auto simp add: uniformity_prod_def eventually_filtermap case_prod_unfold eventually_prod_filter)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   206
    obtain DA where \<open>eventually DA uniformity\<close> and DA_EA: \<open>DA (x,y) \<Longrightarrow> DA (y,z) \<Longrightarrow> EA (x,z)\<close> for x y z
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   207
      using \<open>eventually EA uniformity\<close> uniformity_transE by blast
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   208
    obtain DB where \<open>eventually DB uniformity\<close> and DB_EB: \<open>DB (x,y) \<Longrightarrow> DB (y,z) \<Longrightarrow> EB (x,z)\<close> for x y z
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   209
      using \<open>eventually EB uniformity\<close> uniformity_transE by blast
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   210
    define D where \<open>D = (\<lambda>((a1,b1),(a2,b2)). DA (a1,a2) \<and> DB (b1,b2))\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   211
    have \<open>eventually D uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   212
      using \<open>eventually DA uniformity\<close> \<open>eventually DB uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   213
      by (auto simp add: uniformity_prod_def eventually_filtermap case_prod_unfold eventually_prod_filter D_def)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   214
    moreover have \<open>D ((a1, b1), (a2, b2)) \<Longrightarrow> D ((a2, b2), (a3, b3)) \<Longrightarrow> E ((a1, b1), (a3, b3))\<close> for a1 b1 a2 b2 a3 b3
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   215
      using DA_EA DB_EB D_def EA_EB_E by blast
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   216
    ultimately show ?thesis
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   217
      by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   218
  qed
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   219
qed
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   220
end
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   221
77228
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   222
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   223
lemma (in uniform_space) nhds_eq_comap_uniformity: "nhds x = filtercomap (\<lambda>y. (x, y)) uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   224
proof -
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   225
  have *: "eventually P (filtercomap (\<lambda>y. (x, y)) F) \<longleftrightarrow>
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   226
           eventually (\<lambda>z. fst z = x \<longrightarrow> P (snd z)) F" for P :: "'a \<Rightarrow> bool" and F
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   227
    unfolding eventually_filtercomap  
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   228
    by (smt (verit) eventually_elim2 fst_conv prod.collapse snd_conv)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   229
  thus ?thesis
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   230
    unfolding filter_eq_iff
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   231
    by (subst *) (auto simp: eventually_nhds_uniformity case_prod_unfold)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   232
qed
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   233
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   234
lemma uniformity_of_uniform_continuous_invariant:
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   235
  fixes f :: "'a :: uniform_space \<Rightarrow> 'a \<Rightarrow> 'a"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   236
  assumes "filterlim (\<lambda>((a,b),(c,d)). (f a c, f b d)) uniformity (uniformity \<times>\<^sub>F uniformity)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   237
  assumes "eventually P uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   238
  obtains Q where "eventually Q uniformity" "\<And>a b c. Q (a, b) \<Longrightarrow> P (f a c, f b c)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   239
  using eventually_compose_filterlim[OF assms(2,1)] uniformity_refl
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   240
    by (fastforce simp: case_prod_unfold eventually_filtercomap eventually_prod_same)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   241
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   242
class uniform_topological_monoid_add = topological_monoid_add + uniform_space +
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   243
  assumes uniformly_continuous_add':
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   244
    "filterlim (\<lambda>((a,b), (c,d)). (a + c, b + d)) uniformity (uniformity \<times>\<^sub>F uniformity)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   245
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   246
lemma uniformly_continuous_add:
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   247
  "uniformly_continuous_on UNIV (\<lambda>(x :: 'a :: uniform_topological_monoid_add,y). x + y)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   248
  using uniformly_continuous_add'[where ?'a = 'a]
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   249
  by (simp add: uniformly_continuous_on_uniformity case_prod_unfold uniformity_prod_def filterlim_filtermap)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   250
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   251
lemma filterlim_fst: "filterlim fst F (F \<times>\<^sub>F G)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   252
  by (simp add: filterlim_def filtermap_fst_prod_filter)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   253
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   254
lemma filterlim_snd: "filterlim snd G (F \<times>\<^sub>F G)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   255
  by (simp add: filterlim_def filtermap_snd_prod_filter)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   256
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   257
class uniform_topological_group_add = topological_group_add + uniform_topological_monoid_add +
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   258
  assumes uniformly_continuous_uminus': "filterlim (\<lambda>(a, b). (-a, -b)) uniformity uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   259
begin
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   260
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   261
lemma uniformly_continuous_minus':
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   262
  "filterlim (\<lambda>((a,b), (c,d)). (a - c, b - d)) uniformity (uniformity \<times>\<^sub>F uniformity)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   263
proof -
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   264
  have "filterlim ((\<lambda>((a,b), (c,d)). (a + c, b + d)) \<circ> (\<lambda>((a,b), (c,d)). ((a, b), (-c, -d))))
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   265
          uniformity (uniformity \<times>\<^sub>F uniformity)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   266
    unfolding o_def using uniformly_continuous_uminus'
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   267
    by (intro filterlim_compose[OF uniformly_continuous_add'])
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   268
       (auto simp: case_prod_unfold intro!: filterlim_Pair
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   269
          filterlim_fst filterlim_compose[OF _ filterlim_snd])
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   270
  thus ?thesis
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   271
    by (simp add: o_def case_prod_unfold)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   272
qed
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   273
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   274
end
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   275
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   276
lemma uniformly_continuous_uminus:
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   277
  "uniformly_continuous_on UNIV (\<lambda>x :: 'a :: uniform_topological_group_add. -x)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   278
  using uniformly_continuous_uminus'[where ?'a = 'a]
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   279
  by (simp add: uniformly_continuous_on_uniformity)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   280
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   281
lemma uniformly_continuous_minus:
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   282
  "uniformly_continuous_on UNIV (\<lambda>(x :: 'a :: uniform_topological_group_add,y). x - y)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   283
  using uniformly_continuous_minus'[where ?'a = 'a]
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   284
  by (simp add: uniformly_continuous_on_uniformity case_prod_unfold uniformity_prod_def filterlim_filtermap)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   285
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   286
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   287
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   288
lemma real_normed_vector_is_uniform_topological_group_add [Pure.intro]:
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   289
  "OFCLASS('a :: real_normed_vector, uniform_topological_group_add_class)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   290
proof
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   291
  show "filterlim (\<lambda>((a::'a,b), (c,d)). (a + c, b + d)) uniformity (uniformity \<times>\<^sub>F uniformity)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   292
    unfolding filterlim_def le_filter_def eventually_filtermap case_prod_unfold
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   293
  proof safe
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   294
    fix P :: "'a \<times> 'a \<Rightarrow> bool"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   295
    assume "eventually P uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   296
    then obtain \<epsilon> where \<epsilon>: "\<epsilon> > 0" "\<And>x y. dist x y < \<epsilon> \<Longrightarrow> P (x, y)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   297
      by (auto simp: eventually_uniformity_metric)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   298
    define Q where "Q = (\<lambda>(x::'a,y). dist x y < \<epsilon> / 2)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   299
    have Q: "eventually Q uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   300
      unfolding eventually_uniformity_metric Q_def using \<open>\<epsilon> > 0\<close>
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   301
      by (meson case_prodI divide_pos_pos zero_less_numeral)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   302
    have "P (a + c, b + d)" if "Q (a, b)" "Q (c, d)" for a b c d
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   303
    proof -
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   304
      have "dist (a + c) (b + d) \<le> dist a b + dist c d"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   305
        by (simp add: dist_norm norm_diff_triangle_ineq)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   306
      also have "\<dots> < \<epsilon>"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   307
        using that by (auto simp: Q_def)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   308
      finally show ?thesis
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   309
        by (intro \<epsilon>)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   310
    qed
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   311
    thus "\<forall>\<^sub>F x in uniformity \<times>\<^sub>F uniformity. P (fst (fst x) + fst (snd x), snd (fst x) + snd (snd x))"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   312
      unfolding eventually_prod_filter by (intro exI[of _ Q] conjI Q) auto
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   313
  qed
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   314
next
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   315
  show "filterlim (\<lambda>((a::'a), b). (-a, -b)) uniformity uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   316
    unfolding filterlim_def le_filter_def eventually_filtermap
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   317
  proof safe
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   318
    fix P :: "'a \<times> 'a \<Rightarrow> bool"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   319
    assume "eventually P uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   320
    then obtain \<epsilon> where \<epsilon>: "\<epsilon> > 0" "\<And>x y. dist x y < \<epsilon> \<Longrightarrow> P (x, y)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   321
      by (auto simp: eventually_uniformity_metric)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   322
    show "\<forall>\<^sub>F x in uniformity. P (case x of (a, b) \<Rightarrow> (- a, - b))"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   323
      unfolding eventually_uniformity_metric
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   324
      by (intro exI[of _ \<epsilon>]) (auto intro!: \<epsilon> simp: dist_norm norm_minus_commute)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   325
  qed
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   326
qed
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   327
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   328
instance real :: uniform_topological_group_add ..
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   329
instance complex :: uniform_topological_group_add ..
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   330
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   331
lemma cauchy_seq_finset_iff_vanishing:
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   332
  "uniformity = filtercomap (\<lambda>(x,y). y - x :: 'a :: uniform_topological_group_add) (nhds 0)"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   333
proof -
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   334
  have "filtercomap (\<lambda>x. (0, case x of (x, y) \<Rightarrow> y - (x :: 'a))) uniformity \<le> uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   335
    apply (simp add: le_filter_def eventually_filtercomap)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   336
    using uniformity_of_uniform_continuous_invariant[OF uniformly_continuous_add']
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   337
    by (metis diff_self eq_diff_eq)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   338
  moreover
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   339
  have "uniformity \<le> filtercomap (\<lambda>x. (0, case x of (x, y) \<Rightarrow> y - (x :: 'a))) uniformity"
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   340
    apply (simp add: le_filter_def eventually_filtercomap)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   341
    using uniformity_of_uniform_continuous_invariant[OF uniformly_continuous_minus']
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   342
    by (metis (mono_tags) diff_self eventually_mono surjective_pairing)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   343
  ultimately show ?thesis
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   344
    by (simp add: nhds_eq_comap_uniformity filtercomap_filtercomap)
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   345
qed
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   346
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   347
subsubsection \<open>Metric spaces\<close>
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   348
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   349
instantiation\<^marker>\<open>tag unimportant\<close> prod :: (metric_space, metric_space) uniformity_dist begin
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   350
instance
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   351
proof
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   352
  show \<open>uniformity = (INF e\<in>{0 <..}. principal {(x::'a\<times>'b, y). dist x y < e})\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   353
  proof (subst filter_eq_iff, intro allI iffI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   354
    fix P :: \<open>('a \<times> 'b) \<times> ('a \<times> 'b) \<Rightarrow> bool\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   355
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   356
    have 1: \<open>\<exists>e\<in>{0<..}.
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   357
              {(x,y). dist x y < e} \<subseteq> {(x,y). dist x y < a} \<and>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   358
              {(x,y). dist x y < e} \<subseteq> {(x,y). dist x y < b}\<close> if \<open>a>0\<close> \<open>b>0\<close> for a b
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   359
      apply (rule bexI[of _ \<open>min a b\<close>])
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   360
      using that by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   361
    have 2: \<open>mono (\<lambda>P. eventually (\<lambda>x. P (Q x)) F)\<close> for F :: \<open>'z filter\<close> and Q :: \<open>'z \<Rightarrow> 'y\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   362
      unfolding mono_def using eventually_mono le_funD by fastforce
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   363
    have \<open>\<forall>\<^sub>F ((x1::'a,y1),(x2::'b,y2)) in uniformity \<times>\<^sub>F uniformity. dist x1 y1 < e/2 \<and> dist x2 y2 < e/2\<close> if \<open>e>0\<close> for e
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   364
      by (auto intro!: eventually_prodI exI[of _ \<open>e/2\<close>] simp: case_prod_unfold eventually_uniformity_metric that)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   365
    then have 3: \<open>\<forall>\<^sub>F ((x1::'a,y1),(x2::'b,y2)) in uniformity \<times>\<^sub>F uniformity. dist (x1,x2) (y1,y2) < e\<close> if \<open>e>0\<close> for e
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   366
      apply (rule eventually_rev_mp)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   367
      by (auto intro!: that eventuallyI simp: case_prod_unfold dist_prod_def sqrt_sum_squares_half_less)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   368
    show \<open>eventually P (INF e\<in>{0<..}. principal {(x, y). dist x y < e}) \<Longrightarrow> eventually P uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   369
      apply (subst (asm) eventually_INF_base)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   370
      using 1 3 apply (auto simp: uniformity_prod_def case_prod_unfold eventually_filtermap 2 eventually_principal)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   371
      by (smt (verit, best) eventually_mono)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   372
  next
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   373
    fix P :: \<open>('a \<times> 'b) \<times> ('a \<times> 'b) \<Rightarrow> bool\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   374
    assume \<open>eventually P uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   375
    then obtain P1 P2 where \<open>eventually P1 uniformity\<close> \<open>eventually P2 uniformity\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   376
      and P1P2P: \<open>P1 (x1, y1) \<Longrightarrow> P2 (x2, y2) \<Longrightarrow> P ((x1, x2), (y1, y2))\<close> for x1 y1 x2 y2
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   377
      by (auto simp: eventually_filtermap case_prod_beta eventually_prod_filter uniformity_prod_def)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   378
    from \<open>eventually P1 uniformity\<close> obtain e1 where \<open>e1>0\<close> and e1P1: \<open>dist x y < e1 \<Longrightarrow> P1 (x,y)\<close> for x y
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   379
      using eventually_uniformity_metric by blast
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   380
    from \<open>eventually P2 uniformity\<close> obtain e2 where \<open>e2>0\<close> and e2P2: \<open>dist x y < e2 \<Longrightarrow> P2 (x,y)\<close> for x y
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   381
      using eventually_uniformity_metric by blast
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   382
    define e where \<open>e = min e1 e2\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   383
    have \<open>e > 0\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   384
      using \<open>0 < e1\<close> \<open>0 < e2\<close> e_def by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   385
    have \<open>dist (x1,x2) (y1,y2) < e \<Longrightarrow> dist x1 y1 < e1\<close> for x1 y1 :: 'a and x2 y2 :: 'b
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   386
      unfolding dist_prod_def e_def apply auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   387
      by (smt (verit, best) real_sqrt_sum_squares_ge1)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   388
    moreover have \<open>dist (x1,x2) (y1,y2) < e \<Longrightarrow> dist x2 y2 < e2\<close> for x1 y1 :: 'a and x2 y2 :: 'b
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   389
      unfolding dist_prod_def e_def apply auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   390
      by (smt (verit, best) real_sqrt_sum_squares_ge1)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   391
    ultimately have *: \<open>dist (x1,x2) (y1,y2) < e \<Longrightarrow> P ((x1, x2), (y1, y2))\<close> for x1 y1 x2 y2
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   392
      using e1P1 e2P2 P1P2P by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   393
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   394
    show \<open>eventually P (INF e\<in>{0<..}. principal {(x, y). dist x y < e})\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   395
       apply (rule eventually_INF1[where i=e])
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   396
      using \<open>e > 0\<close> * by (auto simp: eventually_principal)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   397
  qed
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   398
qed
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   399
end
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   400
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   401
declare uniformity_Abort[where 'a="'a :: metric_space \<times> 'b :: metric_space", code]
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   402
68617
75129a73aca3 more economic tagging
nipkow
parents: 68611
diff changeset
   403
instantiation prod :: (metric_space, metric_space) metric_space
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   404
begin
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   405
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   406
proposition dist_Pair_Pair: "dist (a, b) (c, d) = sqrt ((dist a c)\<^sup>2 + (dist b d)\<^sup>2)"
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   407
  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
   408
36332
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   409
lemma dist_fst_le: "dist (fst x) (fst y) \<le> dist x y"
53930
896b642f2aab tuned proofs
huffman
parents: 53015
diff changeset
   410
  unfolding dist_prod_def by (rule real_sqrt_sum_squares_ge1)
36332
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   411
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   412
lemma dist_snd_le: "dist (snd x) (snd y) \<le> dist x y"
53930
896b642f2aab tuned proofs
huffman
parents: 53015
diff changeset
   413
  unfolding dist_prod_def by (rule real_sqrt_sum_squares_ge2)
36332
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   414
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60615
diff changeset
   415
instance
ade12ef2773c tuned proofs;
wenzelm
parents: 60615
diff changeset
   416
proof
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   417
  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
   418
  show "dist x y = 0 \<longleftrightarrow> x = y"
44066
d74182c93f04 rename Pair_fst_snd_eq to prod_eq_iff (keeping old name too)
huffman
parents: 37678
diff changeset
   419
    unfolding dist_prod_def prod_eq_iff by simp
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   420
next
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   421
  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
   422
  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
   423
    unfolding dist_prod_def
31563
ded2364d14d4 cleaned up some proofs
huffman
parents: 31562
diff changeset
   424
    by (intro order_trans [OF _ real_sqrt_sum_squares_triangle_ineq]
ded2364d14d4 cleaned up some proofs
huffman
parents: 31562
diff changeset
   425
        real_sqrt_le_mono add_mono power_mono dist_triangle2 zero_le_dist)
31415
80686a815b59 instance * :: topological_space
huffman
parents: 31405
diff changeset
   426
next
31492
5400beeddb55 replace 'topo' with 'open'; add extra type constraint for 'open'
huffman
parents: 31491
diff changeset
   427
  fix S :: "('a \<times> 'b) set"
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61973
diff changeset
   428
  have *: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)"
31563
ded2364d14d4 cleaned up some proofs
huffman
parents: 31562
diff changeset
   429
  proof
36332
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   430
    assume "open S" show "\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S"
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   431
    proof
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   432
      fix x assume "x \<in> S"
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   433
      obtain A B where "open A" "open B" "x \<in> A \<times> B" "A \<times> B \<subseteq> S"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   434
        using \<open>open S\<close> and \<open>x \<in> S\<close> by (rule open_prod_elim)
36332
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   435
      obtain r where r: "0 < r" "\<forall>y. dist y (fst x) < r \<longrightarrow> y \<in> A"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   436
        using \<open>open A\<close> and \<open>x \<in> A \<times> B\<close> unfolding open_dist by auto
36332
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   437
      obtain s where s: "0 < s" "\<forall>y. dist y (snd x) < s \<longrightarrow> y \<in> B"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   438
        using \<open>open B\<close> and \<open>x \<in> A \<times> B\<close> unfolding open_dist by auto
36332
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   439
      let ?e = "min r s"
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   440
      have "0 < ?e \<and> (\<forall>y. dist y x < ?e \<longrightarrow> y \<in> S)"
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   441
      proof (intro allI impI conjI)
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   442
        show "0 < min r s" by (simp add: r(1) s(1))
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   443
      next
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   444
        fix y assume "dist y x < min r s"
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   445
        hence "dist y x < r" and "dist y x < s"
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   446
          by simp_all
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   447
        hence "dist (fst y) (fst x) < r" and "dist (snd y) (snd x) < s"
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   448
          by (auto intro: le_less_trans dist_fst_le dist_snd_le)
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   449
        hence "fst y \<in> A" and "snd y \<in> B"
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   450
          by (simp_all add: r(2) s(2))
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   451
        hence "y \<in> A \<times> B" by (induct y, simp)
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   452
        with \<open>A \<times> B \<subseteq> S\<close> show "y \<in> S" ..
36332
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   453
      qed
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   454
      thus "\<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S" ..
3ddb2bc07784 convert proofs to Isar-style
huffman
parents: 34110
diff changeset
   455
    qed
31563
ded2364d14d4 cleaned up some proofs
huffman
parents: 31562
diff changeset
   456
  next
44575
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   457
    assume *: "\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S" show "open S"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   458
    proof (rule open_prod_intro)
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   459
      fix x assume "x \<in> S"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   460
      then obtain e where "0 < e" and S: "\<forall>y. dist y x < e \<longrightarrow> y \<in> S"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   461
        using * by fast
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62367
diff changeset
   462
      define r where "r = e / sqrt 2"
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62367
diff changeset
   463
      define s where "s = e / sqrt 2"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   464
      from \<open>0 < e\<close> have "0 < r" and "0 < s"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
   465
        unfolding r_def s_def by simp_all
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   466
      from \<open>0 < e\<close> have "e = sqrt (r\<^sup>2 + s\<^sup>2)"
44575
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   467
        unfolding r_def s_def by (simp add: power_divide)
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62367
diff changeset
   468
      define A where "A = {y. dist (fst x) y < r}"
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62367
diff changeset
   469
      define B where "B = {y. dist (snd x) y < s}"
44575
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   470
      have "open A" and "open B"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   471
        unfolding A_def B_def by (simp_all add: open_ball)
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   472
      moreover have "x \<in> A \<times> B"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   473
        unfolding A_def B_def mem_Times_iff
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   474
        using \<open>0 < r\<close> and \<open>0 < s\<close> by simp
44575
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   475
      moreover have "A \<times> B \<subseteq> S"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   476
      proof (clarify)
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   477
        fix a b assume "a \<in> A" and "b \<in> B"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   478
        hence "dist a (fst x) < r" and "dist b (snd x) < s"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   479
          unfolding A_def B_def by (simp_all add: dist_commute)
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   480
        hence "dist (a, b) x < e"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   481
          unfolding dist_prod_def \<open>e = sqrt (r\<^sup>2 + s\<^sup>2)\<close>
44575
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   482
          by (simp add: add_strict_mono power_strict_mono)
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   483
        thus "(a, b) \<in> S"
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   484
          by (simp add: S)
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   485
      qed
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   486
      ultimately show "\<exists>A B. open A \<and> open B \<and> x \<in> A \<times> B \<and> A \<times> B \<subseteq> S" by fast
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   487
    qed
31563
ded2364d14d4 cleaned up some proofs
huffman
parents: 31562
diff changeset
   488
  qed
31339
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   489
qed
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   490
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   491
end
b4660351e8e7 instance * :: (metric_space, metric_space) metric_space; generalize lemmas to class metric_space
huffman
parents: 31290
diff changeset
   492
54890
cb892d835803 fundamental treatment of undefined vs. universally partial replaces code_abort
haftmann
parents: 54779
diff changeset
   493
declare [[code abort: "dist::('a::metric_space*'b::metric_space)\<Rightarrow>('a*'b) \<Rightarrow> real"]]
54779
d9edb711ef31 pragmatic executability of instance prod::{open,dist,norm}
immler
parents: 53930
diff changeset
   494
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   495
lemma Cauchy_fst: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. fst (X n :: 'a::metric_space \<times> 'b::metric_space))"
53930
896b642f2aab tuned proofs
huffman
parents: 53015
diff changeset
   496
  unfolding Cauchy_def by (fast elim: le_less_trans [OF dist_fst_le])
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   497
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   498
lemma Cauchy_snd: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. snd (X n :: 'a::metric_space \<times> 'b::metric_space))"
53930
896b642f2aab tuned proofs
huffman
parents: 53015
diff changeset
   499
  unfolding Cauchy_def by (fast elim: le_less_trans [OF dist_snd_le])
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   500
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   501
lemma Cauchy_Pair:
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   502
  assumes "Cauchy X" and "Cauchy Y"
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   503
  shows "Cauchy (\<lambda>n. (X n :: 'a::metric_space, Y n :: 'a::metric_space))"
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   504
proof (rule metric_CauchyI)
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   505
  fix r :: real assume "0 < r"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56536
diff changeset
   506
  hence "0 < r / sqrt 2" (is "0 < ?s") by simp
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   507
  obtain M where M: "\<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < ?s"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   508
    using metric_CauchyD [OF \<open>Cauchy X\<close> \<open>0 < ?s\<close>] ..
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   509
  obtain N where N: "\<forall>m\<ge>N. \<forall>n\<ge>N. dist (Y m) (Y n) < ?s"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   510
    using metric_CauchyD [OF \<open>Cauchy Y\<close> \<open>0 < ?s\<close>] ..
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   511
  have "\<forall>m\<ge>max M N. \<forall>n\<ge>max M N. dist (X m, Y m) (X n, Y n) < r"
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   512
    using M N by (simp add: real_sqrt_sum_squares_less dist_Pair_Pair)
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   513
  then show "\<exists>n0. \<forall>m\<ge>n0. \<forall>n\<ge>n0. dist (X m, Y m) (X n, Y n) < r" ..
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   514
qed
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   515
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   516
text \<open>Analogue to @{thm [source] uniformly_continuous_on_def} for two-argument functions.\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   517
lemma uniformly_continuous_on_prod_metric:
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   518
  fixes f :: \<open>('a::metric_space \<times> 'b::metric_space) \<Rightarrow> 'c::metric_space\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   519
  shows \<open>uniformly_continuous_on (S\<times>T) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. \<forall>x\<in>S. \<forall>y\<in>S. \<forall>x'\<in>T. \<forall>y'\<in>T. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (f (x, x')) (f (y, y')) < e)\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   520
proof (unfold uniformly_continuous_on_def, intro iffI impI allI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   521
  fix e :: real 
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   522
  assume \<open>e > 0\<close> and \<open>\<forall>e>0. \<exists>d>0. \<forall>x\<in>S. \<forall>y\<in>S. \<forall>x'\<in>T. \<forall>y'\<in>T. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (f (x, x')) (f (y, y')) < e\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   523
  then obtain d where \<open>d > 0\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   524
    and d: \<open>\<forall>x\<in>S. \<forall>y\<in>S. \<forall>x'\<in>T. \<forall>y'\<in>T. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (f (x, x')) (f (y, y')) < e\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   525
    by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   526
  show \<open>\<exists>d>0. \<forall>x\<in>S\<times>T. \<forall>y\<in>S\<times>T. dist y x < d \<longrightarrow> dist (f y) (f x) < e\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   527
    apply (rule exI[of _ d])
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   528
    using \<open>d>0\<close> d[rule_format] apply auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   529
    by (smt (verit, del_insts) dist_fst_le dist_snd_le fst_conv snd_conv)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   530
next
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   531
  fix e :: real 
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   532
  assume \<open>e > 0\<close> and \<open>\<forall>e>0. \<exists>d>0. \<forall>x\<in>S\<times>T. \<forall>x'\<in>S\<times>T. dist x' x < d \<longrightarrow> dist (f x') (f x) < e\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   533
  then obtain d where \<open>d > 0\<close> and d: \<open>\<forall>x\<in>S\<times>T. \<forall>x'\<in>S\<times>T. dist x' x < d \<longrightarrow> dist (f x') (f x) < e\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   534
    by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   535
  show \<open>\<exists>d>0. \<forall>x\<in>S. \<forall>y\<in>S. \<forall>x'\<in>T. \<forall>y'\<in>T. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (f (x, x')) (f (y, y')) < e\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   536
  proof (intro exI conjI impI ballI)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   537
    from \<open>d > 0\<close> show \<open>d / 2 > 0\<close> by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   538
    fix x y x' y'
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   539
    assume [simp]: \<open>x \<in> S\<close> \<open>y \<in> S\<close> \<open>x' \<in> T\<close> \<open>y' \<in> T\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   540
    assume \<open>dist x y < d / 2\<close> and \<open>dist x' y' < d / 2\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   541
    then have \<open>dist (x, x') (y, y') < d\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   542
      by (simp add: dist_Pair_Pair sqrt_sum_squares_half_less)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   543
    with d show \<open>dist (f (x, x')) (f (y, y')) < e\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   544
      by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   545
  qed
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   546
qed
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   547
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   548
text \<open>Analogue to @{thm [source] isUCont_def} for two-argument functions.\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   549
lemma isUCont_prod_metric:
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   550
  fixes f :: \<open>('a::metric_space \<times> 'b::metric_space) \<Rightarrow> 'c::metric_space\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   551
  shows \<open>isUCont f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. \<forall>x. \<forall>y. \<forall>x'. \<forall>y'. dist x y < d \<longrightarrow> dist x' y' < d \<longrightarrow> dist (f (x, x')) (f (y, y')) < e)\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   552
  using uniformly_continuous_on_prod_metric[of UNIV UNIV]
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   553
  by auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   554
77228
8c093a4b8ccf Even more new material from Eberl and Li
paulson <lp15@cam.ac.uk>
parents: 74475
diff changeset
   555
text \<open>This logically belong with the real vector spaces but we only have the necessary lemmas now.\<close>
74475
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   556
lemma isUCont_plus[simp]:
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   557
  shows \<open>isUCont (\<lambda>(x::'a::real_normed_vector,y). x+y)\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   558
proof (rule isUCont_prod_metric[THEN iffD2], intro allI impI, simp)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   559
  fix e :: real assume \<open>0 < e\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   560
  show \<open>\<exists>d>0. \<forall>x y :: 'a. dist x y < d \<longrightarrow> (\<forall>x' y'. dist x' y' < d \<longrightarrow> dist (x + x') (y + y') < e)\<close>
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   561
    apply (rule exI[of _ \<open>e/2\<close>])
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   562
    using \<open>0 < e\<close> apply auto
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   563
    by (smt (verit, ccfv_SIG) dist_add_cancel dist_add_cancel2 dist_commute dist_triangle_lt)
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   564
qed
409ca22dee4c new notion of infinite sums in HOL-Analysis, ordering on complex numbers
eberlm <eberlm@in.tum.de>
parents: 71174
diff changeset
   565
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   566
subsection \<open>Product is a Complete Metric Space\<close>
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   567
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
   568
instance\<^marker>\<open>tag important\<close> prod :: (complete_space, complete_space) complete_space
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
   569
proof
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   570
  fix X :: "nat \<Rightarrow> 'a \<times> 'b" assume "Cauchy X"
61969
e01015e49041 more symbols;
wenzelm
parents: 61915
diff changeset
   571
  have 1: "(\<lambda>n. fst (X n)) \<longlonglongrightarrow> lim (\<lambda>n. fst (X n))"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   572
    using Cauchy_fst [OF \<open>Cauchy X\<close>]
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   573
    by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff)
61969
e01015e49041 more symbols;
wenzelm
parents: 61915
diff changeset
   574
  have 2: "(\<lambda>n. snd (X n)) \<longlonglongrightarrow> lim (\<lambda>n. snd (X n))"
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 59425
diff changeset
   575
    using Cauchy_snd [OF \<open>Cauchy X\<close>]
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   576
    by (simp add: Cauchy_convergent_iff convergent_LIMSEQ_iff)
61969
e01015e49041 more symbols;
wenzelm
parents: 61915
diff changeset
   577
  have "X \<longlonglongrightarrow> (lim (\<lambda>n. fst (X n)), lim (\<lambda>n. snd (X n)))"
36660
1cc4ab4b7ff7 make (X ----> L) an abbreviation for (X ---> L) sequentially
huffman
parents: 36332
diff changeset
   578
    using tendsto_Pair [OF 1 2] by simp
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   579
  then show "convergent X"
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   580
    by (rule convergentI)
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   581
qed
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   582
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   583
subsection \<open>Product is a Normed Vector Space\<close>
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   584
68617
75129a73aca3 more economic tagging
nipkow
parents: 68611
diff changeset
   585
instantiation prod :: (real_normed_vector, real_normed_vector) real_normed_vector
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   586
begin
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   587
54779
d9edb711ef31 pragmatic executability of instance prod::{open,dist,norm}
immler
parents: 53930
diff changeset
   588
definition norm_prod_def[code del]:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 51644
diff changeset
   589
  "norm x = sqrt ((norm (fst x))\<^sup>2 + (norm (snd x))\<^sup>2)"
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   590
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   591
definition sgn_prod_def:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   592
  "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
   593
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   594
proposition norm_Pair: "norm (a, b) = sqrt ((norm a)\<^sup>2 + (norm b)\<^sup>2)"
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   595
  unfolding norm_prod_def by simp
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   596
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60615
diff changeset
   597
instance
ade12ef2773c tuned proofs;
wenzelm
parents: 60615
diff changeset
   598
proof
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   599
  fix r :: real and x y :: "'a \<times> 'b"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   600
  show "norm x = 0 \<longleftrightarrow> x = 0"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   601
    unfolding norm_prod_def
44066
d74182c93f04 rename Pair_fst_snd_eq to prod_eq_iff (keeping old name too)
huffman
parents: 37678
diff changeset
   602
    by (simp add: prod_eq_iff)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   603
  show "norm (x + y) \<le> norm x + norm y"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   604
    unfolding norm_prod_def
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   605
    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
   606
    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
   607
    done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   608
  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
   609
    unfolding norm_prod_def
31587
a7e187205fc0 remove simp add: norm_scaleR
huffman
parents: 31568
diff changeset
   610
    apply (simp add: power_mult_distrib)
49962
a8cc904a6820 Renamed {left,right}_distrib to distrib_{right,left}.
webertj
parents: 44749
diff changeset
   611
    apply (simp add: distrib_left [symmetric])
68611
4bc4b5c0ccfc de-applying, etc.
paulson <lp15@cam.ac.uk>
parents: 68607
diff changeset
   612
    apply (simp add: real_sqrt_mult)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   613
    done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   614
  show "sgn x = scaleR (inverse (norm x)) x"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   615
    by (rule sgn_prod_def)
31290
f41c023d90bc define dist for products
huffman
parents: 30729
diff changeset
   616
  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
   617
    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
   618
    by (simp add: dist_norm)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   619
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   620
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   621
end
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   622
54890
cb892d835803 fundamental treatment of undefined vs. universally partial replaces code_abort
haftmann
parents: 54779
diff changeset
   623
declare [[code abort: "norm::('a::real_normed_vector*'b::real_normed_vector) \<Rightarrow> real"]]
54779
d9edb711ef31 pragmatic executability of instance prod::{open,dist,norm}
immler
parents: 53930
diff changeset
   624
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
   625
instance\<^marker>\<open>tag important\<close> prod :: (banach, banach) banach ..
31405
1f72869f1a2e instance * :: complete_space; generalize continuity lemmas for fst, snd, Pair
huffman
parents: 31388
diff changeset
   626
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
   627
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Pair operations are linear\<close>
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   628
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   629
lemma bounded_linear_fst: "bounded_linear fst"
44127
7b57b9295d98 lemma bounded_linear_intro
huffman
parents: 44126
diff changeset
   630
  using fst_add fst_scaleR
7b57b9295d98 lemma bounded_linear_intro
huffman
parents: 44126
diff changeset
   631
  by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   632
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   633
lemma bounded_linear_snd: "bounded_linear snd"
44127
7b57b9295d98 lemma bounded_linear_intro
huffman
parents: 44126
diff changeset
   634
  using snd_add snd_scaleR
7b57b9295d98 lemma bounded_linear_intro
huffman
parents: 44126
diff changeset
   635
  by (rule bounded_linear_intro [where K=1], simp add: norm_prod_def)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   636
61915
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 60679
diff changeset
   637
lemmas bounded_linear_fst_comp = bounded_linear_fst[THEN bounded_linear_compose]
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 60679
diff changeset
   638
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 60679
diff changeset
   639
lemmas bounded_linear_snd_comp = bounded_linear_snd[THEN bounded_linear_compose]
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 60679
diff changeset
   640
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   641
lemma bounded_linear_Pair:
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   642
  assumes f: "bounded_linear f"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   643
  assumes g: "bounded_linear g"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   644
  shows "bounded_linear (\<lambda>x. (f x, g x))"
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   645
proof
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   646
  interpret f: bounded_linear f by fact
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   647
  interpret g: bounded_linear g by fact
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   648
  fix x y and r :: real
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   649
  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
   650
    by (simp add: f.add g.add)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   651
  show "(f (r *\<^sub>R x), g (r *\<^sub>R x)) = r *\<^sub>R (f x, g x)"
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   652
    by (simp add: f.scale g.scale)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   653
  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
   654
    using f.pos_bounded by fast
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   655
  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
   656
    using g.pos_bounded by fast
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   657
  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
   658
    apply (rule allI)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   659
    apply (simp add: norm_Pair)
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   660
    apply (rule order_trans [OF sqrt_add_le_add_sqrt], simp, simp)
49962
a8cc904a6820 Renamed {left,right}_distrib to distrib_{right,left}.
webertj
parents: 44749
diff changeset
   661
    apply (simp add: distrib_left)
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   662
    apply (rule add_mono [OF norm_f norm_g])
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   663
    done
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   664
  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
   665
qed
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   666
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
   667
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Frechet derivatives involving pairs\<close>
30019
a2f19e0a28b2 add theory of products as real vector spaces to Library
huffman
parents:
diff changeset
   668
70137
824c047db30b tuned spacing;
wenzelm
parents: 70136
diff changeset
   669
text\<^marker>\<open>tag important\<close> \<open>%whitespace\<close>
68607
67bb59e49834 make theorem, corollary, and proposition %important for HOL-Analysis manual
immler
parents: 68072
diff changeset
   670
proposition has_derivative_Pair [derivative_intros]:
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   671
  assumes f: "(f has_derivative f') (at x within s)"
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   672
    and g: "(g has_derivative g') (at x within s)"
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 54890
diff changeset
   673
  shows "((\<lambda>x. (f x, g x)) has_derivative (\<lambda>h. (f' h, g' h))) (at x within s)"
68607
67bb59e49834 make theorem, corollary, and proposition %important for HOL-Analysis manual
immler
parents: 68072
diff changeset
   674
proof (rule has_derivativeI_sandwich[of 1])
44575
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   675
  show "bounded_linear (\<lambda>h. (f' h, g' h))"
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 54890
diff changeset
   676
    using f g by (intro bounded_linear_Pair has_derivative_bounded_linear)
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   677
  let ?Rf = "\<lambda>y. f y - f x - f' (y - x)"
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   678
  let ?Rg = "\<lambda>y. g y - g x - g' (y - x)"
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   679
  let ?R = "\<lambda>y. ((f y, g y) - (f x, g x) - (f' (y - x), g' (y - x)))"
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   680
61973
0c7e865fa7cb more symbols;
wenzelm
parents: 61969
diff changeset
   681
  show "((\<lambda>y. norm (?Rf y) / norm (y - x) + norm (?Rg y) / norm (y - x)) \<longlongrightarrow> 0) (at x within s)"
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 54890
diff changeset
   682
    using f g by (intro tendsto_add_zero) (auto simp: has_derivative_iff_norm)
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   683
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   684
  fix y :: 'a assume "y \<noteq> x"
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   685
  show "norm (?R y) / norm (y - x) \<le> norm (?Rf y) / norm (y - x) + norm (?Rg y) / norm (y - x)"
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   686
    unfolding add_divide_distrib [symmetric]
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   687
    by (simp add: norm_Pair divide_right_mono order_trans [OF sqrt_add_le_add_sqrt])
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   688
qed simp
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   689
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   690
lemma differentiable_Pair [simp, derivative_intros]:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   691
  "f differentiable at x within s \<Longrightarrow> g differentiable at x within s \<Longrightarrow>
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   692
    (\<lambda>x. (f x, g x)) differentiable at x within s"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   693
  unfolding differentiable_def by (blast intro: has_derivative_Pair)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   694
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
   695
lemmas has_derivative_fst [derivative_intros] = bounded_linear.has_derivative [OF bounded_linear_fst]
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
   696
lemmas has_derivative_snd [derivative_intros] = bounded_linear.has_derivative [OF bounded_linear_snd]
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   697
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
   698
lemma has_derivative_split [derivative_intros]:
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   699
  "((\<lambda>p. f (fst p) (snd p)) has_derivative f') F \<Longrightarrow> ((\<lambda>(a, b). f a b) has_derivative f') F"
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51478
diff changeset
   700
  unfolding split_beta' .
44575
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   701
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   702
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69541
diff changeset
   703
subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Vector derivatives involving pairs\<close>
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   704
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   705
lemma has_vector_derivative_Pair[derivative_intros]:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   706
  assumes "(f has_vector_derivative f') (at x within s)"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   707
    "(g has_vector_derivative g') (at x within s)"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   708
  shows "((\<lambda>x. (f x, g x)) has_vector_derivative (f', g')) (at x within s)"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   709
  using assms
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   710
  by (auto simp: has_vector_derivative_def intro!: derivative_eq_intros)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   711
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   712
lemma
60615
e5fa1d5d3952 Useful lemmas. The theorem concerning swapping the variables in a double integral.
paulson <lp15@cam.ac.uk>
parents: 60500
diff changeset
   713
  fixes x :: "'a::real_normed_vector"
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   714
  shows norm_Pair1 [simp]: "norm (0,x) = norm x"
60615
e5fa1d5d3952 Useful lemmas. The theorem concerning swapping the variables in a double integral.
paulson <lp15@cam.ac.uk>
parents: 60500
diff changeset
   715
    and norm_Pair2 [simp]: "norm (x,0) = norm x"
e5fa1d5d3952 Useful lemmas. The theorem concerning swapping the variables in a double integral.
paulson <lp15@cam.ac.uk>
parents: 60500
diff changeset
   716
by (auto simp: norm_Pair)
e5fa1d5d3952 Useful lemmas. The theorem concerning swapping the variables in a double integral.
paulson <lp15@cam.ac.uk>
parents: 60500
diff changeset
   717
62131
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62102
diff changeset
   718
lemma norm_commute: "norm (x,y) = norm (y,x)"
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62102
diff changeset
   719
  by (simp add: norm_Pair)
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62102
diff changeset
   720
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62102
diff changeset
   721
lemma norm_fst_le: "norm x \<le> norm (x,y)"
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62102
diff changeset
   722
  by (metis dist_fst_le fst_conv fst_zero norm_conv_dist)
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62102
diff changeset
   723
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62102
diff changeset
   724
lemma norm_snd_le: "norm y \<le> norm (x,y)"
1baed43f453e nonneg_Reals, nonpos_Reals, Cauchy integral formula, etc.
paulson
parents: 62102
diff changeset
   725
  by (metis dist_snd_le snd_conv snd_zero norm_conv_dist)
59425
c5e79df8cc21 import general thms from Density_Compiler
hoelzl
parents: 58881
diff changeset
   726
67685
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   727
lemma norm_Pair_le:
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   728
  shows "norm (x, y) \<le> norm x + norm y"
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   729
  unfolding norm_Pair
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   730
  by (metis norm_ge_zero sqrt_sum_squares_le_sum)
bdff8bf0a75b moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
immler
parents: 66453
diff changeset
   731
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   732
lemma (in vector_space_prod) span_Times_sing1: "p.span ({0} \<times> B) = {0} \<times> vs2.span B"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   733
  apply (rule p.span_unique)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   734
  subgoal by (auto intro!: vs1.span_base vs2.span_base)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   735
  subgoal using vs1.subspace_single_0 vs2.subspace_span by (rule subspace_Times)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   736
  subgoal for T
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   737
  proof safe
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   738
    fix b
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   739
    assume subset_T: "{0} \<times> B \<subseteq> T" and subspace: "p.subspace T" and b_span: "b \<in> vs2.span B"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   740
    then obtain t r where b: "b = (\<Sum>a\<in>t. r a *b a)" and t: "finite t" "t \<subseteq> B"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   741
      by (auto simp: vs2.span_explicit)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   742
    have "(0, b) = (\<Sum>b\<in>t. scale (r b) (0, b))"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   743
      unfolding b scale_prod sum_prod
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   744
      by simp
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   745
    also have "\<dots> \<in> T"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   746
      using \<open>t \<subseteq> B\<close> subset_T
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   747
      by (auto intro!: p.subspace_sum p.subspace_scale subspace)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   748
    finally show "(0, b) \<in> T" .
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   749
  qed
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   750
  done
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   751
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   752
lemma (in vector_space_prod) span_Times_sing2: "p.span (A \<times> {0}) = vs1.span A \<times> {0}"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   753
  apply (rule p.span_unique)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   754
  subgoal by (auto intro!: vs1.span_base vs2.span_base)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   755
  subgoal using vs1.subspace_span vs2.subspace_single_0 by (rule subspace_Times)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   756
  subgoal for T
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   757
  proof safe
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   758
    fix a
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   759
    assume subset_T: "A \<times> {0} \<subseteq> T" and subspace: "p.subspace T" and a_span: "a \<in> vs1.span A"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   760
    then obtain t r where a: "a = (\<Sum>a\<in>t. r a *a a)" and t: "finite t" "t \<subseteq> A"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   761
      by (auto simp: vs1.span_explicit)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   762
    have "(a, 0) = (\<Sum>a\<in>t. scale (r a) (a, 0))"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   763
      unfolding a scale_prod sum_prod
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   764
      by simp
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   765
    also have "\<dots> \<in> T"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   766
      using \<open>t \<subseteq> A\<close> subset_T
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   767
      by (auto intro!: p.subspace_sum p.subspace_scale subspace)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   768
    finally show "(a, 0) \<in> T" .
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   769
  qed
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   770
  done
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   771
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   772
subsection \<open>Product is Finite Dimensional\<close>
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   773
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   774
lemma (in finite_dimensional_vector_space) zero_not_in_Basis[simp]: "0 \<notin> Basis"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   775
  using dependent_zero local.independent_Basis by blast
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   776
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   777
locale finite_dimensional_vector_space_prod = vector_space_prod + finite_dimensional_vector_space_pair begin
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   778
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   779
definition "Basis_pair = B1 \<times> {0} \<union> {0} \<times> B2"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   780
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   781
sublocale p: finite_dimensional_vector_space scale Basis_pair
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   782
proof unfold_locales
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   783
  show "finite Basis_pair"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   784
    by (auto intro!: finite_cartesian_product vs1.finite_Basis vs2.finite_Basis simp: Basis_pair_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   785
  show "p.independent Basis_pair"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   786
    unfolding p.dependent_def Basis_pair_def
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   787
  proof safe
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   788
    fix a
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   789
    assume a: "a \<in> B1"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   790
    assume "(a, 0) \<in> p.span (B1 \<times> {0} \<union> {0} \<times> B2 - {(a, 0)})"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   791
    also have "B1 \<times> {0} \<union> {0} \<times> B2 - {(a, 0)} = (B1 - {a}) \<times> {0} \<union> {0} \<times> B2"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   792
      by auto
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   793
    finally show False
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   794
      using a vs1.dependent_def vs1.independent_Basis
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   795
      by (auto simp: p.span_Un span_Times_sing1 span_Times_sing2)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   796
  next
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   797
    fix b
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   798
    assume b: "b \<in> B2"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   799
    assume "(0, b) \<in> p.span (B1 \<times> {0} \<union> {0} \<times> B2 - {(0, b)})"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   800
    also have "(B1 \<times> {0} \<union> {0} \<times> B2 - {(0, b)}) = B1 \<times> {0} \<union> {0} \<times> (B2 - {b})"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   801
      by auto
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   802
    finally show False
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   803
      using b vs2.dependent_def vs2.independent_Basis
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   804
      by (auto simp: p.span_Un span_Times_sing1 span_Times_sing2)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   805
  qed
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   806
  show "p.span Basis_pair = UNIV"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   807
    by (auto simp: p.span_Un span_Times_sing2 span_Times_sing1 vs1.span_Basis vs2.span_Basis
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   808
        Basis_pair_def)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   809
qed
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   810
69541
d466e0a639e4 tuned analysis manual
immler
parents: 69511
diff changeset
   811
proposition dim_Times:
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   812
  assumes "vs1.subspace S" "vs2.subspace T"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   813
  shows "p.dim(S \<times> T) = vs1.dim S + vs2.dim T"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   814
proof -
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   815
  interpret p1: Vector_Spaces.linear s1 scale "(\<lambda>x. (x, 0))"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   816
    by unfold_locales (auto simp: scale_def)
69064
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   817
  interpret pair1: finite_dimensional_vector_space_pair "(*a)" B1 scale Basis_pair
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   818
    by unfold_locales
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   819
  interpret p2: Vector_Spaces.linear s2 scale "(\<lambda>x. (0, x))"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   820
    by unfold_locales (auto simp: scale_def)
69064
5840724b1d71 Prefix form of infix with * on either side no longer needs special treatment
nipkow
parents: 68617
diff changeset
   821
  interpret pair2: finite_dimensional_vector_space_pair "(*b)" B2 scale Basis_pair
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   822
    by unfold_locales
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   823
  have ss: "p.subspace ((\<lambda>x. (x, 0)) ` S)" "p.subspace (Pair 0 ` T)"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   824
    by (rule p1.subspace_image p2.subspace_image assms)+
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   825
  have "p.dim(S \<times> T) = p.dim({u + v |u v. u \<in> (\<lambda>x. (x, 0)) ` S \<and> v \<in> Pair 0 ` T})"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   826
    by (simp add: Times_eq_image_sum)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   827
  moreover have "p.dim ((\<lambda>x. (x, 0::'c)) ` S) = vs1.dim S" "p.dim (Pair (0::'b) ` T) = vs2.dim T"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   828
     by (simp_all add: inj_on_def p1.linear_axioms pair1.dim_image_eq p2.linear_axioms pair2.dim_image_eq)
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   829
  moreover have "p.dim ((\<lambda>x. (x, 0)) ` S \<inter> Pair 0 ` T) = 0"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   830
    by (subst p.dim_eq_0) auto
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   831
  ultimately show ?thesis
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   832
    using p.dim_sums_Int [OF ss] by linarith
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   833
qed
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   834
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   835
lemma dimension_pair: "p.dimension = vs1.dimension + vs2.dimension"
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   836
  using dim_Times[OF vs1.subspace_UNIV vs2.subspace_UNIV]
71174
nipkow
parents: 70137
diff changeset
   837
  by (auto simp: p.dimension_def vs1.dimension_def vs2.dimension_def)
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   838
44575
c5e42b8590dd Product_Vector.thy: clean up some proofs
huffman
parents: 44568
diff changeset
   839
end
68072
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   840
493b818e8e10 added Johannes' generalizations Modules.thy and Vector_Spaces.thy; adapted HOL and HOL-Analysis accordingly
immler
parents: 67962
diff changeset
   841
end