src/HOL/Multivariate_Analysis/Bounded_Linear_Function.thy
author immler
Wed Dec 23 14:36:45 2015 +0100 (2015-12-23)
changeset 61916 7950ae6d3266
parent 61915 e9812a95d108
child 61945 1135b8de26c3
permissions -rw-r--r--
transfer rule for bounded_linear of blinfun
immler@61915
     1
(*  Title:      HOL/Multivariate_Analysis/Bounded_Linear_Function.thy
immler@61915
     2
    Author:     Fabian Immler, TU M√ľnchen
immler@61915
     3
*)
immler@61915
     4
immler@61915
     5
section {* Bounded Linear Function *}
immler@61915
     6
immler@61915
     7
theory Bounded_Linear_Function
immler@61915
     8
imports
immler@61915
     9
  Topology_Euclidean_Space
immler@61915
    10
  Operator_Norm
immler@61915
    11
begin
immler@61915
    12
immler@61915
    13
subsection {* Intro rules for @{term bounded_linear} *}
immler@61915
    14
immler@61915
    15
named_theorems bounded_linear_intros
immler@61915
    16
immler@61915
    17
lemma onorm_inner_left:
immler@61915
    18
  assumes "bounded_linear r"
immler@61915
    19
  shows "onorm (\<lambda>x. r x \<bullet> f) \<le> onorm r * norm f"
immler@61915
    20
proof (rule onorm_bound)
immler@61915
    21
  fix x
immler@61915
    22
  have "norm (r x \<bullet> f) \<le> norm (r x) * norm f"
immler@61915
    23
    by (simp add: Cauchy_Schwarz_ineq2)
immler@61915
    24
  also have "\<dots> \<le> onorm r * norm x * norm f"
immler@61915
    25
    by (intro mult_right_mono onorm assms norm_ge_zero)
immler@61915
    26
  finally show "norm (r x \<bullet> f) \<le> onorm r * norm f * norm x"
immler@61915
    27
    by (simp add: ac_simps)
immler@61915
    28
qed (intro mult_nonneg_nonneg norm_ge_zero onorm_pos_le assms)
immler@61915
    29
immler@61915
    30
lemma onorm_inner_right:
immler@61915
    31
  assumes "bounded_linear r"
immler@61915
    32
  shows "onorm (\<lambda>x. f \<bullet> r x) \<le> norm f * onorm r"
immler@61915
    33
  apply (subst inner_commute)
immler@61915
    34
  apply (rule onorm_inner_left[OF assms, THEN order_trans])
immler@61915
    35
  apply simp
immler@61915
    36
  done
immler@61915
    37
immler@61915
    38
lemmas [bounded_linear_intros] =
immler@61915
    39
  bounded_linear_zero
immler@61915
    40
  bounded_linear_add
immler@61915
    41
  bounded_linear_const_mult
immler@61915
    42
  bounded_linear_mult_const
immler@61915
    43
  bounded_linear_scaleR_const
immler@61915
    44
  bounded_linear_const_scaleR
immler@61915
    45
  bounded_linear_ident
immler@61915
    46
  bounded_linear_setsum
immler@61915
    47
  bounded_linear_Pair
immler@61915
    48
  bounded_linear_sub
immler@61915
    49
  bounded_linear_fst_comp
immler@61915
    50
  bounded_linear_snd_comp
immler@61915
    51
  bounded_linear_inner_left_comp
immler@61915
    52
  bounded_linear_inner_right_comp
immler@61915
    53
immler@61915
    54
immler@61915
    55
subsection \<open>declaration of derivative/continuous/tendsto introduction rules for bounded linear functions\<close>
immler@61915
    56
immler@61915
    57
attribute_setup bounded_linear =
immler@61915
    58
  \<open>Scan.succeed (Thm.declaration_attribute (fn thm =>
immler@61915
    59
    fold (fn (r, s) => Named_Theorems.add_thm s (thm RS r))
immler@61915
    60
      [
immler@61915
    61
        (@{thm bounded_linear.has_derivative}, "Deriv.derivative_intros"),
immler@61915
    62
        (@{thm bounded_linear.tendsto}, "Topological_Spaces.tendsto_intros"),
immler@61915
    63
        (@{thm bounded_linear.continuous}, "Topological_Spaces.continuous_intros"),
immler@61915
    64
        (@{thm bounded_linear.continuous_on}, "Topological_Spaces.continuous_intros"),
immler@61915
    65
        (@{thm bounded_linear.uniformly_continuous_on}, "Topological_Spaces.continuous_intros"),
immler@61915
    66
        (@{thm bounded_linear_compose}, "Bounded_Linear_Function.bounded_linear_intros")
immler@61915
    67
      ]))\<close>
immler@61915
    68
immler@61915
    69
attribute_setup bounded_bilinear =
immler@61915
    70
  \<open>Scan.succeed (Thm.declaration_attribute (fn thm =>
immler@61915
    71
    fold (fn (r, s) => Named_Theorems.add_thm s (thm RS r))
immler@61915
    72
      [
immler@61915
    73
        (@{thm bounded_bilinear.FDERIV}, "Deriv.derivative_intros"),
immler@61915
    74
        (@{thm bounded_bilinear.tendsto}, "Topological_Spaces.tendsto_intros"),
immler@61915
    75
        (@{thm bounded_bilinear.continuous}, "Topological_Spaces.continuous_intros"),
immler@61915
    76
        (@{thm bounded_bilinear.continuous_on}, "Topological_Spaces.continuous_intros"),
immler@61915
    77
        (@{thm bounded_linear_compose[OF bounded_bilinear.bounded_linear_left]},
immler@61915
    78
          "Bounded_Linear_Function.bounded_linear_intros"),
immler@61915
    79
        (@{thm bounded_linear_compose[OF bounded_bilinear.bounded_linear_right]},
immler@61915
    80
          "Bounded_Linear_Function.bounded_linear_intros"),
immler@61915
    81
        (@{thm bounded_linear.uniformly_continuous_on[OF bounded_bilinear.bounded_linear_left]},
immler@61915
    82
          "Topological_Spaces.continuous_intros"),
immler@61915
    83
        (@{thm bounded_linear.uniformly_continuous_on[OF bounded_bilinear.bounded_linear_right]},
immler@61915
    84
          "Topological_Spaces.continuous_intros")
immler@61915
    85
      ]))\<close>
immler@61915
    86
immler@61915
    87
immler@61915
    88
subsection \<open>type of bounded linear functions\<close>
immler@61915
    89
immler@61915
    90
typedef (overloaded) ('a, 'b) blinfun ("(_ \<Rightarrow>\<^sub>L /_)" [22, 21] 21) =
immler@61915
    91
  "{f::'a::real_normed_vector\<Rightarrow>'b::real_normed_vector. bounded_linear f}"
immler@61915
    92
  morphisms blinfun_apply Blinfun
