src/HOL/Analysis/L2_Norm.thy
author immler
Thu, 22 Feb 2018 15:17:25 +0100
changeset 67685 bdff8bf0a75b
parent 67156 3a9966b88a50
child 68465 e699ca8e22b7
permissions -rw-r--r--
moved theorems from AFP/Affine_Arithmetic and AFP/Ordinary_Differential_Equations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63627
6ddb43c6b711 rename HOL-Multivariate_Analysis to HOL-Analysis.
hoelzl
parents: 60974
diff changeset
     1
(*  Title:      HOL/Analysis/L2_Norm.thy
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman, Portland State University
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
     3
*)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
     4
67143
db609ac2c307 initial version of Analysis document
nipkow
parents: 67006
diff changeset
     5
section \<open>L2 Norm\<close>
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
     6
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
     7
theory L2_Norm
67006
b1278ed3cd46 prefer main entry points of HOL;
wenzelm
parents: 66453
diff changeset
     8
imports Complex_Main
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
     9
begin
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    10
67156
3a9966b88a50 "important" annotations
nipkow
parents: 67155
diff changeset
    11
definition %important "L2_set f A = sqrt (\<Sum>i\<in>A. (f i)\<^sup>2)"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    12
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    13
lemma L2_set_cong:
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    14
  "\<lbrakk>A = B; \<And>x. x \<in> B \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> L2_set f A = L2_set g B"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    15
  unfolding L2_set_def by simp
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    16
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    17
lemma strong_L2_set_cong:
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    18
  "\<lbrakk>A = B; \<And>x. x \<in> B =simp=> f x = g x\<rbrakk> \<Longrightarrow> L2_set f A = L2_set g B"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    19
  unfolding L2_set_def simp_implies_def by simp
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    20
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    21
lemma L2_set_infinite [simp]: "\<not> finite A \<Longrightarrow> L2_set f A = 0"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    22
  unfolding L2_set_def by simp
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    23
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    24
lemma L2_set_empty [simp]: "L2_set f {} = 0"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    25
  unfolding L2_set_def by simp
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    26
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    27
lemma L2_set_insert [simp]:
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    28
  "\<lbrakk>finite F; a \<notin> F\<rbrakk> \<Longrightarrow>
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    29
    L2_set f (insert a F) = sqrt ((f a)\<^sup>2 + (L2_set f F)\<^sup>2)"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    30
  unfolding L2_set_def by (simp add: sum_nonneg)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    31
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    32
lemma L2_set_nonneg [simp]: "0 \<le> L2_set f A"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    33
  unfolding L2_set_def by (simp add: sum_nonneg)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    34
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    35
lemma L2_set_0': "\<forall>a\<in>A. f a = 0 \<Longrightarrow> L2_set f A = 0"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    36
  unfolding L2_set_def by simp
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    37
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    38
lemma L2_set_constant: "L2_set (\<lambda>x. y) A = sqrt (of_nat (card A)) * \<bar>y\<bar>"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    39
  unfolding L2_set_def by (simp add: real_sqrt_mult)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    40
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    41
lemma L2_set_mono:
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    42
  assumes "\<And>i. i \<in> K \<Longrightarrow> f i \<le> g i"
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    43
  assumes "\<And>i. i \<in> K \<Longrightarrow> 0 \<le> f i"
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    44
  shows "L2_set f K \<le> L2_set g K"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    45
  unfolding L2_set_def
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
    46
  by (simp add: sum_nonneg sum_mono power_mono assms)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    47
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    48
lemma L2_set_strict_mono:
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    49
  assumes "finite K" and "K \<noteq> {}"
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    50
  assumes "\<And>i. i \<in> K \<Longrightarrow> f i < g i"
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    51
  assumes "\<And>i. i \<in> K \<Longrightarrow> 0 \<le> f i"
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    52
  shows "L2_set f K < L2_set g K"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    53
  unfolding L2_set_def
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
    54
  by (simp add: sum_strict_mono power_strict_mono assms)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    55
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    56
lemma L2_set_right_distrib:
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    57
  "0 \<le> r \<Longrightarrow> r * L2_set f A = L2_set (\<lambda>x. r * f x) A"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    58
  unfolding L2_set_def
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    59
  apply (simp add: power_mult_distrib)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
    60
  apply (simp add: sum_distrib_left [symmetric])
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
    61
  apply (simp add: real_sqrt_mult sum_nonneg)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    62
  done
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    63
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    64
lemma L2_set_left_distrib:
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    65
  "0 \<le> r \<Longrightarrow> L2_set f A * r = L2_set (\<lambda>x. f x * r) A"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    66
  unfolding L2_set_def
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    67
  apply (simp add: power_mult_distrib)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
    68
  apply (simp add: sum_distrib_right [symmetric])
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
    69
  apply (simp add: real_sqrt_mult sum_nonneg)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    70
  done
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    71
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    72
lemma L2_set_eq_0_iff: "finite A \<Longrightarrow> L2_set f A = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    73
  unfolding L2_set_def
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
    74
  by (simp add: sum_nonneg sum_nonneg_eq_0_iff)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    75
67156
3a9966b88a50 "important" annotations
nipkow
parents: 67155
diff changeset
    76