immler@61915
    93
  by (blast intro: bounded_linear_intros)
immler@61915
    94
immler@61915
    95
declare [[coercion
immler@61915
    96
    "blinfun_apply :: ('a::real_normed_vector \<Rightarrow>\<^sub>L'b::real_normed_vector) \<Rightarrow> 'a \<Rightarrow> 'b"]]
immler@61915
    97
immler@61915
    98
lemma bounded_linear_blinfun_apply[bounded_linear_intros]:
immler@61915
    99
  "bounded_linear g \<Longrightarrow> bounded_linear (\<lambda>x. blinfun_apply f (g x))"
immler@61915
   100
  by (metis blinfun_apply mem_Collect_eq bounded_linear_compose)
immler@61915
   101
immler@61915
   102
setup_lifting type_definition_blinfun
immler@61915
   103
immler@61915
   104
lemma blinfun_eqI: "(\<And>i. blinfun_apply x i = blinfun_apply y i) \<Longrightarrow> x = y"
immler@61915
   105
  by transfer auto
immler@61915
   106
immler@61915
   107
lemma bounded_linear_Blinfun_apply: "bounded_linear f \<Longrightarrow> blinfun_apply (Blinfun f) = f"
immler@61915
   108
  by (auto simp: Blinfun_inverse)
immler@61915
   109
immler@61915
   110
immler@61915
   111
subsection \<open>type class instantiations\<close>
immler@61915
   112
immler@61915
   113
instantiation blinfun :: (real_normed_vector, real_normed_vector) real_normed_vector
immler@61915
   114
begin
immler@61915
   115
immler@61915
   116
lift_definition norm_blinfun :: "'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> real" is onorm .
immler@61915
   117
immler@61915
   118
lift_definition minus_blinfun :: "'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   119
  is "\<lambda>f g x. f x - g x"
immler@61915
   120
  by (rule bounded_linear_sub)
immler@61915
   121
immler@61915
   122
definition dist_blinfun :: "'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> real"
immler@61915
   123
  where "dist_blinfun a b = norm (a - b)"
immler@61915
   124
immler@61915
   125
definition open_blinfun :: "('a \<Rightarrow>\<^sub>L 'b) set \<Rightarrow> bool"
immler@61915
   126
  where "open_blinfun S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)"
immler@61915
   127
immler@61915
   128
lift_definition uminus_blinfun :: "'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b" is "\<lambda>f x. - f x"
immler@61915
   129
  by (rule bounded_linear_minus)
immler@61915
   130
immler@61915
   131
lift_definition zero_blinfun :: "'a \<Rightarrow>\<^sub>L 'b" is "\<lambda>x. 0"
immler@61915
   132
  by (rule bounded_linear_zero)
immler@61915
   133
immler@61915
   134
lift_definition plus_blinfun :: "'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   135
  is "\<lambda>f g x. f x + g x"
immler@61915
   136
  by (metis bounded_linear_add)
immler@61915
   137
immler@61915
   138
lift_definition scaleR_blinfun::"real \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b" is "\<lambda>r f x. r *\<^sub>R f x"
immler@61915
   139
  by (metis bounded_linear_compose bounded_linear_scaleR_right)
immler@61915
   140
immler@61915
   141
definition sgn_blinfun :: "'a \<Rightarrow>\<^sub>L 'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   142
  where "sgn_blinfun x = scaleR (inverse (norm x)) x"
immler@61915
   143
immler@61915
   144
instance
immler@61915
   145
  apply standard
immler@61915
   146
  unfolding dist_blinfun_def open_blinfun_def sgn_blinfun_def
immler@61915
   147
  apply (transfer, force simp: onorm_triangle onorm_scaleR onorm_eq_0 algebra_simps)+
immler@61915
   148
  done
immler@61915
   149
immler@61915
   150
end
immler@61915
   151
immler@61915
   152
lemma norm_blinfun_eqI:
immler@61915
   153
  assumes "n \<le> norm (blinfun_apply f x) / norm x"
immler@61915
   154
  assumes "\<And>x. norm (blinfun_apply f x) \<le> n * norm x"
immler@61915
   155
  assumes "0 \<le> n"
immler@61915
   156
  shows "norm f = n"
immler@61915
   157
  by (auto simp: norm_blinfun_def
immler@61915
   158
    intro!: antisym onorm_bound assms order_trans[OF _ le_onorm]
immler@61915
   159
    bounded_linear_intros)
immler@61915
   160
immler@61915
   161
lemma norm_blinfun: "norm (blinfun_apply f x) \<le> norm f * norm x"
immler@61915
   162
  by transfer (rule onorm)
immler@61915
   163
immler@61915
   164
lemma norm_blinfun_bound: "0 \<le> b \<Longrightarrow> (\<And>x. norm (blinfun_apply f x) \<le> b * norm x) \<Longrightarrow> norm f \<le> b"
immler@61915
   165
  by transfer (rule onorm_bound)
immler@61915
   166
immler@61915
   167
lemma bounded_bilinear_blinfun_apply[bounded_bilinear]: "bounded_bilinear blinfun_apply"
immler@61915
   168
proof
immler@61915
   169
  fix f g::"'a \<Rightarrow>\<^sub>L 'b" and a b::'a and r::real
immler@61915
   170
  show "(f + g) a = f a + g a" "(r *\<^sub>R f) a = r *\<^sub>R f a"
immler@61915
   171
    by (transfer, simp)+
immler@61915
   172
  interpret bounded_linear f for f::"'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   173
    by (auto intro!: bounded_linear_intros)
immler@61915
   174
  show "f (a + b) = f a + f b" "f (r *\<^sub>R a) = r *\<^sub>R f a"
immler@61915
   175
    by (simp_all add: add scaleR)
immler@61915
   176
  show "\<exists>K. \<forall>a b. norm (blinfun_apply a b) \<le> norm a * norm b * K"
immler@61915
   177
    by (auto intro!: exI[where x=1] norm_blinfun)
immler@61915
   178
qed
immler@61915
   179
immler@61915
   180
interpretation blinfun: bounded_bilinear blinfun_apply
immler@61915
   181
  by (rule bounded_bilinear_blinfun_apply)
immler@61915
   182
immler@61915
   183
lemmas bounded_linear_apply_blinfun[intro, simp] = blinfun.bounded_linear_left
immler@61915
   184
immler@61915
   185
immler@61915
   186
context bounded_bilinear
immler@61915
   187
begin
immler@61915
   188
immler@61915
   189
named_theorems bilinear_simps
immler@61915
   190
immler@61915
   191
lemmas [bilinear_simps] =
immler@61915
   192
  add_left
immler@61915
   193
  add_right
immler@61915
   194
  diff_left
immler@61915
   195
  diff_right
immler@61915
   196
  minus_left
immler@61915
   197
  minus_right
immler@61915
   198
  scaleR_left
immler@61915
   199
  scaleR_right
immler@61915
   200
  zero_left
immler@61915
   201
  zero_right
immler@61915
   202
  setsum_left
immler@61915
   203
  setsum_right
immler@61915
   204
immler@61915
   205
end
immler@61915
   206
immler@61915
   207
immler@61915
   208
instance blinfun :: (banach, banach) banach
immler@61915
   209
proof
immler@61915
   210
  fix X::"nat \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   211
  assume "Cauchy X"
immler@61915
   212
  {
immler@61915
   213
    fix x::'a
immler@61915
   214
    {
immler@61915
   215
      fix x::'a
immler@61915
   216
      assume "norm x \<le> 1"
immler@61915
   217
      have "Cauchy (\<lambda>n. X n x)"
immler@61915
   218
      proof (rule CauchyI)
immler@61915
   219
        fix e::real
immler@61915
   220
        assume "0 < e"
immler@61915
   221
        from CauchyD[OF `Cauchy X` `0 < e`] obtain M
immler@61915
   222
          where M: "\<And>m n. m \<ge> M \<Longrightarrow> n \<ge> M \<Longrightarrow> norm (X m - X n) < e"
immler@61915
   223
          by auto
immler@61915
   224
        show "\<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m x - X n x) < e"
immler@61915
   225
        proof (safe intro!: exI[where x=M])
immler@61915
   226
          fix m n
immler@61915
   227
          assume le: "M \<le> m" "M \<le> n"
immler@61915
   228
          have "norm (X m x - X n x) = norm ((X m - X n) x)"
immler@61915
   229
            by (simp add: blinfun.bilinear_simps)
immler@61915
   230
          also have "\<dots> \<le> norm (X m - X n) * norm x"
immler@61915
   231
             by (rule norm_blinfun)
immler@61915
   232
          also have "\<dots> \<le> norm (X m - X n) * 1"
immler@61915
   233
            using `norm x \<le> 1` norm_ge_zero by (rule mult_left_mono)
immler@61915
   234
          also have "\<dots> = norm (X m - X n)" by simp
immler@61915
   235
          also have "\<dots> < e" using le by fact
immler@61915
   236
          finally show "norm (X m x - X n x) < e" .
immler@61915
   237
        qed
immler@61915
   238
      qed
immler@61915
   239
      hence "convergent (\<lambda>n. X n x)"
immler@61915
   240
        by (metis Cauchy_convergent_iff)
immler@61915
   241
    } note convergent_norm1 = this
immler@61915
   242
    def y \<equiv> "x /\<^sub>R norm x"
immler@61915
   243
    have y: "norm y \<le> 1" and xy: "x = norm x *\<^sub>R y"
immler@61915
   244
      by (simp_all add: y_def inverse_eq_divide)
immler@61915
   245
    have "convergent (\<lambda>n. norm x *\<^sub>R X n y)"
immler@61915
   246
      by (intro bounded_bilinear.convergent[OF bounded_bilinear_scaleR] convergent_const
immler@61915
   247
        convergent_norm1 y)
immler@61915
   248
    also have "(\<lambda>n. norm x *\<^sub>R X n y) = (\<lambda>n. X n x)"
immler@61915
   249
      by (subst xy) (simp add: blinfun.bilinear_simps)
immler@61915
   250
    finally have "convergent (\<lambda>n. X n x)" .
immler@61915
   251
  }
immler@61915
   252
  then obtain v where v: "\<And>x. (\<lambda>n. X n x) ----> v x"
immler@61915
   253
    unfolding convergent_def
immler@61915
   254
    by metis
immler@61915
   255
immler@61915
   256
  have "Cauchy (\<lambda>n. norm (X n))"
immler@61915
   257
  proof (rule CauchyI)
immler@61915
   258
    fix e::real
immler@61915
   259
    assume "e > 0"
immler@61915
   260
    from CauchyD[OF `Cauchy X` `0 < e`] obtain M
immler@61915
   261
      where M: "\<And>m n. m \<ge> M \<Longrightarrow> n \<ge> M \<Longrightarrow> norm (X m - X n) < e"
immler@61915
   262
      by auto
immler@61915
   263
    show "\<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (norm (X m) - norm (X n)) < e"
immler@61915
   264
    proof (safe intro!: exI[where x=M])
immler@61915
   265
      fix m n assume mn: "m \<ge> M" "n \<ge> M"
immler@61915
   266
      have "norm (norm (X m) - norm (X n)) \<le> norm (X m - X n)"
immler@61915
   267
        by (metis norm_triangle_ineq3 real_norm_def)
immler@61915
   268
      also have "\<dots> < e" using mn by fact
immler@61915
   269
      finally show "norm (norm (X m) - norm (X n)) < e" .
immler@61915
   270
    qed
immler@61915
   271
  qed
immler@61915
   272
  then obtain K where K: "(\<lambda>n. norm (X n)) ----> K"
immler@61915
   273
    unfolding Cauchy_convergent_iff convergent_def
immler@61915
   274
    by metis
immler@61915
   275
immler@61915
   276
  have "bounded_linear v"
immler@61915
   277
  proof
immler@61915
   278
    fix x y and r::real
immler@61915
   279
    from tendsto_add[OF v[of x] v [of y]] v[of "x + y", unfolded blinfun.bilinear_simps]
immler@61915
   280
      tendsto_scaleR[OF tendsto_const[of r] v[of x]] v[of "r *\<^sub>R x", unfolded blinfun.bilinear_simps]
immler@61915
   281
    show "v (x + y) = v x + v y" "v (r *\<^sub>R x) = r *\<^sub>R v x"
immler@61915
   282
      by (metis (poly_guards_query) LIMSEQ_unique)+
immler@61915
   283
    show "\<exists>K. \<forall>x. norm (v x) \<le> norm x * K"
immler@61915
   284
    proof (safe intro!: exI[where x=K])
immler@61915
   285
      fix x
immler@61915
   286
      have "norm (v x) \<le> K * norm x"
immler@61915
   287
        by (rule tendsto_le[OF _ tendsto_mult[OF K tendsto_const] tendsto_norm[OF v]])
immler@61915
   288
          (auto simp: norm_blinfun)
immler@61915
   289
      thus "norm (v x) \<le> norm x * K"
immler@61915
   290
        by (simp add: ac_simps)
immler@61915
   291
    qed
immler@61915
   292
  qed
immler@61915
   293
  hence Bv: "\<And>x. (\<lambda>n. X n x) ----> Blinfun v x"
immler@61915
   294
    by (auto simp: bounded_linear_Blinfun_apply v)
immler@61915
   295
immler@61915
   296
  have "X ----> Blinfun v"
immler@61915
   297
  proof (rule LIMSEQ_I)
immler@61915
   298
    fix r::real assume "r > 0"
immler@61915
   299
    def r' \<equiv> "r / 2"