lemma %important L2_set_triangle_ineq:
3a9966b88a50 "important" annotations
nipkow
parents: 67155
diff changeset
    77
  "L2_set (\<lambda>i. f i + g i) A \<le> L2_set f A + L2_set g A"
3a9966b88a50 "important" annotations
nipkow
parents: 67155
diff changeset
    78
proof %unimportant (cases "finite A")
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    79
  case False
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    80
  thus ?thesis by simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    81
next
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    82
  case True
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    83
  thus ?thesis
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    84
  proof (induct set: finite)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    85
    case empty
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    86
    show ?case by simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    87
  next
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    88
    case (insert x F)
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    89
    hence "sqrt ((f x + g x)\<^sup>2 + (L2_set (\<lambda>i. f i + g i) F)\<^sup>2) \<le>
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    90
           sqrt ((f x + g x)\<^sup>2 + (L2_set f F + L2_set g F)\<^sup>2)"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    91
      by (intro real_sqrt_le_mono add_left_mono power_mono insert
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    92
                L2_set_nonneg add_increasing zero_le_power2)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    93
    also have
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
    94
      "\<dots> \<le> sqrt ((f x)\<^sup>2 + (L2_set f F)\<^sup>2) + sqrt ((g x)\<^sup>2 + (L2_set g F)\<^sup>2)"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    95
      by (rule real_sqrt_sum_squares_triangle_ineq)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    96
    finally show ?case
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    97
      using insert by simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    98
  qed
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
    99
qed
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   100
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
   101
lemma L2_set_le_sum [rule_format]:
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
   102
  "(\<forall>i\<in>A. 0 \<le> f i) \<longrightarrow> L2_set f A \<le> sum f A"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   103
  apply (cases "finite A")
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   104
  apply (induct set: finite)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   105
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   106
  apply clarsimp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   107
  apply (erule order_trans [OF sqrt_sum_squares_le_sum])
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   108
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   109
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   110
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   111
  done
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   112
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49962
diff changeset
   113
lemma sqrt_sum_squares_le_sum_abs: "sqrt (x\<^sup>2 + y\<^sup>2) \<le> \<bar>x\<bar> + \<bar>y\<bar>"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   114
  apply (rule power2_le_imp_le)
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 53015
diff changeset
   115
  apply (simp add: power2_sum)
44142
8e27e0177518 avoid warnings about duplicate rules
huffman
parents: 41959
diff changeset
   116
  apply simp
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   117
  done
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   118
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
   119
lemma L2_set_le_sum_abs: "L2_set f A \<le> (\<Sum>i\<in>A. \<bar>f i\<bar>)"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   120
  apply (cases "finite A")
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   121
  apply (induct set: finite)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   122
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   123
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   124
  apply (rule order_trans [OF sqrt_sum_squares_le_sum_abs])
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   125
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   126
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   127
  done
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   128
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
   129
lemma L2_set_mult_ineq_lemma:
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   130
  fixes a b c d :: real
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49962
diff changeset
   131
  shows "2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   132
proof -
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49962
diff changeset
   133
  have "0 \<le> (a * d - b * c)\<^sup>2" by simp
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49962
diff changeset
   134
  also have "\<dots> = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * d) * (b * c)"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   135
    by (simp only: power2_diff power_mult_distrib)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49962
diff changeset
   136
  also have "\<dots> = a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2 - 2 * (a * c) * (b * d)"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   137
    by simp
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49962
diff changeset
   138
  finally show "2 * (a * c) * (b * d) \<le> a\<^sup>2 * d\<^sup>2 + b\<^sup>2 * c\<^sup>2"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   139
    by simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   140
qed
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   141
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
   142
lemma L2_set_mult_ineq: "(\<Sum>i\<in>A. \<bar>f i\<bar> * \<bar>g i\<bar>) \<le> L2_set f A * L2_set g A"
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   143
  apply (cases "finite A")
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   144
  apply (induct set: finite)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   145
  apply simp
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   146
  apply (rule power2_le_imp_le, simp)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   147
  apply (rule order_trans)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   148
  apply (rule power_mono)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   149
  apply (erule add_left_mono)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
   150
  apply (simp add: sum_nonneg)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   151
  apply (simp add: power2_sum)
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   152
  apply (simp add: power_mult_distrib)
49962
a8cc904a6820 Renamed {left,right}_distrib to distrib_{right,left}.
webertj
parents: 44142
diff changeset
   153
  apply (simp add: distrib_left distrib_right)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   154
  apply (rule ord_le_eq_trans)
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
   155
  apply (rule L2_set_mult_ineq_lemma)
56536
aefb4a8da31f made mult_nonneg_nonneg a simp rule
nipkow
parents: 53015
diff changeset
   156
  apply simp_all
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   157
  done
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   158
67155
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
   159
lemma member_le_L2_set: "\<lbrakk>finite A; i \<in> A\<rbrakk> \<Longrightarrow> f i \<le> L2_set f A"
9e5b05d54f9d canonical name
nipkow
parents: 67144
diff changeset
   160
  unfolding L2_set_def
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63938
diff changeset
   161
  by (auto intro!: member_le_sum real_le_rsqrt)
36333
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   162
82356c9e218a move l2-norm stuff into separate theory file
huffman
parents:
diff changeset
   163
end