immler@61915
   300
    have "0 < r'" "r' < r" using `r > 0` by (simp_all add: r'_def)
immler@61915
   301
    from CauchyD[OF `Cauchy X` `r' > 0`]
immler@61915
   302
    obtain M where M: "\<And>m n. m \<ge> M \<Longrightarrow> n \<ge> M \<Longrightarrow> norm (X m - X n) < r'"
immler@61915
   303
      by metis
immler@61915
   304
    show "\<exists>no. \<forall>n\<ge>no. norm (X n - Blinfun v) < r"
immler@61915
   305
    proof (safe intro!: exI[where x=M])
immler@61915
   306
      fix n assume n: "M \<le> n"
immler@61915
   307
      have "norm (X n - Blinfun v) \<le> r'"
immler@61915
   308
      proof (rule norm_blinfun_bound)
immler@61915
   309
        fix x
immler@61915
   310
        have "eventually (\<lambda>m. m \<ge> M) sequentially"
immler@61915
   311
          by (metis eventually_ge_at_top)
immler@61915
   312
        hence ev_le: "eventually (\<lambda>m. norm (X n x - X m x) \<le> r' * norm x) sequentially"
immler@61915
   313
        proof eventually_elim
immler@61915
   314
          case (elim m)
immler@61915
   315
          have "norm (X n x - X m x) = norm ((X n - X m) x)"
immler@61915
   316
            by (simp add: blinfun.bilinear_simps)
immler@61915
   317
          also have "\<dots> \<le> norm ((X n - X m)) * norm x"
immler@61915
   318
            by (rule norm_blinfun)
immler@61915
   319
          also have "\<dots> \<le> r' * norm x"
immler@61915
   320
            using M[OF n elim] by (simp add: mult_right_mono)
immler@61915
   321
          finally show ?case .
immler@61915
   322
        qed
immler@61915
   323
        have tendsto_v: "(\<lambda>m. norm (X n x - X m x)) ----> norm (X n x - Blinfun v x)"
immler@61915
   324
          by (auto intro!: tendsto_intros Bv)
immler@61915
   325
        show "norm ((X n - Blinfun v) x) \<le> r' * norm x"
immler@61915
   326
          by (auto intro!: tendsto_ge_const tendsto_v ev_le simp: blinfun.bilinear_simps)
immler@61915
   327
      qed (simp add: `0 < r'` less_imp_le)
immler@61915
   328
      thus "norm (X n - Blinfun v) < r"
immler@61915
   329
        by (metis `r' < r` le_less_trans)
immler@61915
   330
    qed
immler@61915
   331
  qed
immler@61915
   332
  thus "convergent X"
immler@61915
   333
    by (rule convergentI)
immler@61915
   334
qed
immler@61915
   335
immler@61915
   336
subsection {* On Euclidean Space *}
immler@61915
   337
immler@61915
   338
lemma Zfun_setsum:
immler@61915
   339
  assumes "finite s"
immler@61915
   340
  assumes f: "\<And>i. i \<in> s \<Longrightarrow> Zfun (f i) F"
immler@61915
   341
  shows "Zfun (\<lambda>x. setsum (\<lambda>i. f i x) s) F"
immler@61915
   342
  using assms by induct (auto intro!: Zfun_zero Zfun_add)
immler@61915
   343
immler@61915
   344
lemma norm_blinfun_euclidean_le:
immler@61915
   345
  fixes a::"'a::euclidean_space \<Rightarrow>\<^sub>L 'b::real_normed_vector"
immler@61915
   346
  shows "norm a \<le> setsum (\<lambda>x. norm (a x)) Basis"
immler@61915
   347
  apply (rule norm_blinfun_bound)
immler@61915
   348
   apply (simp add: setsum_nonneg)
immler@61915
   349
  apply (subst euclidean_representation[symmetric, where 'a='a])
immler@61915
   350
  apply (simp only: blinfun.bilinear_simps setsum_left_distrib)
immler@61915
   351
  apply (rule order.trans[OF norm_setsum setsum_mono])
immler@61915
   352
  apply (simp add: abs_mult mult_right_mono ac_simps Basis_le_norm)
immler@61915
   353
  done
immler@61915
   354
immler@61915
   355
lemma tendsto_componentwise1:
immler@61915
   356
  fixes a::"'a::euclidean_space \<Rightarrow>\<^sub>L 'b::real_normed_vector"
immler@61915
   357
    and b::"'c \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   358
  assumes "(\<And>j. j \<in> Basis \<Longrightarrow> ((\<lambda>n. b n j) ---> a j) F)"
immler@61915
   359
  shows "(b ---> a) F"
immler@61915
   360
proof -
immler@61915
   361
  have "\<And>j. j \<in> Basis \<Longrightarrow> Zfun (\<lambda>x. norm (b x j - a j)) F"
immler@61915
   362
    using assms unfolding tendsto_Zfun_iff Zfun_norm_iff .
immler@61915
   363
  hence "Zfun (\<lambda>x. \<Sum>j\<in>Basis. norm (b x j - a j)) F"
immler@61915
   364
    by (auto intro!: Zfun_setsum)
immler@61915
   365
  thus ?thesis
immler@61915
   366
    unfolding tendsto_Zfun_iff
immler@61915
   367
    by (rule Zfun_le)
immler@61915
   368
      (auto intro!: order_trans[OF norm_blinfun_euclidean_le] simp: blinfun.bilinear_simps)
immler@61915
   369
qed
immler@61915
   370
immler@61915
   371
lift_definition
immler@61915
   372
  blinfun_of_matrix::"('b::euclidean_space \<Rightarrow> 'a::euclidean_space \<Rightarrow> real) \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   373
  is "\<lambda>a x. \<Sum>i\<in>Basis. \<Sum>j\<in>Basis. ((x \<bullet> j) * a i j) *\<^sub>R i"
immler@61915
   374
  by (intro bounded_linear_intros)
immler@61915
   375
immler@61915
   376
lemma blinfun_of_matrix_works:
immler@61915
   377
  fixes f::"'a::euclidean_space \<Rightarrow>\<^sub>L 'b::euclidean_space"
immler@61915
   378
  shows "blinfun_of_matrix (\<lambda>i j. (f j) \<bullet> i) = f"
immler@61915
   379
proof (transfer, rule,  rule euclidean_eqI)
immler@61915
   380
  fix f::"'a \<Rightarrow> 'b" and x::'a and b::'b assume "bounded_linear f" and b: "b \<in> Basis"
immler@61915
   381
  then interpret bounded_linear f by simp
immler@61915
   382
  have "(\<Sum>j\<in>Basis. \<Sum>i\<in>Basis. (x \<bullet> i * (f i \<bullet> j)) *\<^sub>R j) \<bullet> b
immler@61915
   383
    = (\<Sum>j\<in>Basis. if j = b then (\<Sum>i\<in>Basis. (x \<bullet> i * (f i \<bullet> j))) else 0)"
immler@61915
   384
    using b
immler@61915
   385
    by (auto simp add: algebra_simps inner_setsum_left inner_Basis split: split_if intro!: setsum.cong)
immler@61915
   386
  also have "\<dots> = (\<Sum>i\<in>Basis. (x \<bullet> i * (f i \<bullet> b)))"
immler@61915
   387
    using b by (simp add: setsum.delta)
immler@61915
   388
  also have "\<dots> = f x \<bullet> b"
immler@61915
   389
    by (subst linear_componentwise[symmetric]) (unfold_locales, rule)
immler@61915
   390
  finally show "(\<Sum>j\<in>Basis. \<Sum>i\<in>Basis. (x \<bullet> i * (f i \<bullet> j)) *\<^sub>R j) \<bullet> b = f x \<bullet> b" .
immler@61915
   391
qed
immler@61915
   392
immler@61915
   393
lemma blinfun_of_matrix_apply:
immler@61915
   394
  "blinfun_of_matrix a x = (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. ((x \<bullet> j) * a i j) *\<^sub>R i)"
immler@61915
   395
  by transfer simp
immler@61915
   396
immler@61915
   397
lemma blinfun_of_matrix_minus: "blinfun_of_matrix x - blinfun_of_matrix y = blinfun_of_matrix (x - y)"
immler@61915
   398
  by transfer (auto simp: algebra_simps setsum_subtractf)
immler@61915
   399
immler@61915
   400
lemma norm_blinfun_of_matrix:
immler@61915
   401
  "norm (blinfun_of_matrix a) \<le> (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. abs (a i j))"
immler@61915
   402
  apply (rule norm_blinfun_bound)
immler@61915
   403
   apply (simp add: setsum_nonneg)
immler@61915
   404
  apply (simp only: blinfun_of_matrix_apply setsum_left_distrib)
immler@61915
   405
  apply (rule order_trans[OF norm_setsum setsum_mono])
immler@61915
   406
  apply (rule order_trans[OF norm_setsum setsum_mono])
immler@61915
   407
  apply (simp add: abs_mult mult_right_mono ac_simps Basis_le_norm)
immler@61915
   408
  done
immler@61915
   409
immler@61915
   410
lemma tendsto_blinfun_of_matrix:
immler@61915
   411
  assumes "\<And>i j. i \<in> Basis \<Longrightarrow> j \<in> Basis \<Longrightarrow> ((\<lambda>n. b n i j) ---> a i j) F"
immler@61915
   412
  shows "((\<lambda>n. blinfun_of_matrix (b n)) ---> blinfun_of_matrix a) F"
immler@61915
   413
proof -
immler@61915
   414
  have "\<And>i j. i \<in> Basis \<Longrightarrow> j \<in> Basis \<Longrightarrow> Zfun (\<lambda>x. norm (b x i j - a i j)) F"
immler@61915
   415
    using assms unfolding tendsto_Zfun_iff Zfun_norm_iff .
immler@61915
   416
  hence "Zfun (\<lambda>x. (\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. abs (b x i j - a i j))) F"
immler@61915
   417
    by (auto intro!: Zfun_setsum)
immler@61915
   418
  thus ?thesis
immler@61915
   419
    unfolding tendsto_Zfun_iff blinfun_of_matrix_minus
immler@61915
   420
    by (rule Zfun_le) (auto intro!: order_trans[OF norm_blinfun_of_matrix])
immler@61915
   421
qed
immler@61915
   422
immler@61915
   423
lemma tendsto_componentwise:
immler@61915
   424
  fixes a::"'a::euclidean_space \<Rightarrow>\<^sub>L 'b::euclidean_space"
immler@61915
   425
    and b::"'c \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   426
  shows "(\<And>i j. i \<in> Basis \<Longrightarrow> j \<in> Basis \<Longrightarrow> ((\<lambda>n. b n j \<bullet> i) ---> a j \<bullet> i) F) \<Longrightarrow> (b ---> a) F"
immler@61915
   427
  apply (subst blinfun_of_matrix_works[of a, symmetric])
immler@61915
   428
  apply (subst blinfun_of_matrix_works[of "b x" for x, symmetric, abs_def])
immler@61915
   429
  by (rule tendsto_blinfun_of_matrix)
immler@61915
   430
immler@61915
   431
lemma
immler@61915
   432
  continuous_blinfun_componentwiseI:
immler@61915
   433
  fixes f:: "'b::t2_space \<Rightarrow> 'a::euclidean_space \<Rightarrow>\<^sub>L 'c::euclidean_space"
immler@61915
   434
  assumes "\<And>i j. i \<in> Basis \<Longrightarrow> j \<in> Basis \<Longrightarrow> continuous F (\<lambda>x. (f x) j \<bullet> i)"
immler@61915
   435
  shows "continuous F f"
immler@61915
   436
  using assms by (auto simp: continuous_def intro!: tendsto_componentwise)
immler@61915
   437
immler@61915
   438
lemma
immler@61915
   439
  continuous_blinfun_componentwiseI1:
immler@61915
   440
  fixes f:: "'b::t2_space \<Rightarrow> 'a::euclidean_space \<Rightarrow>\<^sub>L 'c::real_normed_vector"
immler@61915
   441
  assumes "\<And>i. i \<in> Basis \<Longrightarrow> continuous F (\<lambda>x. f x i)"
immler@61915
   442
  shows "continuous F f"
immler@61915
   443
  using assms by (auto simp: continuous_def intro!: tendsto_componentwise1)
immler@61915
   444
immler@61915
   445
lemma bounded_linear_blinfun_matrix: "bounded_linear (\<lambda>x. (x::_\<Rightarrow>\<^sub>L _) j \<bullet> i)"
immler@61915
   446
  by (auto intro!: bounded_linearI' bounded_linear_intros)
immler@61915
   447
immler@61915
   448
lemma continuous_blinfun_matrix:
immler@61915
   449
  fixes f:: "'b::t2_space \<Rightarrow> 'a::real_normed_vector \<Rightarrow>\<^sub>L 'c::real_inner"
immler@61915
   450
  assumes "continuous F f"
immler@61915
   451
  shows "continuous F (\<lambda>x. (f x) j \<bullet> i)"
immler@61915
   452
  by (rule bounded_linear.continuous[OF bounded_linear_blinfun_matrix assms])
immler@61915
   453
immler@61915
   454
lemma continuous_on_blinfun_matrix:
immler@61915
   455
  fixes f::"'a::t2_space \<Rightarrow> 'b::real_normed_vector \<Rightarrow>\<^sub>L 'c::real_inner"
immler@61915
   456
  assumes "continuous_on S f"
immler@61915
   457
  shows "continuous_on S (\<lambda>x. (f x) j \<bullet> i)"
immler@61915
   458
  using assms
immler@61915
   459
  by (auto simp: continuous_on_eq_continuous_within continuous_blinfun_matrix)
immler@61915
   460
immler@61915
   461
lemma mult_if_delta:
immler@61915
   462
  "(if P then (1::'a::comm_semiring_1) else 0) * q = (if P then q else 0)"
immler@61915
   463
  by auto
immler@61915
   464
immler@61915
   465
text {* TODO: generalize this and @{thm compact_lemma}?! *}
immler@61915
   466
lemma compact_blinfun_lemma:
immler@61915
   467
  fixes f :: "nat \<Rightarrow> 'a::euclidean_space \<Rightarrow>\<^sub>L 'b::euclidean_space"
immler@61915
   468
  assumes "bounded (range f)"
immler@61915
   469
  shows "\<forall>d\<subseteq>Basis. \<exists>l::'a \<Rightarrow>\<^sub>L 'b. \<exists> r.
immler@61915
   470
    subseq r \<and> (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) i) (l i) < e) sequentially)"
immler@61915
   471
proof safe
immler@61915
   472
  fix d :: "'a set"
immler@61915
   473
  assume d: "d \<subseteq> Basis"
immler@61915
   474
  with finite_Basis have "finite d"
immler@61915
   475
    by (blast intro: finite_subset)
immler@61915
   476
  from this d show "\<exists>l::'a \<Rightarrow>\<^sub>L 'b. \<exists>r. subseq r \<and>
immler@61915
   477
    (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) i) (l i) < e) sequentially)"
immler@61915
   478
  proof (induct d)
immler@61915
   479
    case empty
immler@61915
   480
    then show ?case
immler@61915
   481
      unfolding subseq_def by auto
immler@61915
   482
  next
immler@61915
   483
    case (insert k d)
immler@61915
   484
    have k[intro]: "k \<in> Basis"
immler@61915
   485
      using insert by auto
immler@61915
   486
    have s': "bounded ((\<lambda>x. blinfun_apply x k) ` range f)"
immler@61915
   487
      using `bounded (range f)`
immler@61915
   488
      by (auto intro!: bounded_linear_image bounded_linear_intros)
immler@61915
   489
    obtain l1::"'a \<Rightarrow>\<^sub>L 'b" and r1 where r1: "subseq r1"
immler@61915
   490
      and lr1: "\<forall>e > 0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r1 n) i) (l1 i) < e) sequentially"
immler@61915
   491
      using insert(3) using insert(4) by auto
immler@61915
   492
    have f': "\<forall>n. f (r1 n) k \<in> (\<lambda>x. blinfun_apply x k) ` range f"
immler@61915
   493
      by simp
immler@61915
   494
    have "bounded (range (\<lambda>i. f (r1 i) k))"
immler@61915
   495
      by (metis (lifting) bounded_subset f' image_subsetI s')
immler@61915
   496
    then obtain l2 r2
immler@61915
   497
      where r2: "subseq r2"
immler@61915
   498
      and lr2: "((\<lambda>i. f (r1 (r2 i)) k) ---> l2) sequentially"
immler@61915
   499
      using bounded_imp_convergent_subsequence[of "\<lambda>i. f (r1 i) k"]
immler@61915
   500
      by (auto simp: o_def)
immler@61915
   501
    def r \<equiv> "r1 \<circ> r2"
immler@61915
   502
    have r:"subseq r"
immler@61915
   503
      using r1 and r2 unfolding r_def o_def subseq_def by auto
immler@61915
   504
    moreover
immler@61915
   505
    def l \<equiv> "blinfun_of_matrix (\<lambda>i j. if j = k then l2 \<bullet> i else l1 j \<bullet> i)::'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   506
    {
immler@61915
   507
      fix e::real
immler@61915
   508
      assume "e > 0"
immler@61915
   509
      from lr1 `e > 0` have N1: "eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r1 n)  i) (l1  i) < e) sequentially"
immler@61915
   510
        by blast
immler@61915
   511
      from lr2 `e > 0` have N2:"eventually (\<lambda>n. dist (f (r1 (r2 n))  k) l2 < e) sequentially"
immler@61915
   512
        by (rule tendstoD)
immler@61915
   513
      from r2 N1 have N1': "eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r1 (r2 n))  i) (l1  i) < e) sequentially"
immler@61915
   514
        by (rule eventually_subseq)
immler@61915
   515
      have l2: "l k = l2"
immler@61915
   516
        using insert.prems
immler@61915
   517
        by (auto simp: blinfun_of_matrix.rep_eq inner_Basis l_def mult_if_delta
immler@61915
   518
          scaleR_setsum_left[symmetric] setsum.delta' intro!: euclidean_eqI[where 'a='b])
immler@61915
   519
      {
immler@61915
   520
        fix i assume "i \<in> d"
immler@61915
   521
        with insert have "i \<in> Basis" "i \<noteq> k" by auto
immler@61915
   522
        hence l1: "l i = (l1 i)"
immler@61915
   523
          by (auto simp: blinfun_of_matrix.rep_eq inner_Basis l_def mult_if_delta
immler@61915
   524
            scaleR_setsum_left[symmetric] setsum.delta' intro!: euclidean_eqI[where 'a='b])
immler@61915
   525
      } note l1 = this
immler@61915
   526
      have "eventually (\<lambda>n. \<forall>i\<in>(insert k d). dist (f (r n)  i) (l  i) < e) sequentially"
immler@61915
   527
        using N1' N2
immler@61915
   528
        by eventually_elim (insert insert.prems, auto simp: r_def o_def l1 l2)
immler@61915
   529
    }
immler@61915
   530
    ultimately show ?case by auto
immler@61915
   531
  qed
immler@61915
   532
qed
immler@61915
   533
immler@61915
   534
lemma blinfun_euclidean_eqI: "(\<And>i. i \<in> Basis \<Longrightarrow> blinfun_apply x i = blinfun_apply y i) \<Longrightarrow> x = y"
immler@61915
   535
  apply (auto intro!: blinfun_eqI)
immler@61915
   536
  apply (subst (2) euclidean_representation[symmetric, where 'a='a])
immler@61915
   537
  apply (subst (1) euclidean_representation[symmetric, where 'a='a])
immler@61915
   538
  apply (simp add: blinfun.bilinear_simps)
immler@61915
   539
  done
immler@61915
   540
immler@61915
   541
text {* TODO: generalize (via @{thm compact_cball})? *}
immler@61915
   542
instance blinfun :: (euclidean_space, euclidean_space) heine_borel
immler@61915
   543
proof
immler@61915
   544
  fix f :: "nat \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'b"
immler@61915
   545
  assume f: "bounded (range f)"
immler@61915
   546
  then obtain l::"'a \<Rightarrow>\<^sub>L 'b" and r where r: "subseq r"
immler@61915
   547
    and l: "\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>Basis. dist (f (r n) i) (l i) < e) sequentially"
immler@61915
   548
    using compact_blinfun_lemma [OF f] by blast
immler@61915
   549
  {
immler@61915
   550
    fix e::real
immler@61915
   551
    let ?d = "real_of_nat DIM('a) * real_of_nat DIM('b)"
immler@61915
   552
    assume "e > 0"
immler@61915
   553
    hence "e / ?d > 0" by (simp add: DIM_positive)
immler@61915
   554
    with l have "eventually (\<lambda>n. \<forall>i\<in>Basis. dist (f (r n) i) (l i) < e / ?d) sequentially"
immler@61915
   555
      by simp
immler@61915
   556
    moreover
immler@61915
   557
    {
immler@61915
   558
      fix n
immler@61915
   559
      assume n: "\<forall>i\<in>Basis. dist (f (r n) i) (l i) < e / ?d"
immler@61915
   560
      have "norm (f (r n) - l) = norm (blinfun_of_matrix (\<lambda>i j. (f (r n) - l) j \<bullet> i))"
immler@61915
   561
        unfolding blinfun_of_matrix_works ..
immler@61915
   562
      also note norm_blinfun_of_matrix
immler@61915
   563
      also have "(\<Sum>i\<in>Basis. \<Sum>j\<in>Basis. \<bar>(f (r n) - l) j \<bullet> i\<bar>) <
immler@61915
   564
        (\<Sum>i\<in>(Basis::'b set). e / real_of_nat DIM('b))"
immler@61915
   565
      proof (rule setsum_strict_mono)
immler@61915
   566
        fix i::'b assume i: "i \<in> Basis"
immler@61915
   567
        have "(\<Sum>j::'a\<in>Basis. \<bar>(f (r n) - l) j \<bullet> i\<bar>) < (\<Sum>j::'a\<in>Basis. e / ?d)"
immler@61915
   568
        proof (rule setsum_strict_mono)
immler@61915
   569
          fix j::'a assume j: "j \<in> Basis"
immler@61915
   570
          have "\<bar>(f (r n) - l) j \<bullet> i\<bar> \<le> norm ((f (r n) - l) j)"
immler@61915
   571
            by (simp add: Basis_le_norm i)
immler@61915
   572
          also have "\<dots> < e / ?d"
immler@61915
   573
            using n i j by (auto simp: dist_norm blinfun.bilinear_simps)
immler@61915
   574
          finally show "\<bar>(f (r n) - l) j \<bullet> i\<bar> < e / ?d" by simp
immler@61915
   575
        qed simp_all
immler@61915
   576
        also have "\<dots> \<le> e / real_of_nat DIM('b)"
immler@61915
   577
          by simp
immler@61915
   578
        finally show "(\<Sum>j\<in>Basis. \<bar>(f (r n) - l) j \<bullet> i\<bar>) < e / real_of_nat DIM('b)"
immler@61915
   579
          by simp
immler@61915
   580
      qed simp_all
immler@61915
   581
      also have "\<dots> \<le> e" by simp
immler@61915
   582
      finally have "dist (f (r n)) l < e"
immler@61915
   583
        by (auto simp: dist_norm)
immler@61915
   584
    }
immler@61915
   585
    ultimately have "eventually (\<lambda>n. dist (f (r n)) l < e) sequentially"
immler@61915
   586
      using eventually_elim2 by force
immler@61915
   587
  }
immler@61915
   588
  then have *: "((f \<circ> r) ---> l) sequentially"
immler@61915
   589
    unfolding o_def tendsto_iff by simp
immler@61915
   590
  with r show "\<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially"
immler@61915
   591
    by auto
immler@61915
   592
qed
immler@61915
   593
immler@61915
   594
immler@61915
   595
subsection \<open>concrete bounded linear functions\<close>
immler@61915
   596
immler@61916
   597
lemma transfer_bounded_bilinear_bounded_linearI:
immler@61916
   598
  assumes "g = (\<lambda>i x. (blinfun_apply (f i) x))"
immler@61916
   599
  shows "bounded_bilinear g = bounded_linear f"
immler@61916
   600
proof
immler@61916
   601
  assume "bounded_bilinear g"
immler@61916
   602
  then interpret bounded_bilinear f by (simp add: assms)
immler@61916
   603
  show "bounded_linear f"
immler@61916
   604
  proof (unfold_locales, safe intro!: blinfun_eqI)
immler@61916
   605
    fix i
immler@61916
   606
    show "f (x + y) i = (f x + f y) i" "f (r *\<^sub>R x) i = (r *\<^sub>R f x) i" for r x y
immler@61916
   607
      by (auto intro!: blinfun_eqI simp: blinfun.bilinear_simps)
immler@61916
   608
    from _ nonneg_bounded show "\<exists>K. \<forall>x. norm (f x) \<le> norm x * K"
immler@61916
   609
      by (rule ex_reg) (auto intro!: onorm_bound simp: norm_blinfun.rep_eq ac_simps)
immler@61916
   610
  qed
immler@61916
   611
qed (auto simp: assms intro!: blinfun.comp)
immler@61916
   612
immler@61916
   613
lemma transfer_bounded_bilinear_bounded_linear[transfer_rule]:
immler@61916
   614
  "(rel_fun (rel_fun op = (pcr_blinfun op = op =)) op =) bounded_bilinear bounded_linear"
immler@61916
   615
  by (auto simp: pcr_blinfun_def cr_blinfun_def rel_fun_def OO_def
immler@61916
   616
    intro!: transfer_bounded_bilinear_bounded_linearI)
immler@61915
   617
immler@61915
   618
context bounded_bilinear
immler@61915
   619
begin
immler@61915
   620
immler@61915
   621
lift_definition prod_left::"'b \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'c" is "(\<lambda>b a. prod a b)"
immler@61915
   622
  by (rule bounded_linear_left)
immler@61915
   623
declare prod_left.rep_eq[simp]
immler@61915
   624
immler@61915
   625
lemma bounded_linear_prod_left[bounded_linear]: "bounded_linear prod_left"
immler@61916
   626
  by transfer (rule flip)
immler@61915
   627
immler@61915
   628
lift_definition prod_right::"'a \<Rightarrow> 'b \<Rightarrow>\<^sub>L 'c" is "(\<lambda>a b. prod a b)"
immler@61915
   629
  by (rule bounded_linear_right)
immler@61915
   630
declare prod_right.rep_eq[simp]
immler@61915
   631
immler@61915
   632
lemma bounded_linear_prod_right[bounded_linear]: "bounded_linear prod_right"
immler@61916
   633
  by transfer (rule bounded_bilinear_axioms)
immler@61915
   634
immler@61915
   635
end
immler@61915
   636
immler@61915
   637
lift_definition id_blinfun::"'a::real_normed_vector \<Rightarrow>\<^sub>L 'a" is "\<lambda>x. x"
immler@61915
   638
  by (rule bounded_linear_ident)
immler@61915
   639
immler@61915
   640
lemmas blinfun_apply_id_blinfun[simp] = id_blinfun.rep_eq
immler@61915
   641
immler@61915
   642
lemma norm_blinfun_id[simp]:
immler@61915
   643
  "norm (id_blinfun::'a::{real_normed_vector, perfect_space} \<Rightarrow>\<^sub>L 'a) = 1"
immler@61915
   644
  by transfer (auto simp: onorm_id)
immler@61915
   645
immler@61915
   646
lemma norm_blinfun_id_le:
immler@61915
   647
  "norm (id_blinfun::'a::real_normed_vector \<Rightarrow>\<^sub>L 'a) \<le> 1"
immler@61915
   648
  by transfer (auto simp: onorm_id_le)
immler@61915
   649
immler@61915
   650
immler@61915
   651
lift_definition fst_blinfun::"('a::real_normed_vector \<times> 'b::real_normed_vector) \<Rightarrow>\<^sub>L 'a" is fst
immler@61915
   652
  by (rule bounded_linear_fst)
immler@61915
   653
immler@61915
   654
lemma blinfun_apply_fst_blinfun[simp]: "blinfun_apply fst_blinfun = fst"
immler@61915
   655
  by transfer (rule refl)
immler@61915
   656
immler@61915
   657
immler@61915
   658
lift_definition snd_blinfun::"('a::real_normed_vector \<times> 'b::real_normed_vector) \<Rightarrow>\<^sub>L 'b" is snd
immler@61915
   659
  by (rule bounded_linear_snd)
immler@61915
   660
immler@61915
   661
lemma blinfun_apply_snd_blinfun[simp]: "blinfun_apply snd_blinfun = snd"
immler@61915
   662
  by transfer (rule refl)
immler@61915
   663
immler@61915
   664
immler@61915
   665
lift_definition blinfun_compose::
immler@61915
   666
  "'a::real_normed_vector \<Rightarrow>\<^sub>L 'b::real_normed_vector \<Rightarrow>
immler@61915
   667
    'c::real_normed_vector \<Rightarrow>\<^sub>L 'a \<Rightarrow>
immler@61915
   668
    'c \<Rightarrow>\<^sub>L 'b" (infixl "o\<^sub>L" 55) is "op o"
immler@61915
   669
  parametric comp_transfer
immler@61915
   670
  unfolding o_def
immler@61915
   671
  by (rule bounded_linear_compose)
immler@61915
   672
immler@61915
   673
lemma blinfun_apply_blinfun_compose[simp]: "(a o\<^sub>L b) c = a (b c)"
immler@61915
   674
  by (simp add: blinfun_compose.rep_eq)
immler@61915
   675
immler@61915
   676
lemma norm_blinfun_compose:
immler@61915
   677
  "norm (f o\<^sub>L g) \<le> norm f * norm g"
immler@61915
   678
  by transfer (rule onorm_compose)
immler@61915
   679
immler@61915
   680
lemma bounded_bilinear_blinfun_compose[bounded_bilinear]: "bounded_bilinear op o\<^sub>L"
immler@61915
   681
  by unfold_locales
immler@61915
   682
    (auto intro!: blinfun_eqI exI[where x=1] simp: blinfun.bilinear_simps norm_blinfun_compose)
immler@61915
   683
immler@61915
   684
immler@61915
   685
lift_definition blinfun_inner_right::"'a::real_inner \<Rightarrow> 'a \<Rightarrow>\<^sub>L real" is "op \<bullet>"
immler@61915
   686
  by (rule bounded_linear_inner_right)
immler@61915
   687
declare blinfun_inner_right.rep_eq[simp]
immler@61915
   688
immler@61915
   689
lemma bounded_linear_blinfun_inner_right[bounded_linear]: "bounded_linear blinfun_inner_right"
immler@61916
   690
  by transfer (rule bounded_bilinear_inner)
immler@61915
   691
immler@61915
   692
immler@61915
   693
lift_definition blinfun_inner_left::"'a::real_inner \<Rightarrow> 'a \<Rightarrow>\<^sub>L real" is "\<lambda>x y. y \<bullet> x"
immler@61915
   694
  by (rule bounded_linear_inner_left)
immler@61915
   695
declare blinfun_inner_left.rep_eq[simp]
immler@61915
   696
immler@61915
   697
lemma bounded_linear_blinfun_inner_left[bounded_linear]: "bounded_linear blinfun_inner_left"
immler@61916
   698
  by transfer (rule bounded_bilinear.flip[OF bounded_bilinear_inner])
immler@61915
   699
immler@61915
   700
immler@61915
   701
lift_definition blinfun_scaleR_right::"real \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'a::real_normed_vector" is "op *\<^sub>R"
immler@61915
   702
  by (rule bounded_linear_scaleR_right)
immler@61915
   703
declare blinfun_scaleR_right.rep_eq[simp]
immler@61915
   704
immler@61915
   705
lemma bounded_linear_blinfun_scaleR_right[bounded_linear]: "bounded_linear blinfun_scaleR_right"
immler@61916
   706
  by transfer (rule bounded_bilinear_scaleR)
immler@61915
   707
immler@61915
   708
immler@61915
   709
lift_definition blinfun_scaleR_left::"'a::real_normed_vector \<Rightarrow> real \<Rightarrow>\<^sub>L 'a" is "\<lambda>x y. y *\<^sub>R x"
immler@61915
   710
  by (rule bounded_linear_scaleR_left)
immler@61915
   711
lemmas [simp] = blinfun_scaleR_left.rep_eq
immler@61915
   712
immler@61915
   713
lemma bounded_linear_blinfun_scaleR_left[bounded_linear]: "bounded_linear blinfun_scaleR_left"
immler@61916
   714
  by transfer (rule bounded_bilinear.flip[OF bounded_bilinear_scaleR])
immler@61915
   715
immler@61915
   716
immler@61915
   717
lift_definition blinfun_mult_right::"'a \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'a::real_normed_algebra" is "op *"
immler@61915
   718
  by (rule bounded_linear_mult_right)
immler@61915
   719
declare blinfun_mult_right.rep_eq[simp]
immler@61915
   720
immler@61915
   721
lemma bounded_linear_blinfun_mult_right[bounded_linear]: "bounded_linear blinfun_mult_right"
immler@61916
   722
  by transfer (rule bounded_bilinear_mult)
immler@61915
   723
immler@61915
   724
immler@61915
   725
lift_definition blinfun_mult_left::"'a::real_normed_algebra \<Rightarrow> 'a \<Rightarrow>\<^sub>L 'a" is "\<lambda>x y. y * x"
immler@61915
   726
  by (rule bounded_linear_mult_left)
immler@61915
   727
lemmas [simp] = blinfun_mult_left.rep_eq
immler@61915
   728
immler@61915
   729
lemma bounded_linear_blinfun_mult_left[bounded_linear]: "bounded_linear blinfun_mult_left"
immler@61916
   730
  by transfer (rule bounded_bilinear.flip[OF bounded_bilinear_mult])
immler@61915
   731
immler@61915
   732
end