src/HOL/Multivariate_Analysis/Integration.thy
author wenzelm
Tue, 03 Sep 2013 01:12:40 +0200
changeset 53374 a14d2a854c02
parent 53015 a1119cf551e8
child 53399 43b3b3fa6967
permissions -rw-r--r--
tuned proofs -- clarified flow of facts wrt. calculation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
     1
header {* Kurzweil-Henstock Gauge Integration in many dimensions. *}
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
     2
(*  Author:                     John Harrison
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
     3
    Translation from HOL light: Robert Himmelmann, TU Muenchen *)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
     4
35292
e4a431b6d9b7 Replaced Integration by Multivariate-Analysis/Real_Integration
hoelzl
parents: 35291
diff changeset
     5
theory Integration
41413
64cd30d6b0b8 explicit file specifications -- avoid secondary load path;
wenzelm
parents: 40513
diff changeset
     6
imports
64cd30d6b0b8 explicit file specifications -- avoid secondary load path;
wenzelm
parents: 40513
diff changeset
     7
  Derivative
64cd30d6b0b8 explicit file specifications -- avoid secondary load path;
wenzelm
parents: 40513
diff changeset
     8
  "~~/src/HOL/Library/Indicator_Function"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
     9
begin
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
    10
51518
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    11
lemma cSup_abs_le: (* TODO: is this really needed? *)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    12
  fixes S :: "real set"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    13
  shows "S \<noteq> {} \<Longrightarrow> (\<forall>x\<in>S. \<bar>x\<bar> \<le> a) \<Longrightarrow> \<bar>Sup S\<bar> \<le> a"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    14
by (auto simp add: abs_le_interval_iff intro: cSup_least) (metis cSup_upper2) 
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    15
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    16
lemma cInf_abs_ge: (* TODO: is this really needed? *)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    17
  fixes S :: "real set"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    18
  shows "S \<noteq> {} \<Longrightarrow> (\<forall>x\<in>S. \<bar>x\<bar> \<le> a) \<Longrightarrow> \<bar>Inf S\<bar> \<le> a"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    19
by (simp add: Inf_real_def) (rule cSup_abs_le, auto) 
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    20
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    21
lemma cSup_asclose: (* TODO: is this really needed? *)
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    22
  fixes S :: "real set"
51518
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    23
  assumes S:"S \<noteq> {}" and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e" shows "\<bar>Sup S - l\<bar> \<le> e"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    24
proof-
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    25
  have th: "\<And>(x::real) l e. \<bar>x - l\<bar> \<le> e \<longleftrightarrow> l - e \<le> x \<and> x \<le> l + e" by arith
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    26
  thus ?thesis using S b cSup_bounds[of S "l - e" "l+e"] unfolding th
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    27
    by  (auto simp add: setge_def setle_def)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    28
qed
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    29
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    30
lemma cInf_asclose: (* TODO: is this really needed? *)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    31
  fixes S :: "real set"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    32
  assumes S:"S \<noteq> {}" and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e" shows "\<bar>Inf S - l\<bar> \<le> e"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    33
proof -
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    34
  have "\<bar>- Sup (uminus ` S) - l\<bar> =  \<bar>Sup (uminus ` S) - (-l)\<bar>"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    35
    by auto
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    36
  also have "... \<le> e" 
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    37
    apply (rule cSup_asclose) 
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    38
    apply (auto simp add: S)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    39
    apply (metis abs_minus_add_cancel b add_commute diff_minus)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    40
    done
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    41
  finally have "\<bar>- Sup (uminus ` S) - l\<bar> \<le> e" .
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    42
  thus ?thesis
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    43
    by (simp add: Inf_real_def)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    44
qed
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    45
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    46
lemma cSup_finite_ge_iff: 
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    47
  fixes S :: "real set" shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<le> Sup S \<longleftrightarrow> (\<exists>x\<in>S. a \<le> x)"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    48
  by (metis cSup_eq_Max Max_ge_iff)
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    49
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    50
lemma cSup_finite_le_iff: 
51518
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    51
  fixes S :: "real set" shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<ge> Sup S \<longleftrightarrow> (\<forall>x\<in>S. a \<ge> x)"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    52
  by (metis cSup_eq_Max Max_le_iff)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    53
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    54
lemma cInf_finite_ge_iff: 
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    55
  fixes S :: "real set" shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<le> Inf S \<longleftrightarrow> (\<forall>x\<in>S. a \<le> x)"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    56
  by (metis cInf_eq_Min Min_ge_iff)
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    57
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    58
lemma cInf_finite_le_iff: 
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    59
  fixes S :: "real set" shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<ge> Inf S \<longleftrightarrow> (\<exists>x\<in>S. a \<ge> x)"
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
    60
  by (metis cInf_eq_Min Min_le_iff)
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    61
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    62
lemma Inf: (* rename *)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    63
  fixes S :: "real set"
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    64
  shows "S \<noteq> {} ==> (\<exists>b. b <=* S) ==> isGlb UNIV S (Inf S)"
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    65
by (auto simp add: isLb_def setle_def setge_def isGlb_def greatestP_def intro: cInf_lower cInf_greatest) 
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    66
 
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    67
lemma real_le_inf_subset:
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    68
  assumes "t \<noteq> {}" "t \<subseteq> s" "\<exists>b. b <=* s"
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    69
  shows "Inf s <= Inf (t::real set)"
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    70
  apply (rule isGlb_le_isLb)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    71
  apply (rule Inf[OF assms(1)])
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    72
  apply (insert assms)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    73
  apply (erule exE)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    74
  apply (rule_tac x = b in exI)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    75
  apply (auto simp: isLb_def setge_def intro: cInf_lower cInf_greatest)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    76
  done
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    77
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    78
lemma real_ge_sup_subset:
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    79
  assumes "t \<noteq> {}" "t \<subseteq> s" "\<exists>b. s *<= b"
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    80
  shows "Sup s >= Sup (t::real set)"
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    81
  apply (rule isLub_le_isUb)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    82
  apply (rule isLub_cSup[OF assms(1)])
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    83
  apply (insert assms)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    84
  apply (erule exE)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    85
  apply (rule_tac x = b in exI)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    86
  apply (auto simp: isUb_def setle_def intro: cSup_upper cSup_least)
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    87
  done
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
    88
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
    89
(*declare not_less[simp] not_le[simp]*)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
    90
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
    91
lemmas scaleR_simps = scaleR_zero_left scaleR_minus_left scaleR_left_diff_distrib
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
    92
  scaleR_zero_right scaleR_minus_right scaleR_right_diff_distrib scaleR_eq_0_iff
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
    93
  scaleR_cancel_left scaleR_cancel_right scaleR_add_right scaleR_add_left real_vector_class.scaleR_one
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
    94
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
    95
lemma real_arch_invD:
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
    96
  "0 < (e::real) \<Longrightarrow> (\<exists>n::nat. n \<noteq> 0 \<and> 0 < inverse (real n) \<and> inverse (real n) < e)"
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
    97
  by (subst(asm) real_arch_inv)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
    98
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
    99
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   100
subsection {* Sundries *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   101
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   102
lemma conjunctD2: assumes "a \<and> b" shows a b using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   103
lemma conjunctD3: assumes "a \<and> b \<and> c" shows a b c using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   104
lemma conjunctD4: assumes "a \<and> b \<and> c \<and> d" shows a b c d using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   105
lemma conjunctD5: assumes "a \<and> b \<and> c \<and> d \<and> e" shows a b c d e using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   106
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
   107
declare norm_triangle_ineq4[intro] 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   108
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   109
lemma simple_image: "{f x |x . x \<in> s} = f ` s" by blast
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   110
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   111
lemma linear_simps:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   112
  assumes "bounded_linear f"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   113
  shows
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   114
    "f (a + b) = f a + f b"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   115
    "f (a - b) = f a - f b"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   116
    "f 0 = 0"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   117
    "f (- a) = - f a"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   118
    "f (s *\<^sub>R v) = s *\<^sub>R (f v)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   119
  apply (rule_tac[!] additive.add additive.minus additive.diff additive.zero bounded_linear.scaleR)
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   120
  using assms unfolding bounded_linear_def additive_def
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   121
  apply auto
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   122
  done
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   123
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   124
lemma bounded_linearI:
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   125
  assumes "\<And>x y. f (x + y) = f x + f y"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   126
    and "\<And>r x. f (r *\<^sub>R x) = r *\<^sub>R f x" "\<And>x. norm (f x) \<le> norm x * K"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   127
  shows "bounded_linear f"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   128
  unfolding bounded_linear_def additive_def bounded_linear_axioms_def using assms by auto
51348
011c97ba3b3d move lemma Inf to usage point
hoelzl
parents: 50945
diff changeset
   129
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   130
lemma bounded_linear_component [intro]: "bounded_linear (\<lambda>x::'a::euclidean_space. x \<bullet> k)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   131
  by (rule bounded_linear_inner_left)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   132
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   133
lemma transitive_stepwise_lt_eq:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   134
  assumes "(\<And>x y z::nat. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   135
  shows "((\<forall>m. \<forall>n>m. R m n) \<longleftrightarrow> (\<forall>n. R n (Suc n)))" (is "?l = ?r")
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   136
proof (safe)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   137
  assume ?r
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   138
  fix n m :: nat
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   139
  assume "m < n"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   140
  then show "R m n"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   141
  proof (induct n arbitrary: m)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   142
    case (Suc n)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   143
    show ?case 
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   144
    proof (cases "m < n")
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   145
      case True
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   146
      show ?thesis
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   147
        apply (rule assms[OF Suc(1)[OF True]])
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   148
        using `?r`
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   149
        apply auto
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   150
        done
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   151
    next
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   152
      case False
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   153
      then have "m = n" using Suc(2) by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   154
      then show ?thesis using `?r` by auto
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   155
    qed
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   156
  qed auto
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   157
qed auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   158
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   159
lemma transitive_stepwise_gt:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   160
  assumes "\<And>x y z. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z" "\<And>n. R n (Suc n) "
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   161
  shows "\<forall>n>m. R m n"
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   162
proof -
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   163
  have "\<forall>m. \<forall>n>m. R m n"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   164
    apply (subst transitive_stepwise_lt_eq)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   165
    apply (rule assms)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   166
    apply assumption
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   167
    apply assumption
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   168
    using assms(2) apply auto
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   169
    done
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   170
  then show ?thesis by auto
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   171
qed
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   172
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   173
lemma transitive_stepwise_le_eq:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   174
  assumes "\<And>x. R x x" "\<And>x y z. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   175
  shows "(\<forall>m. \<forall>n\<ge>m. R m n) \<longleftrightarrow> (\<forall>n. R n (Suc n))" (is "?l = ?r")
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   176
proof safe
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   177
  assume ?r
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   178
  fix m n :: nat
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   179
  assume "m \<le> n"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   180
  thus "R m n"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   181
  proof (induct n arbitrary: m)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   182
    case 0
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   183
    with assms show ?case by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   184
  next
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   185
    case (Suc n)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   186
    show ?case
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   187
    proof (cases "m \<le> n")
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   188
      case True
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   189
      show ?thesis
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   190
        apply (rule assms(2))
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   191
        apply (rule Suc(1)[OF True])
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   192
        using `?r` apply auto
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   193
        done
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   194
    next
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   195
      case False
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   196
      hence "m = Suc n" using Suc(2) by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   197
      thus ?thesis using assms(1) by auto
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   198
    qed
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   199
  qed
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   200
qed auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   201
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   202
lemma transitive_stepwise_le:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   203
  assumes "\<And>x. R x x" "\<And>x y z. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z" "\<And>n. R n (Suc n) "
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   204
  shows "\<forall>n\<ge>m. R m n"
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   205
proof -
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   206
  have "\<forall>m. \<forall>n\<ge>m. R m n"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   207
    apply (subst transitive_stepwise_le_eq)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   208
    apply (rule assms)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   209
    apply (rule assms,assumption,assumption)
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   210
    using assms(3) apply auto
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   211
    done
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   212
  then show ?thesis by auto
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   213
qed
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   214
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
   215
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   216
subsection {* Some useful lemmas about intervals. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   217
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   218
abbreviation One where "One \<equiv> ((\<Sum>Basis)::_::euclidean_space)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   219
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   220
lemma empty_as_interval: "{} = {One..(0::'a::ordered_euclidean_space)}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   221
  by (auto simp: set_eq_iff eucl_le[where 'a='a] intro!: bexI[OF _ SOME_Basis])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   222
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   223
lemma interior_subset_union_intervals: 
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   224
  assumes "i = {a..b::'a::ordered_euclidean_space}" "j = {c..d}"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   225
    "interior j \<noteq> {}" "i \<subseteq> j \<union> s" "interior(i) \<inter> interior(j) = {}"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   226
  shows "interior i \<subseteq> interior s"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   227
proof -
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   228
  have "{a<..<b} \<inter> {c..d} = {}"
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   229
    using inter_interval_mixed_eq_empty[of c d a b] and assms(3,5)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   230
    unfolding assms(1,2) interior_closed_interval by auto
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   231
  moreover
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   232
  have "{a<..<b} \<subseteq> {c..d} \<union> s"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   233
    apply (rule order_trans,rule interval_open_subset_closed)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   234
    using assms(4) unfolding assms(1,2)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   235
    apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   236
    done
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   237
  ultimately
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   238
  show ?thesis
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   239
    apply -
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   240
    apply (rule interior_maximal)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   241
    defer
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   242
    apply (rule open_interior)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   243
    unfolding assms(1,2) interior_closed_interval
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   244
    apply auto
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   245
    done
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   246
qed
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   247
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   248
lemma inter_interior_unions_intervals:
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   249
  fixes f::"('a::ordered_euclidean_space) set set"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   250
  assumes "finite f" "open s" "\<forall>t\<in>f. \<exists>a b. t = {a..b}" "\<forall>t\<in>f. s \<inter> (interior t) = {}"
49675
d9c2fb37d92a tuned proofs;
wenzelm
parents: 49197
diff changeset
   251
  shows "s \<inter> interior(\<Union>f) = {}"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   252
proof (rule ccontr, unfold ex_in_conv[THEN sym])
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   253
  case goal1
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   254
  have lem1: "\<And>x e s U. ball x e \<subseteq> s \<inter> interior U \<longleftrightarrow> ball x e \<subseteq> s \<inter> U"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   255
    apply rule
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   256
    defer
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   257
    apply (rule_tac Int_greatest)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   258
    unfolding open_subset_interior[OF open_ball]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   259
    using interior_subset
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   260
    apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   261
    done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   262
  have lem2: "\<And>x s P. \<exists>x\<in>s. P x \<Longrightarrow> \<exists>x\<in>insert x s. P x" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   263
  have "\<And>f. finite f \<Longrightarrow> (\<forall>t\<in>f. \<exists>a b. t = {a..b}) \<Longrightarrow>
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   264
    (\<exists>x. x \<in> s \<inter> interior (\<Union>f)) \<Longrightarrow> (\<exists>t\<in>f. \<exists>x. \<exists>e>0. ball x e \<subseteq> s \<inter> t)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   265
  proof -
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   266
    case goal1
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   267
    then show ?case
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   268
    proof (induct rule: finite_induct)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   269
      case empty from this(2) guess x ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   270
      hence False unfolding Union_empty interior_empty by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   271
      thus ?case by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   272
    next
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   273
      case (insert i f) guess x using insert(5) .. note x = this
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   274
      then guess e unfolding open_contains_ball_eq[OF open_Int[OF assms(2) open_interior],rule_format] .. note e=this
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   275
      guess a using insert(4)[rule_format,OF insertI1] ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   276
      then guess b .. note ab = this
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   277
      show ?case
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   278
      proof (cases "x\<in>i")
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   279
        case False
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   280
        hence "x \<in> UNIV - {a..b}" unfolding ab by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   281
        then guess d unfolding open_contains_ball_eq[OF open_Diff[OF open_UNIV closed_interval],rule_format] ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   282
        hence "0 < d" "ball x (min d e) \<subseteq> UNIV - i" unfolding ab ball_min_Int by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   283
        hence "ball x (min d e) \<subseteq> s \<inter> interior (\<Union>f)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   284
          using e unfolding lem1 unfolding  ball_min_Int by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   285
        hence "x \<in> s \<inter> interior (\<Union>f)" using `d>0` e by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   286
        hence "\<exists>t\<in>f. \<exists>x e. 0 < e \<and> ball x e \<subseteq> s \<inter> t"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   287
          apply -
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   288
          apply (rule insert(3))
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   289
          using insert(4)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   290
          apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   291
          done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   292
        thus ?thesis by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   293
      next
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   294
        case True show ?thesis
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   295
        proof (cases "x\<in>{a<..<b}")
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   296
          case True
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   297
          then guess d unfolding open_contains_ball_eq[OF open_interval,rule_format] ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   298
          thus ?thesis
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   299
            apply (rule_tac x=i in bexI, rule_tac x=x in exI, rule_tac x="min d e" in exI)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   300
            unfolding ab
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   301
            using interval_open_subset_closed[of a b] and e
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   302
            apply fastforce+
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   303
            done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   304
        next
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   305
          case False
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   306
          then obtain k where "x\<bullet>k \<le> a\<bullet>k \<or> x\<bullet>k \<ge> b\<bullet>k" and k:"k\<in>Basis"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   307
            unfolding mem_interval by (auto simp add: not_less)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   308
          hence "x\<bullet>k = a\<bullet>k \<or> x\<bullet>k = b\<bullet>k"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   309
            using True unfolding ab and mem_interval
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   310
              apply (erule_tac x = k in ballE)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   311
              apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   312
              done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   313
          hence "\<exists>x. ball x (e/2) \<subseteq> s \<inter> (\<Union>f)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   314
          proof (erule_tac disjE)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   315
            let ?z = "x - (e/2) *\<^sub>R k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   316
            assume as: "x\<bullet>k = a\<bullet>k"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   317
            have "ball ?z (e / 2) \<inter> i = {}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   318
              apply (rule ccontr)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   319
              unfolding ex_in_conv[THEN sym]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   320
            proof (erule exE)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   321
              fix y
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   322
              assume "y \<in> ball ?z (e / 2) \<inter> i"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   323
              hence "dist ?z y < e/2" and yi:"y\<in>i" by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   324
              hence "\<bar>(?z - y) \<bullet> k\<bar> < e/2"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   325
                using Basis_le_norm[OF k, of "?z - y"] unfolding dist_norm by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   326
              hence "y\<bullet>k < a\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   327
                using e[THEN conjunct1] k by (auto simp add: field_simps as inner_Basis inner_simps)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   328
              hence "y \<notin> i"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   329
                unfolding ab mem_interval by (auto intro!: bexI[OF _ k])
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   330
              thus False using yi by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   331
            qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   332
            moreover
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   333
            have "ball ?z (e/2) \<subseteq> s \<inter> (\<Union>insert i f)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   334
              apply(rule order_trans[OF _ e[THEN conjunct2, unfolded lem1]])
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   335
            proof
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   336
              fix y
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   337
              assume as: "y\<in> ball ?z (e/2)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   338
              have "norm (x - y) \<le> \<bar>e\<bar> / 2 + norm (x - y - (e / 2) *\<^sub>R k)"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   339
                apply -
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   340
                apply (rule order_trans,rule norm_triangle_sub[of "x - y" "(e/2) *\<^sub>R k"])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   341
                unfolding norm_scaleR norm_Basis[OF k]
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   342
                apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   343
                done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   344
              also have "\<dots> < \<bar>e\<bar> / 2 + \<bar>e\<bar> / 2"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   345
                apply (rule add_strict_left_mono)
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   346
                using as
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   347
                unfolding mem_ball dist_norm
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   348
                using e
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   349
                apply (auto simp add: field_simps)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   350
                done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   351
              finally show "y\<in>ball x e"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   352
                unfolding mem_ball dist_norm using e by (auto simp add:field_simps)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   353
            qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   354
            ultimately show ?thesis
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   355
              apply (rule_tac x="?z" in exI)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   356
              unfolding Union_insert
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   357
              apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   358
              done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   359
          next
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   360
            let ?z = "x + (e/2) *\<^sub>R k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   361
            assume as: "x\<bullet>k = b\<bullet>k"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   362
            have "ball ?z (e / 2) \<inter> i = {}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   363
              apply (rule ccontr)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   364
              unfolding ex_in_conv[THEN sym]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   365
            proof(erule exE)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   366
              fix y
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   367
              assume "y \<in> ball ?z (e / 2) \<inter> i"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   368
              hence "dist ?z y < e/2" and yi:"y\<in>i" by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   369
              hence "\<bar>(?z - y) \<bullet> k\<bar> < e/2"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   370
                using Basis_le_norm[OF k, of "?z - y"] unfolding dist_norm by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   371
              hence "y\<bullet>k > b\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   372
                using e[THEN conjunct1] k by(auto simp add:field_simps inner_simps inner_Basis as)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   373
              hence "y \<notin> i"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   374
                unfolding ab mem_interval by (auto intro!: bexI[OF _ k])
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   375
              thus False using yi by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   376
            qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   377
            moreover
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   378
            have "ball ?z (e/2) \<subseteq> s \<inter> (\<Union>insert i f)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   379
              apply (rule order_trans[OF _ e[THEN conjunct2, unfolded lem1]])
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   380
            proof
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   381
              fix y
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   382
              assume as: "y\<in> ball ?z (e/2)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   383
              have "norm (x - y) \<le> \<bar>e\<bar> / 2 + norm (x - y + (e / 2) *\<^sub>R k)"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   384
                apply -
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   385
                apply(rule order_trans,rule norm_triangle_sub[of "x - y" "- (e/2) *\<^sub>R k"])
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   386
                unfolding norm_scaleR
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   387
                apply (auto simp: k)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   388
                done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   389
              also have "\<dots> < \<bar>e\<bar> / 2 + \<bar>e\<bar> / 2"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   390
                apply (rule add_strict_left_mono)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   391
                using as unfolding mem_ball dist_norm
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   392
                using e apply (auto simp add: field_simps)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   393
                done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   394
              finally show "y\<in>ball x e"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   395
                unfolding mem_ball dist_norm using e by(auto simp add:field_simps)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   396
            qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   397
            ultimately show ?thesis
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   398
              apply (rule_tac x="?z" in exI)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   399
              unfolding Union_insert
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   400
              apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   401
              done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   402
          qed 
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   403
          then guess x ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   404
          hence "x \<in> s \<inter> interior (\<Union>f)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   405
            unfolding lem1[where U="\<Union>f",THEN sym]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   406
            using centre_in_ball e[THEN conjunct1] by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   407
          thus ?thesis
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   408
            apply -
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   409
            apply (rule lem2, rule insert(3))
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   410
            using insert(4) apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   411
            done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   412
        qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   413
      qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   414
    qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   415
  qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   416
  note * = this
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   417
  guess t using *[OF assms(1,3) goal1] ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   418
  from this(2) guess x ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   419
  then guess e ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   420
  hence "x \<in> s" "x\<in>interior t"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   421
    defer
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   422
    using open_subset_interior[OF open_ball, of x e t] apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   423
    done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   424
  thus False using `t\<in>f` assms(4) by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   425
qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   426
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
   427
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   428
subsection {* Bounds on intervals where they exist. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   429
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   430
definition interval_upperbound :: "('a::ordered_euclidean_space) set \<Rightarrow> 'a" where
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   431
  "interval_upperbound s = (\<Sum>i\<in>Basis. Sup {a. \<exists>x\<in>s. x\<bullet>i = a} *\<^sub>R i)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   432
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   433
definition interval_lowerbound :: "('a::ordered_euclidean_space) set \<Rightarrow> 'a" where
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   434
  "interval_lowerbound s = (\<Sum>i\<in>Basis. Inf {a. \<exists>x\<in>s. x\<bullet>i = a} *\<^sub>R i)"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   435
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   436
lemma interval_upperbound[simp]:
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   437
  "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   438
    interval_upperbound {a..b} = (b::'a::ordered_euclidean_space)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   439
  unfolding interval_upperbound_def euclidean_representation_setsum
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   440
  by (auto simp del: ex_simps simp add: Bex_def ex_simps[symmetric] eucl_le[where 'a='a] setle_def
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
   441
           intro!: cSup_unique)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   442
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   443
lemma interval_lowerbound[simp]:
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   444
  "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   445
    interval_lowerbound {a..b} = (a::'a::ordered_euclidean_space)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   446
  unfolding interval_lowerbound_def euclidean_representation_setsum
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   447
  by (auto simp del: ex_simps simp add: Bex_def ex_simps[symmetric] eucl_le[where 'a='a] setge_def
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
   448
           intro!: cInf_unique)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   449
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   450
lemmas interval_bounds = interval_upperbound interval_lowerbound
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   451
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   452
lemma interval_bounds'[simp]:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   453
  assumes "{a..b}\<noteq>{}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   454
  shows "interval_upperbound {a..b} = b" "interval_lowerbound {a..b} = a"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   455
  using assms unfolding interval_ne_empty by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   456
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   457
subsection {* Content (length, area, volume...) of an interval. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   458
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
   459
definition "content (s::('a::ordered_euclidean_space) set) =
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   460
  (if s = {} then 0 else (\<Prod>i\<in>Basis. (interval_upperbound s)\<bullet>i - (interval_lowerbound s)\<bullet>i))"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   461
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   462
lemma interval_not_empty:"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i \<Longrightarrow> {a..b::'a::ordered_euclidean_space} \<noteq> {}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
   463
  unfolding interval_eq_empty unfolding not_ex not_less by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
   464
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   465
lemma content_closed_interval:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   466
  fixes a::"'a::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   467
  assumes "\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   468
  shows "content {a..b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   469
  using interval_not_empty[OF assms]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   470
  unfolding content_def interval_upperbound[OF assms] interval_lowerbound[OF assms]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   471
  by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   472
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   473
lemma content_closed_interval':
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   474
  fixes a::"'a::ordered_euclidean_space"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   475
  assumes "{a..b}\<noteq>{}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   476
  shows "content {a..b} = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   477
  apply (rule content_closed_interval)
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   478
  using assms
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   479
  unfolding interval_ne_empty
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   480
  apply assumption
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   481
  done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   482
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   483
lemma content_real:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   484
  assumes "a\<le>b"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   485
  shows "content {a..b} = b-a"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   486
proof -
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   487
  have *: "{..<Suc 0} = {0}" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   488
  show ?thesis unfolding content_def using assms by (auto simp: *)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
   489
qed
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
   490
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
   491
lemma content_singleton[simp]: "content {a} = 0"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
   492
proof -
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
   493
  have "content {a .. a} = 0"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   494
    by (subst content_closed_interval) (auto simp: ex_in_conv)
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
   495
  then show ?thesis by simp
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
   496
qed
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
   497
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   498
lemma content_unit[intro]: "content{0..One::'a::ordered_euclidean_space} = 1"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   499
proof -
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   500
  have *: "\<forall>i\<in>Basis. (0::'a)\<bullet>i \<le> (One::'a)\<bullet>i" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
   501
  have "0 \<in> {0..One::'a}" unfolding mem_interval by auto
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   502
  thus ?thesis unfolding content_def interval_bounds[OF *] using setprod_1 by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   503
qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   504
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   505
lemma content_pos_le[intro]:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   506
  fixes a::"'a::ordered_euclidean_space"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   507
  shows "0 \<le> content {a..b}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   508
proof (cases "{a..b} = {}")
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   509
  case False
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   510
  hence *: "\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" unfolding interval_ne_empty .
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   511
  have "(\<Prod>i\<in>Basis. interval_upperbound {a..b} \<bullet> i - interval_lowerbound {a..b} \<bullet> i) \<ge> 0"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   512
    apply (rule setprod_nonneg)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   513
    unfolding interval_bounds[OF *]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   514
    using *
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   515
    apply (erule_tac x=x in ballE)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   516
    apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   517
    done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   518
  thus ?thesis unfolding content_def by (auto simp del:interval_bounds')
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   519
qed (unfold content_def, auto)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   520
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   521
lemma content_pos_lt:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   522
  fixes a::"'a::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   523
  assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   524
  shows "0 < content {a..b}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   525
proof -
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   526
  have help_lemma1: "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i \<Longrightarrow> \<forall>i\<in>Basis. a\<bullet>i \<le> ((b\<bullet>i)::real)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   527
    apply (rule, erule_tac x=i in ballE)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   528
    apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   529
    done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   530
  show ?thesis unfolding content_closed_interval[OF help_lemma1[OF assms]]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   531
    apply(rule setprod_pos)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   532
    using assms apply (erule_tac x=x in ballE)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   533
    apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   534
    done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   535
qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   536
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   537
lemma content_eq_0: "content{a..b::'a::ordered_euclidean_space} = 0 \<longleftrightarrow> (\<exists>i\<in>Basis. b\<bullet>i \<le> a\<bullet>i)"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   538
proof (cases "{a..b} = {}")
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   539
  case True
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   540
  thus ?thesis
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   541
    unfolding content_def if_P[OF True]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   542
    unfolding interval_eq_empty
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   543
    apply -
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   544
    apply (rule, erule bexE)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   545
    apply (rule_tac x = i in bexI)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   546
    apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   547
    done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   548
next
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   549
  case False
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   550
  from this[unfolded interval_eq_empty not_ex not_less]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   551
  have as: "\<forall>i\<in>Basis. b \<bullet> i \<ge> a \<bullet> i" by fastforce
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   552
  show ?thesis
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   553
    unfolding content_def if_not_P[OF False] setprod_zero_iff[OF finite_Basis]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   554
    using as
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   555
    by (auto intro!: bexI)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   556
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   557
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   558
lemma cond_cases:"(P \<Longrightarrow> Q x) \<Longrightarrow> (\<not> P \<Longrightarrow> Q y) \<Longrightarrow> Q (if P then x else y)" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   559
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   560
lemma content_closed_interval_cases:
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   561
  "content {a..b::'a::ordered_euclidean_space} =
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   562
    (if \<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i then setprod (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis else 0)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   563
  by (auto simp: not_le content_eq_0 intro: less_imp_le content_closed_interval)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   564
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   565
lemma content_eq_0_interior: "content {a..b} = 0 \<longleftrightarrow> interior({a..b}) = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   566
  unfolding content_eq_0 interior_closed_interval interval_eq_empty by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   567
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   568
lemma content_pos_lt_eq: "0 < content {a..b::'a::ordered_euclidean_space} \<longleftrightarrow> (\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i)"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   569
  apply rule
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   570
  defer
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   571
  apply (rule content_pos_lt, assumption)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   572
proof -
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   573
  assume "0 < content {a..b}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   574
  hence "content {a..b} \<noteq> 0" by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   575
  thus "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   576
    unfolding content_eq_0 not_ex not_le by fastforce
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   577
qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   578
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   579
lemma content_empty [simp]: "content {} = 0" unfolding content_def by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   580
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   581
lemma content_subset:
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   582
  assumes "{a..b} \<subseteq> {c..d}"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   583
  shows "content {a..b::'a::ordered_euclidean_space} \<le> content {c..d}"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   584
proof (cases "{a..b} = {}")
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   585
  case True
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   586
  thus ?thesis using content_pos_le[of c d] by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   587
next
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   588
  case False
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   589
  hence ab_ne:"\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" unfolding interval_ne_empty by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   590
  hence ab_ab:"a\<in>{a..b}" "b\<in>{a..b}" unfolding mem_interval by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   591
  have "{c..d} \<noteq> {}" using assms False by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   592
  hence cd_ne:"\<forall>i\<in>Basis. c \<bullet> i \<le> d \<bullet> i" using assms unfolding interval_ne_empty by auto
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   593
  show ?thesis
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   594
    unfolding content_def
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   595
    unfolding interval_bounds[OF ab_ne] interval_bounds[OF cd_ne]
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   596
    unfolding if_not_P[OF False] if_not_P[OF `{c..d} \<noteq> {}`]
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   597
    apply (rule setprod_mono, rule)
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   598
  proof
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   599
    fix i :: 'a
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   600
    assume i: "i\<in>Basis"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   601
    show "0 \<le> b \<bullet> i - a \<bullet> i" using ab_ne[THEN bspec, OF i] i by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   602
    show "b \<bullet> i - a \<bullet> i \<le> d \<bullet> i - c \<bullet> i"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   603
      using assms[unfolded subset_eq mem_interval,rule_format,OF ab_ab(2),of i]
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   604
      using assms[unfolded subset_eq mem_interval,rule_format,OF ab_ab(1),of i]
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   605
      using i by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   606
  qed
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   607
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   608
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   609
lemma content_lt_nz: "0 < content {a..b} \<longleftrightarrow> content {a..b} \<noteq> 0"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
   610
  unfolding content_pos_lt_eq content_eq_0 unfolding not_ex not_le by fastforce
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   611
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   612
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   613
subsection {* The notion of a gauge --- simply an open set containing the point. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   614
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   615
definition gauge where "gauge d \<longleftrightarrow> (\<forall>x. x\<in>(d x) \<and> open(d x))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   616
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   617
lemma gaugeI: assumes "\<And>x. x\<in>g x" "\<And>x. open (g x)" shows "gauge g"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   618
  using assms unfolding gauge_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   619
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   620
lemma gaugeD[dest]: assumes "gauge d" shows "x\<in>d x" "open (d x)"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   621
  using assms unfolding gauge_def by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   622
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   623
lemma gauge_ball_dependent: "\<forall>x. 0 < e x \<Longrightarrow> gauge (\<lambda>x. ball x (e x))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   624
  unfolding gauge_def by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   625
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
   626
lemma gauge_ball[intro]: "0 < e \<Longrightarrow> gauge (\<lambda>x. ball x e)" unfolding gauge_def by auto 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   627
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   628
lemma gauge_trivial[intro]: "gauge (\<lambda>x. ball x 1)"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   629
  by (rule gauge_ball) auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   630
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
   631
lemma gauge_inter[intro]: "gauge d1 \<Longrightarrow> gauge d2 \<Longrightarrow> gauge (\<lambda>x. (d1 x) \<inter> (d2 x))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   632
  unfolding gauge_def by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   633
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   634
lemma gauge_inters:
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   635
  assumes "finite s" "\<forall>d\<in>s. gauge (f d)"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   636
  shows "gauge(\<lambda>x. \<Inter> {f d x | d. d \<in> s})"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   637
proof -
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   638
  have *:"\<And>x. {f d x |d. d \<in> s} = (\<lambda>d. f d x) ` s" by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   639
  show ?thesis
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   640
    unfolding gauge_def unfolding * 
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   641
    using assms unfolding Ball_def Inter_iff mem_Collect_eq gauge_def by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   642
qed
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   643
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   644
lemma gauge_existence_lemma: "(\<forall>x. \<exists>d::real. p x \<longrightarrow> 0 < d \<and> q d x) \<longleftrightarrow> (\<forall>x. \<exists>d>0. p x \<longrightarrow> q d x)"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   645
  by(meson zero_less_one)
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   646
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   647
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   648
subsection {* Divisions. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   649
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   650
definition division_of (infixl "division'_of" 40) where
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   651
  "s division_of i \<equiv>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   652
        finite s \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   653
        (\<forall>k\<in>s. k \<subseteq> i \<and> k \<noteq> {} \<and> (\<exists>a b. k = {a..b})) \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   654
        (\<forall>k1\<in>s. \<forall>k2\<in>s. k1 \<noteq> k2 \<longrightarrow> interior(k1) \<inter> interior(k2) = {}) \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   655
        (\<Union>s = i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   656
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   657
lemma division_ofD[dest]:
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   658
  assumes "s division_of i"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   659
  shows "finite s" "\<And>k. k\<in>s \<Longrightarrow> k \<subseteq> i" "\<And>k. k\<in>s \<Longrightarrow>  k \<noteq> {}" "\<And>k. k\<in>s \<Longrightarrow> (\<exists>a b. k = {a..b})"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   660
    "\<And>k1 k2. \<lbrakk>k1\<in>s; k2\<in>s; k1 \<noteq> k2\<rbrakk> \<Longrightarrow> interior(k1) \<inter> interior(k2) = {}" "\<Union>s = i"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   661
  using assms unfolding division_of_def by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   662
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   663
lemma division_ofI:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   664
  assumes "finite s" "\<And>k. k\<in>s \<Longrightarrow> k \<subseteq> i" "\<And>k. k\<in>s \<Longrightarrow>  k \<noteq> {}" "\<And>k. k\<in>s \<Longrightarrow> (\<exists>a b. k = {a..b})"
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   665
    "\<And>k1 k2. \<lbrakk>k1\<in>s; k2\<in>s; k1 \<noteq> k2\<rbrakk> \<Longrightarrow> interior(k1) \<inter> interior(k2) = {}" "\<Union>s = i"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   666
  shows "s division_of i" using assms unfolding division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   667
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   668
lemma division_of_finite: "s division_of i \<Longrightarrow> finite s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   669
  unfolding division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   670
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   671
lemma division_of_self[intro]: "{a..b} \<noteq> {} \<Longrightarrow> {{a..b}} division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   672
  unfolding division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   673
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   674
lemma division_of_trivial[simp]: "s division_of {} \<longleftrightarrow> s = {}" unfolding division_of_def by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   675
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   676
lemma division_of_sing[simp]:
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   677
  "s division_of {a..a::'a::ordered_euclidean_space} \<longleftrightarrow> s = {{a..a}}" (is "?l = ?r")
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   678
proof
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   679
  assume ?r
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   680
  moreover {
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   681
    assume "s = {{a}}"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   682
    moreover fix k assume "k\<in>s" 
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   683
    ultimately have"\<exists>x y. k = {x..y}"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   684
      apply (rule_tac x=a in exI)+
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   685
      unfolding interval_sing
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   686
      apply auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   687
      done
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   688
  }
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   689
  ultimately show ?l unfolding division_of_def interval_sing by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   690
next
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   691
  assume ?l
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   692
  note as=conjunctD4[OF this[unfolded division_of_def interval_sing]]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   693
  { fix x assume x:"x\<in>s" have "x={a}" using as(2)[rule_format,OF x] by auto }
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   694
  moreover have "s \<noteq> {}" using as(4) by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   695
  ultimately show ?r unfolding interval_sing by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   696
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   697
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   698
lemma elementary_empty: obtains p where "p division_of {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   699
  unfolding division_of_trivial by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   700
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   701
lemma elementary_interval: obtains p where "p division_of {a..b}"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   702
  by (metis division_of_trivial division_of_self)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   703
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   704
lemma division_contains: "s division_of i \<Longrightarrow> \<forall>x\<in>i. \<exists>k\<in>s. x \<in> k"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   705
  unfolding division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   706
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   707
lemma forall_in_division:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   708
 "d division_of i \<Longrightarrow> ((\<forall>x\<in>d. P x) \<longleftrightarrow> (\<forall>a b. {a..b} \<in> d \<longrightarrow> P {a..b}))"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
   709
  unfolding division_of_def by fastforce
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   710
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   711
lemma division_of_subset: assumes "p division_of (\<Union>p)" "q \<subseteq> p" shows "q division_of (\<Union>q)"
49698
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   712
  apply (rule division_ofI)
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   713
proof -
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   714
  note as=division_ofD[OF assms(1)]
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   715
  show "finite q"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   716
    apply (rule finite_subset)
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   717
    using as(1) assms(2) apply auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   718
    done
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   719
  { fix k
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   720
    assume "k \<in> q"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   721
    hence kp:"k\<in>p" using assms(2) by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   722
    show "k\<subseteq>\<Union>q" using `k \<in> q` by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   723
    show "\<exists>a b. k = {a..b}" using as(4)[OF kp]
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   724
      by auto show "k \<noteq> {}" using as(3)[OF kp] by auto }
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   725
  fix k1 k2
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   726
  assume "k1 \<in> q" "k2 \<in> q" "k1 \<noteq> k2"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   727
  hence *: "k1\<in>p" "k2\<in>p" "k1\<noteq>k2" using assms(2) by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   728
  show "interior k1 \<inter> interior k2 = {}" using as(5)[OF *] by auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   729
qed auto
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   730
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   731
lemma division_of_union_self[intro]: "p division_of s \<Longrightarrow> p division_of (\<Union>p)"
f68e237e8c10 tuned proofs;
wenzelm
parents: 49675
diff changeset
   732
  unfolding division_of_def by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   733
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   734
lemma division_of_content_0:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   735
  assumes "content {a..b} = 0" "d division_of {a..b}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   736
  shows "\<forall>k\<in>d. content k = 0"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   737
  unfolding forall_in_division[OF assms(2)]
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   738
  apply (rule,rule,rule)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   739
  apply (drule division_ofD(2)[OF assms(2)])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   740
  apply (drule content_subset) unfolding assms(1)
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   741
proof -
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   742
  case goal1
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   743
  thus ?case using content_pos_le[of a b] by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   744
qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   745
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   746
lemma division_inter:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   747
  assumes "p1 division_of s1" "p2 division_of (s2::('a::ordered_euclidean_space) set)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   748
  shows "{k1 \<inter> k2 | k1 k2 .k1 \<in> p1 \<and> k2 \<in> p2 \<and> k1 \<inter> k2 \<noteq> {}} division_of (s1 \<inter> s2)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   749
  (is "?A' division_of _")
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   750
proof -
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   751
  let ?A = "{s. s \<in>  (\<lambda>(k1,k2). k1 \<inter> k2) ` (p1 \<times> p2) \<and> s \<noteq> {}}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   752
  have *:"?A' = ?A" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   753
  show ?thesis unfolding *
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   754
  proof (rule division_ofI)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   755
    have "?A \<subseteq> (\<lambda>(x, y). x \<inter> y) ` (p1 \<times> p2)" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   756
    moreover have "finite (p1 \<times> p2)" using assms unfolding division_of_def by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   757
    ultimately show "finite ?A" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   758
    have *:"\<And>s. \<Union>{x\<in>s. x \<noteq> {}} = \<Union>s" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   759
    show "\<Union>?A = s1 \<inter> s2"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   760
      apply (rule set_eqI)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   761
      unfolding * and Union_image_eq UN_iff
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   762
      using division_ofD(6)[OF assms(1)] and division_ofD(6)[OF assms(2)]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   763
      apply auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   764
      done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   765
    { fix k
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   766
      assume "k\<in>?A"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   767
      then obtain k1 k2 where k: "k = k1 \<inter> k2" "k1\<in>p1" "k2\<in>p2" "k\<noteq>{}" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   768
      thus "k \<noteq> {}" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   769
      show "k \<subseteq> s1 \<inter> s2"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   770
        using division_ofD(2)[OF assms(1) k(2)] and division_ofD(2)[OF assms(2) k(3)]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   771
        unfolding k by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   772
      guess a1 using division_ofD(4)[OF assms(1) k(2)] ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   773
      then guess b1 .. note ab1=this
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   774
      guess a2 using division_ofD(4)[OF assms(2) k(3)] ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   775
      then guess b2 .. note ab2=this
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   776
      show "\<exists>a b. k = {a..b}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   777
        unfolding k ab1 ab2 unfolding inter_interval by auto }
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   778
    fix k1 k2
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   779
    assume "k1\<in>?A"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   780
    then obtain x1 y1 where k1:"k1 = x1 \<inter> y1" "x1\<in>p1" "y1\<in>p2" "k1\<noteq>{}" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   781
    assume "k2\<in>?A"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   782
    then obtain x2 y2 where k2:"k2 = x2 \<inter> y2" "x2\<in>p1" "y2\<in>p2" "k2\<noteq>{}" by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   783
    assume "k1 \<noteq> k2"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   784
    hence th:"x1\<noteq>x2 \<or> y1\<noteq>y2" unfolding k1 k2 by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   785
    have *:"(interior x1 \<inter> interior x2 = {} \<or> interior y1 \<inter> interior y2 = {}) \<Longrightarrow>
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   786
      interior(x1 \<inter> y1) \<subseteq> interior(x1) \<Longrightarrow> interior(x1 \<inter> y1) \<subseteq> interior(y1) \<Longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   787
      interior(x2 \<inter> y2) \<subseteq> interior(x2) \<Longrightarrow> interior(x2 \<inter> y2) \<subseteq> interior(y2)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   788
      \<Longrightarrow> interior(x1 \<inter> y1) \<inter> interior(x2 \<inter> y2) = {}" by auto
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   789
    show "interior k1 \<inter> interior k2 = {}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   790
      unfolding k1 k2
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   791
      apply (rule *)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   792
      defer
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   793
      apply (rule_tac[1-4] interior_mono)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   794
      using division_ofD(5)[OF assms(1) k1(2) k2(2)]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   795
      using division_ofD(5)[OF assms(2) k1(3) k2(3)]
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   796
      using th apply auto done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   797
  qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   798
qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   799
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   800
lemma division_inter_1:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   801
  assumes "d division_of i" "{a..b::'a::ordered_euclidean_space} \<subseteq> i"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   802
  shows "{ {a..b} \<inter> k |k. k \<in> d \<and> {a..b} \<inter> k \<noteq> {} } division_of {a..b}"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   803
proof (cases "{a..b} = {}")
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   804
  case True
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   805
  show ?thesis unfolding True and division_of_trivial by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   806
next
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   807
  case False
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   808
  have *: "{a..b} \<inter> i = {a..b}" using assms(2) by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   809
  show ?thesis using division_inter[OF division_of_self[OF False] assms(1)] unfolding * by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   810
qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   811
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   812
lemma elementary_inter:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   813
  assumes "p1 division_of s" "p2 division_of (t::('a::ordered_euclidean_space) set)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   814
  shows "\<exists>p. p division_of (s \<inter> t)"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   815
  apply rule
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   816
  apply (rule division_inter[OF assms])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   817
  done
49970
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   818
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   819
lemma elementary_inters:
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   820
  assumes "finite f" "f\<noteq>{}" "\<forall>s\<in>f. \<exists>p. p division_of (s::('a::ordered_euclidean_space) set)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   821
  shows "\<exists>p. p division_of (\<Inter> f)"
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   822
  using assms
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   823
proof (induct f rule: finite_induct)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   824
  case (insert x f)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   825
  show ?case
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   826
  proof (cases "f = {}")
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   827
    case True
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   828
    thus ?thesis unfolding True using insert by auto
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   829
  next
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   830
    case False
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   831
    guess p using insert(3)[OF False insert(5)[unfolded ball_simps,THEN conjunct2]] ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   832
    moreover guess px using insert(5)[rule_format,OF insertI1] ..
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   833
    ultimately show ?thesis
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   834
      unfolding Inter_insert
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   835
      apply (rule_tac elementary_inter)
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   836
      apply assumption
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   837
      apply assumption
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   838
      done
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   839
  qed
ca5ab959c0ae tuned proofs;
wenzelm
parents: 49698
diff changeset
   840
qed auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   841
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   842
lemma division_disjoint_union:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   843
  assumes "p1 division_of s1" "p2 division_of s2" "interior s1 \<inter> interior s2 = {}"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   844
  shows "(p1 \<union> p2) division_of (s1 \<union> s2)"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   845
proof (rule division_ofI)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   846
  note d1 = division_ofD[OF assms(1)] and d2 = division_ofD[OF assms(2)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   847
  show "finite (p1 \<union> p2)" using d1(1) d2(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   848
  show "\<Union>(p1 \<union> p2) = s1 \<union> s2" using d1(6) d2(6) by auto
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   849
  {
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   850
    fix k1 k2
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   851
    assume as: "k1 \<in> p1 \<union> p2" "k2 \<in> p1 \<union> p2" "k1 \<noteq> k2"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   852
    moreover
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   853
    let ?g="interior k1 \<inter> interior k2 = {}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   854
    {
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   855
      assume as: "k1\<in>p1" "k2\<in>p2"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   856
      have ?g
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   857
        using interior_mono[OF d1(2)[OF as(1)]] interior_mono[OF d2(2)[OF as(2)]]
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   858
        using assms(3) by blast
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   859
    }
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   860
    moreover
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   861
    {
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   862
      assume as: "k1\<in>p2" "k2\<in>p1"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   863
      have ?g
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   864
        using interior_mono[OF d1(2)[OF as(2)]] interior_mono[OF d2(2)[OF as(1)]]
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   865
        using assms(3) by blast
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   866
    }
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   867
    ultimately show ?g using d1(5)[OF _ _ as(3)] and d2(5)[OF _ _ as(3)] by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   868
  }
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   869
  fix k
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   870
  assume k: "k \<in> p1 \<union> p2"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   871
  show "k \<subseteq> s1 \<union> s2" using k d1(2) d2(2) by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   872
  show "k \<noteq> {}" using k d1(3) d2(3) by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   873
  show "\<exists>a b. k = {a..b}" using k d1(4) d2(4) by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   874
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   875
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   876
lemma partial_division_extend_1:
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   877
  assumes incl: "{c..d} \<subseteq> {a..b::'a::ordered_euclidean_space}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   878
    and nonempty: "{c..d} \<noteq> {}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   879
  obtains p where "p division_of {a..b}" "{c..d} \<in> p"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   880
proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   881
  let ?B = "\<lambda>f::'a\<Rightarrow>'a \<times> 'a. {(\<Sum>i\<in>Basis. (fst (f i) \<bullet> i) *\<^sub>R i) .. (\<Sum>i\<in>Basis. (snd (f i) \<bullet> i) *\<^sub>R i)}"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   882
  def p \<equiv> "?B ` (Basis \<rightarrow>\<^sub>E {(a, c), (c, d), (d, b)})"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   883
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   884
  show "{c .. d} \<in> p"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   885
    unfolding p_def
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   886
    by (auto simp add: interval_eq_empty eucl_le[where 'a='a]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   887
             intro!: image_eqI[where x="\<lambda>(i::'a)\<in>Basis. (c, d)"])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   888
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   889
  {
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   890
    fix i :: 'a
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   891
    assume "i \<in> Basis"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   892
    with incl nonempty have "a \<bullet> i \<le> c \<bullet> i" "c \<bullet> i \<le> d \<bullet> i" "d \<bullet> i \<le> b \<bullet> i"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   893
      unfolding interval_eq_empty subset_interval by (auto simp: not_le)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   894
  }
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   895
  note ord = this
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   896
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   897
  show "p division_of {a..b}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   898
  proof (rule division_ofI)
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   899
    show "finite p" unfolding p_def by (auto intro!: finite_PiE)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   900
    {
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   901
      fix k
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   902
      assume "k \<in> p"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   903
      then obtain f where f: "f \<in> Basis \<rightarrow>\<^sub>E {(a, c), (c, d), (d, b)}" and k: "k = ?B f"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   904
        by (auto simp: p_def)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   905
      then show "\<exists>a b. k = {a..b}" by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   906
      have "k \<subseteq> {a..b} \<and> k \<noteq> {}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   907
      proof (simp add: k interval_eq_empty subset_interval not_less, safe)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   908
        fix i :: 'a
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   909
        assume i: "i \<in> Basis"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   910
        with f have "f i = (a, c) \<or> f i = (c, d) \<or> f i = (d, b)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   911
          by (auto simp: PiE_iff)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   912
        with i ord[of i]
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   913
        show "a \<bullet> i \<le> fst (f i) \<bullet> i" "snd (f i) \<bullet> i \<le> b \<bullet> i" "fst (f i) \<bullet> i \<le> snd (f i) \<bullet> i"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   914
          by (auto simp: subset_iff eucl_le[where 'a='a])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   915
      qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   916
      then show "k \<noteq> {}" "k \<subseteq> {a .. b}" by auto
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   917
      {
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   918
        fix l assume "l \<in> p"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 52141
diff changeset
   919
        then obtain g where g: "g \<in> Basis \<rightarrow>\<^sub>E {(a, c), (c, d), (d, b)}" and l: "l = ?B g"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   920
          by (auto simp: p_def)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   921
        assume "l \<noteq> k"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   922
        have "\<exists>i\<in>Basis. f i \<noteq> g i"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   923
        proof (rule ccontr)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   924
          assume "\<not> (\<exists>i\<in>Basis. f i \<noteq> g i)"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   925
          with f g have "f = g"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   926
            by (auto simp: PiE_iff extensional_def intro!: ext)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   927
          with `l \<noteq> k` show False
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   928
            by (simp add: l k)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   929
        qed
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   930
        then guess i .. note * = this
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   931
        moreover from * have "f i = (a, c) \<or> f i = (c, d) \<or> f i = (d, b)"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   932
            "g i = (a, c) \<or> g i = (c, d) \<or> g i = (d, b)"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   933
          using f g by (auto simp: PiE_iff)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   934
        moreover note ord[of i]
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   935
        ultimately show "interior l \<inter> interior k = {}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   936
          by (auto simp add: l k interior_closed_interval disjoint_interval intro!: bexI[of _ i])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   937
      }
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   938
      note `k \<subseteq> { a.. b}`
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   939
    }
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   940
    moreover
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   941
    {
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   942
      fix x assume x: "x \<in> {a .. b}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   943
      have "\<forall>i\<in>Basis. \<exists>l. x \<bullet> i \<in> {fst l \<bullet> i .. snd l \<bullet> i} \<and> l \<in> {(a, c), (c, d), (d, b)}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   944
      proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   945
        fix i :: 'a assume "i \<in> Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   946
        with x ord[of i] 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   947
        have "(a \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> c \<bullet> i) \<or> (c \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> d \<bullet> i) \<or>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   948
            (d \<bullet> i \<le> x \<bullet> i \<and> x \<bullet> i \<le> b \<bullet> i)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   949
          by (auto simp: eucl_le[where 'a='a])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   950
        then show "\<exists>l. x \<bullet> i \<in> {fst l \<bullet> i .. snd l \<bullet> i} \<and> l \<in> {(a, c), (c, d), (d, b)}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   951
          by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   952
      qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   953
      then guess f unfolding bchoice_iff .. note f = this
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
   954
      moreover from f have "restrict f Basis \<in> Basis \<rightarrow>\<^sub>E {(a, c), (c, d), (d, b)}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   955
        by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   956
      moreover from f have "x \<in> ?B (restrict f Basis)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   957
        by (auto simp: mem_interval eucl_le[where 'a='a])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   958
      ultimately have "\<exists>k\<in>p. x \<in> k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   959
        unfolding p_def by blast }
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   960
    ultimately show "\<Union>p = {a..b}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   961
      by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   962
  qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
   963
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   964
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   965
lemma partial_division_extend_interval:
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   966
  assumes "p division_of (\<Union>p)" "(\<Union>p) \<subseteq> {a..b}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   967
  obtains q where "p \<subseteq> q" "q division_of {a..b::'a::ordered_euclidean_space}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   968
proof (cases "p = {}")
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   969
  case True
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   970
  guess q apply (rule elementary_interval[of a b]) .
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   971
  thus ?thesis
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   972
    apply -
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   973
    apply (rule that[of q])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   974
    unfolding True
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   975
    apply auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   976
    done
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   977
next
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   978
  case False
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   979
  note p = division_ofD[OF assms(1)]
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   980
  have *: "\<forall>k\<in>p. \<exists>q. q division_of {a..b} \<and> k\<in>q"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   981
  proof
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   982
    case goal1
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   983
    guess c using p(4)[OF goal1] ..
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   984
    then guess d .. note "cd" = this
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   985
    have *: "{c..d} \<subseteq> {a..b}" "{c..d} \<noteq> {}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   986
      using p(2,3)[OF goal1, unfolded "cd"] using assms(2) by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   987
    guess q apply(rule partial_division_extend_1[OF *]) .
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   988
    thus ?case unfolding "cd" by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   989
  qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
   990
  guess q using bchoice[OF *] .. note q = conjunctD2[OF this[rule_format]]
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   991
  have "\<And>x. x\<in>p \<Longrightarrow> \<exists>d. d division_of \<Union>(q x - {x})"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   992
    apply (rule, rule_tac p="q x" in division_of_subset)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   993
  proof -
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   994
    fix x
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   995
    assume x: "x\<in>p"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   996
    show "q x division_of \<Union>q x"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   997
      apply -
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   998
      apply (rule division_ofI)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
   999
      using division_ofD[OF q(1)[OF x]]
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1000
      apply auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1001
      done
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1002
    show "q x - {x} \<subseteq> q x" by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1003
  qed
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1004
  hence "\<exists>d. d division_of \<Inter> ((\<lambda>i. \<Union>(q i - {i})) ` p)"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1005
    apply -
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1006
    apply (rule elementary_inters)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1007
    apply (rule finite_imageI[OF p(1)])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1008
    unfolding image_is_empty
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1009
    apply (rule False)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1010
    apply auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1011
    done
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1012
  then guess d .. note d = this
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1013
  show ?thesis
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1014
    apply (rule that[of "d \<union> p"])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1015
  proof -
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1016
    have *: "\<And>s f t. s \<noteq> {} \<Longrightarrow> (\<forall>i\<in>s. f i \<union> i = t) \<Longrightarrow> t = \<Inter> (f ` s) \<union> (\<Union>s)" by auto
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1017
    have *: "{a..b} = \<Inter> ((\<lambda>i. \<Union>(q i - {i})) ` p) \<union> \<Union>p"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1018
      apply (rule *[OF False])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1019
    proof
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1020
      fix i
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1021
      assume i: "i\<in>p"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1022
      show "\<Union>(q i - {i}) \<union> i = {a..b}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1023
        using division_ofD(6)[OF q(1)[OF i]] using q(2)[OF i] by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1024
    qed
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1025
    show "d \<union> p division_of {a..b}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1026
      unfolding *
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1027
      apply (rule division_disjoint_union[OF d assms(1)])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1028
      apply (rule inter_interior_unions_intervals)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1029
      apply (rule p open_interior ballI)+
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1030
    proof (assumption, rule)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1031
      fix k
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1032
      assume k: "k\<in>p"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1033
      have *: "\<And>u t s. u \<subseteq> s \<Longrightarrow> s \<inter> t = {} \<Longrightarrow> u \<inter> t = {}" by auto
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1034
      show "interior (\<Inter> ((\<lambda>i. \<Union>(q i - {i})) ` p)) \<inter> interior k = {}"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1035
        apply (rule *[of _ "interior (\<Union>(q k - {k}))"])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1036
        defer
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1037
        apply (subst Int_commute)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1038
        apply (rule inter_interior_unions_intervals)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1039
      proof -
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1040
        note qk=division_ofD[OF q(1)[OF k]]
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1041
        show "finite (q k - {k})" "open (interior k)"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1042
          "\<forall>t\<in>q k - {k}. \<exists>a b. t = {a..b}" using qk by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1043
        show "\<forall>t\<in>q k - {k}. interior k \<inter> interior t = {}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1044
          using qk(5) using q(2)[OF k] by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1045
        have *: "\<And>x s. x \<in> s \<Longrightarrow> \<Inter>s \<subseteq> x" by auto
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1046
        show "interior (\<Inter> ((\<lambda>i. \<Union>(q i - {i})) ` p)) \<subseteq> interior (\<Union>(q k - {k}))"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1047
          apply (rule interior_mono *)+
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1048
          using k by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1049
      qed
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1050
    qed
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1051
  qed auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1052
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1053
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1054
lemma elementary_bounded[dest]: "p division_of s \<Longrightarrow> bounded (s::('a::ordered_euclidean_space) set)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1055
  unfolding division_of_def by(metis bounded_Union bounded_interval) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1056
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1057
lemma elementary_subset_interval: "p division_of s \<Longrightarrow> \<exists>a b. s \<subseteq> {a..b::'a::ordered_euclidean_space}"
50945
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1058
  by (meson elementary_bounded bounded_subset_closed_interval)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1059
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1060
lemma division_union_intervals_exists:
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1061
  assumes "{a..b::'a::ordered_euclidean_space} \<noteq> {}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1062
  obtains p where "(insert {a..b} p) division_of ({a..b} \<union> {c..d})"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1063
proof (cases "{c..d} = {}")
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1064
  case True
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1065
  show ?thesis
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1066
    apply (rule that[of "{}"])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1067
    unfolding True
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1068
    using assms
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1069
    apply auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1070
    done
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1071
next
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1072
  case False
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1073
  note false=this
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1074
  show ?thesis
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1075
  proof (cases "{a..b} \<inter> {c..d} = {}")
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1076
    case True
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1077
    have *:"\<And>a b. {a,b} = {a} \<union> {b}" by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1078
    show ?thesis
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1079
      apply (rule that[of "{{c..d}}"])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1080
      unfolding *
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1081
      apply (rule division_disjoint_union)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1082
      using false True assms
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1083
      using interior_subset
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1084
      apply auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1085
      done
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1086
  next
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1087
    case False
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1088
    obtain u v where uv: "{a..b} \<inter> {c..d} = {u..v}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1089
      unfolding inter_interval by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1090
    have *: "{u..v} \<subseteq> {c..d}" using uv by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1091
    guess p apply (rule partial_division_extend_1[OF * False[unfolded uv]]) .
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1092
    note p=this division_ofD[OF this(1)]
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1093
    have *: "{a..b} \<union> {c..d} = {a..b} \<union> \<Union>(p - {{u..v}})" "\<And>x s. insert x s = {x} \<union> s"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1094
      using p(8) unfolding uv[THEN sym] by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1095
    show ?thesis
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1096
      apply (rule that[of "p - {{u..v}}"])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1097
      unfolding *(1)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1098
      apply (subst *(2))
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1099
      apply (rule division_disjoint_union)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1100
      apply (rule, rule assms)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1101
      apply (rule division_of_subset[of p])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1102
      apply (rule division_of_union_self[OF p(1)])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1103
      defer
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1104
      unfolding interior_inter[THEN sym]
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1105
    proof -
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1106
      have *: "\<And>cd p uv ab. p \<subseteq> cd \<Longrightarrow> ab \<inter> cd = uv \<Longrightarrow> ab \<inter> p = uv \<inter> p" by auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1107
      have "interior ({a..b} \<inter> \<Union>(p - {{u..v}})) = interior({u..v} \<inter> \<Union>(p - {{u..v}}))" 
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1108
        apply (rule arg_cong[of _ _ interior])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1109
        apply (rule *[OF _ uv])
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1110
        using p(8)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1111
        apply auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1112
        done
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1113
      also have "\<dots> = {}"
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1114
        unfolding interior_inter
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1115
        apply (rule inter_interior_unions_intervals)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1116
        using p(6) p(7)[OF p(2)] p(3)
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1117
        apply auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1118
        done
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1119
      finally show "interior ({a..b} \<inter> \<Union>(p - {{u..v}})) = {}" .
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1120
    qed auto
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1121
  qed
917e76c53f82 tuned proofs;
wenzelm
parents: 50919
diff changeset
  1122
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1123
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1124
lemma division_of_unions: assumes "finite f"  "\<And>p. p\<in>f \<Longrightarrow> p division_of (\<Union>p)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1125
  "\<And>k1 k2. \<lbrakk>k1 \<in> \<Union>f; k2 \<in> \<Union>f; k1 \<noteq> k2\<rbrakk> \<Longrightarrow> interior k1 \<inter> interior k2 = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1126
  shows "\<Union>f division_of \<Union>\<Union>f" apply(rule division_ofI) prefer 5 apply(rule assms(3)|assumption)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1127
  apply(rule finite_Union assms(1))+ prefer 3 apply(erule UnionE) apply(rule_tac s=X in division_ofD(3)[OF assms(2)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1128
  using division_ofD[OF assms(2)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1129
  
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1130
lemma elementary_union_interval: assumes "p division_of \<Union>p"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1131
  obtains q where "q division_of ({a..b::'a::ordered_euclidean_space} \<union> \<Union>p)" proof-
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1132
  note assm=division_ofD[OF assms]
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1133
  have lem1:"\<And>f s. \<Union>\<Union> (f ` s) = \<Union>((\<lambda>x.\<Union>(f x)) ` s)" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1134
  have lem2:"\<And>f s. f \<noteq> {} \<Longrightarrow> \<Union>{s \<union> t |t. t \<in> f} = s \<union> \<Union>f" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1135
{ presume "p={} \<Longrightarrow> thesis" "{a..b} = {} \<Longrightarrow> thesis" "{a..b} \<noteq> {} \<Longrightarrow> interior {a..b} = {} \<Longrightarrow> thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1136
    "p\<noteq>{} \<Longrightarrow> interior {a..b}\<noteq>{} \<Longrightarrow> {a..b} \<noteq> {} \<Longrightarrow> thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1137
  thus thesis by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1138
next assume as:"p={}" guess p apply(rule elementary_interval[of a b]) .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1139
  thus thesis apply(rule_tac that[of p]) unfolding as by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1140
next assume as:"{a..b}={}" show thesis apply(rule that) unfolding as using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1141
next assume as:"interior {a..b} = {}" "{a..b} \<noteq> {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1142
  show thesis apply(rule that[of "insert {a..b} p"],rule division_ofI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1143
    unfolding finite_insert apply(rule assm(1)) unfolding Union_insert  
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  1144
    using assm(2-4) as apply- by(fastforce dest: assm(5))+
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1145
next assume as:"p \<noteq> {}" "interior {a..b} \<noteq> {}" "{a..b}\<noteq>{}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1146
  have "\<forall>k\<in>p. \<exists>q. (insert {a..b} q) division_of ({a..b} \<union> k)" proof case goal1
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1147
    from assm(4)[OF this] guess c .. then guess d ..
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1148
    thus ?case apply-apply(rule division_union_intervals_exists[OF as(3),of c d]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1149
  qed from bchoice[OF this] guess q .. note q=division_ofD[OF this[rule_format]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1150
  let ?D = "\<Union>{insert {a..b} (q k) | k. k \<in> p}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1151
  show thesis apply(rule that[of "?D"]) proof(rule division_ofI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1152
    have *:"{insert {a..b} (q k) |k. k \<in> p} = (\<lambda>k. insert {a..b} (q k)) ` p" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1153
    show "finite ?D" apply(rule finite_Union) unfolding * apply(rule finite_imageI) using assm(1) q(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1154
    show "\<Union>?D = {a..b} \<union> \<Union>p" unfolding * lem1 unfolding lem2[OF as(1), of "{a..b}",THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1155
      using q(6) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1156
    fix k assume k:"k\<in>?D" thus " k \<subseteq> {a..b} \<union> \<Union>p" using q(2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1157
    show "k \<noteq> {}" using q(3) k by auto show "\<exists>a b. k = {a..b}" using q(4) k by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1158
    fix k' assume k':"k'\<in>?D" "k\<noteq>k'"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1159
    obtain x  where x: "k \<in>insert {a..b} (q x)"  "x\<in>p"  using k  by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1160
    obtain x' where x':"k'\<in>insert {a..b} (q x')" "x'\<in>p" using k' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1161
    show "interior k \<inter> interior k' = {}" proof(cases "x=x'")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1162
      case True show ?thesis apply(rule q(5)) using x x' k' unfolding True by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1163
    next case False 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1164
      { presume "k = {a..b} \<Longrightarrow> ?thesis" "k' = {a..b} \<Longrightarrow> ?thesis" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1165
        "k \<noteq> {a..b} \<Longrightarrow> k' \<noteq> {a..b} \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1166
        thus ?thesis by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1167
      { assume as':"k  = {a..b}" show ?thesis apply(rule q(5)) using x' k'(2) unfolding as' by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1168
      { assume as':"k' = {a..b}" show ?thesis apply(rule q(5)) using x  k'(2) unfolding as' by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1169
      assume as':"k \<noteq> {a..b}" "k' \<noteq> {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1170
      guess c using q(4)[OF x(2,1)] .. then guess d .. note c_d=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1171
      have "interior k  \<inter> interior {a..b} = {}" apply(rule q(5)) using x  k'(2) using as' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1172
      hence "interior k \<subseteq> interior x" apply-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1173
        apply(rule interior_subset_union_intervals[OF c_d _ as(2) q(2)[OF x(2,1)]]) by auto moreover
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1174
      guess c using q(4)[OF x'(2,1)] .. then guess d .. note c_d=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1175
      have "interior k' \<inter> interior {a..b} = {}" apply(rule q(5)) using x' k'(2) using as' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1176
      hence "interior k' \<subseteq> interior x'" apply-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1177
        apply(rule interior_subset_union_intervals[OF c_d _ as(2) q(2)[OF x'(2,1)]]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1178
      ultimately show ?thesis using assm(5)[OF x(2) x'(2) False] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1179
    qed qed } qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1180
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1181
lemma elementary_unions_intervals:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1182
  assumes "finite f" "\<And>s. s \<in> f \<Longrightarrow> \<exists>a b. s = {a..b::'a::ordered_euclidean_space}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1183
  obtains p where "p division_of (\<Union>f)" proof-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1184
  have "\<exists>p. p division_of (\<Union>f)" proof(induct_tac f rule:finite_subset_induct) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1185
    show "\<exists>p. p division_of \<Union>{}" using elementary_empty by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1186
    fix x F assume as:"finite F" "x \<notin> F" "\<exists>p. p division_of \<Union>F" "x\<in>f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1187
    from this(3) guess p .. note p=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1188
    from assms(2)[OF as(4)] guess a .. then guess b .. note ab=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1189
    have *:"\<Union>F = \<Union>p" using division_ofD[OF p] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1190
    show "\<exists>p. p division_of \<Union>insert x F" using elementary_union_interval[OF p[unfolded *], of a b]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1191
      unfolding Union_insert ab * by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1192
  qed(insert assms,auto) thus ?thesis apply-apply(erule exE,rule that) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1193
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1194
lemma elementary_union: assumes "ps division_of s" "pt division_of (t::('a::ordered_euclidean_space) set)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1195
  obtains p where "p division_of (s \<union> t)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1196
proof- have "s \<union> t = \<Union>ps \<union> \<Union>pt" using assms unfolding division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1197
  hence *:"\<Union>(ps \<union> pt) = s \<union> t" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1198
  show ?thesis apply-apply(rule elementary_unions_intervals[of "ps\<union>pt"])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1199
    unfolding * prefer 3 apply(rule_tac p=p in that)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1200
    using assms[unfolded division_of_def] by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1201
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1202
lemma partial_division_extend: fixes t::"('a::ordered_euclidean_space) set"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1203
  assumes "p division_of s" "q division_of t" "s \<subseteq> t"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1204
  obtains r where "p \<subseteq> r" "r division_of t" proof-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1205
  note divp = division_ofD[OF assms(1)] and divq = division_ofD[OF assms(2)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1206
  obtain a b where ab:"t\<subseteq>{a..b}" using elementary_subset_interval[OF assms(2)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1207
  guess r1 apply(rule partial_division_extend_interval) apply(rule assms(1)[unfolded divp(6)[THEN sym]])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1208
    apply(rule subset_trans) by(rule ab assms[unfolded divp(6)[THEN sym]])+  note r1 = this division_ofD[OF this(2)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1209
  guess p' apply(rule elementary_unions_intervals[of "r1 - p"]) using r1(3,6) by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1210
  then obtain r2 where r2:"r2 division_of (\<Union>(r1 - p)) \<inter> (\<Union>q)" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1211
    apply- apply(drule elementary_inter[OF _ assms(2)[unfolded divq(6)[THEN sym]]]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1212
  { fix x assume x:"x\<in>t" "x\<notin>s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1213
    hence "x\<in>\<Union>r1" unfolding r1 using ab by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1214
    then guess r unfolding Union_iff .. note r=this moreover
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1215
    have "r \<notin> p" proof assume "r\<in>p" hence "x\<in>s" using divp(2) r by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1216
      thus False using x by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1217
    ultimately have "x\<in>\<Union>(r1 - p)" by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1218
  hence *:"t = \<Union>p \<union> (\<Union>(r1 - p) \<inter> \<Union>q)" unfolding divp divq using assms(3) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1219
  show ?thesis apply(rule that[of "p \<union> r2"]) unfolding * defer apply(rule division_disjoint_union)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1220
    unfolding divp(6) apply(rule assms r2)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1221
  proof- have "interior s \<inter> interior (\<Union>(r1-p)) = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1222
    proof(rule inter_interior_unions_intervals)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1223
      show "finite (r1 - p)" "open (interior s)" "\<forall>t\<in>r1-p. \<exists>a b. t = {a..b}" using r1 by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1224
      have *:"\<And>s. (\<And>x. x \<in> s \<Longrightarrow> False) \<Longrightarrow> s = {}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1225
      show "\<forall>t\<in>r1-p. interior s \<inter> interior t = {}" proof(rule)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1226
        fix m x assume as:"m\<in>r1-p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1227
        have "interior m \<inter> interior (\<Union>p) = {}" proof(rule inter_interior_unions_intervals)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1228
          show "finite p" "open (interior m)" "\<forall>t\<in>p. \<exists>a b. t = {a..b}" using divp by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1229
          show "\<forall>t\<in>p. interior m \<inter> interior t = {}" apply(rule, rule r1(7)) using as using r1 by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1230
        qed thus "interior s \<inter> interior m = {}" unfolding divp by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1231
      qed qed        
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1232
    thus "interior s \<inter> interior (\<Union>(r1-p) \<inter> (\<Union>q)) = {}" using interior_subset by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1233
  qed auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1234
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1235
subsection {* Tagged (partial) divisions. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1236
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1237
definition tagged_partial_division_of (infixr "tagged'_partial'_division'_of" 40) where
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1238
  "(s tagged_partial_division_of i) \<equiv>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1239
        finite s \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1240
        (\<forall>x k. (x,k) \<in> s \<longrightarrow> x \<in> k \<and> k \<subseteq> i \<and> (\<exists>a b. k = {a..b})) \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1241
        (\<forall>x1 k1 x2 k2. (x1,k1) \<in> s \<and> (x2,k2) \<in> s \<and> ((x1,k1) \<noteq> (x2,k2))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1242
                       \<longrightarrow> (interior(k1) \<inter> interior(k2) = {}))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1243
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1244
lemma tagged_partial_division_ofD[dest]: assumes "s tagged_partial_division_of i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1245
  shows "finite s" "\<And>x k. (x,k) \<in> s \<Longrightarrow> x \<in> k" "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1246
  "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1247
  "\<And>x1 k1 x2 k2. (x1,k1) \<in> s \<Longrightarrow> (x2,k2) \<in> s \<Longrightarrow> (x1,k1) \<noteq> (x2,k2) \<Longrightarrow> interior(k1) \<inter> interior(k2) = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1248
  using assms unfolding tagged_partial_division_of_def  apply- by blast+ 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1249
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1250
definition tagged_division_of (infixr "tagged'_division'_of" 40) where
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1251
  "(s tagged_division_of i) \<equiv>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1252
        (s tagged_partial_division_of i) \<and> (\<Union>{k. \<exists>x. (x,k) \<in> s} = i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1253
44167
e81d676d598e avoid duplicate rule warnings
huffman
parents: 44140
diff changeset
  1254
lemma tagged_division_of_finite: "s tagged_division_of i \<Longrightarrow> finite s"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1255
  unfolding tagged_division_of_def tagged_partial_division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1256
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1257
lemma tagged_division_of:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1258
 "(s tagged_division_of i) \<longleftrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1259
        finite s \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1260
        (\<forall>x k. (x,k) \<in> s
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1261
               \<longrightarrow> x \<in> k \<and> k \<subseteq> i \<and> (\<exists>a b. k = {a..b})) \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1262
        (\<forall>x1 k1 x2 k2. (x1,k1) \<in> s \<and> (x2,k2) \<in> s \<and> ~((x1,k1) = (x2,k2))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1263
                       \<longrightarrow> (interior(k1) \<inter> interior(k2) = {})) \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1264
        (\<Union>{k. \<exists>x. (x,k) \<in> s} = i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1265
  unfolding tagged_division_of_def tagged_partial_division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1266
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1267
lemma tagged_division_ofI: assumes
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1268
  "finite s" "\<And>x k. (x,k) \<in> s \<Longrightarrow> x \<in> k" "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> i"  "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1269
  "\<And>x1 k1 x2 k2. (x1,k1) \<in> s \<Longrightarrow> (x2,k2) \<in> s \<Longrightarrow> ~((x1,k1) = (x2,k2)) \<Longrightarrow> (interior(k1) \<inter> interior(k2) = {})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1270
  "(\<Union>{k. \<exists>x. (x,k) \<in> s} = i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1271
  shows "s tagged_division_of i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1272
  unfolding tagged_division_of apply(rule) defer apply rule
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1273
  apply(rule allI impI conjI assms)+ apply assumption
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1274
  apply(rule, rule assms, assumption) apply(rule assms, assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1275
  using assms(1,5-) apply- by blast+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1276
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1277
lemma tagged_division_ofD[dest]: assumes "s tagged_division_of i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1278
  shows "finite s" "\<And>x k. (x,k) \<in> s \<Longrightarrow> x \<in> k" "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> i"  "\<And>x k. (x,k) \<in> s \<Longrightarrow> \<exists>a b. k = {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1279
  "\<And>x1 k1 x2 k2. (x1,k1) \<in> s \<Longrightarrow> (x2,k2) \<in> s \<Longrightarrow> ~((x1,k1) = (x2,k2)) \<Longrightarrow> (interior(k1) \<inter> interior(k2) = {})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1280
  "(\<Union>{k. \<exists>x. (x,k) \<in> s} = i)" using assms unfolding tagged_division_of apply- by blast+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1281
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1282
lemma division_of_tagged_division: assumes"s tagged_division_of i"  shows "(snd ` s) division_of i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1283
proof(rule division_ofI) note assm=tagged_division_ofD[OF assms]
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1284
  show "\<Union>(snd ` s) = i" "finite (snd ` s)" using assm by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1285
  fix k assume k:"k \<in> snd ` s" then obtain xk where xk:"(xk, k) \<in> s" by auto
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  1286
  thus  "k \<subseteq> i" "k \<noteq> {}" "\<exists>a b. k = {a..b}" using assm apply- by fastforce+
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1287
  fix k' assume k':"k' \<in> snd ` s" "k \<noteq> k'" from this(1) obtain xk' where xk':"(xk', k') \<in> s" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1288
  thus "interior k \<inter> interior k' = {}" apply-apply(rule assm(5)) apply(rule xk xk')+ using k' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1289
qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1290
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1291
lemma partial_division_of_tagged_division: assumes "s tagged_partial_division_of i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1292
  shows "(snd ` s) division_of \<Union>(snd ` s)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1293
proof(rule division_ofI) note assm=tagged_partial_division_ofD[OF assms]
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1294
  show "finite (snd ` s)" "\<Union>(snd ` s) = \<Union>(snd ` s)" using assm by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1295
  fix k assume k:"k \<in> snd ` s" then obtain xk where xk:"(xk, k) \<in> s" by auto
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1296
  thus "k\<noteq>{}" "\<exists>a b. k = {a..b}" "k \<subseteq> \<Union>(snd ` s)" using assm by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1297
  fix k' assume k':"k' \<in> snd ` s" "k \<noteq> k'" from this(1) obtain xk' where xk':"(xk', k') \<in> s" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1298
  thus "interior k \<inter> interior k' = {}" apply-apply(rule assm(5)) apply(rule xk xk')+ using k' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1299
qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1300
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1301
lemma tagged_partial_division_subset: assumes "s tagged_partial_division_of i" "t \<subseteq> s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1302
  shows "t tagged_partial_division_of i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1303
  using assms unfolding tagged_partial_division_of_def using finite_subset[OF assms(2)] by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1304
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1305
lemma setsum_over_tagged_division_lemma: fixes d::"('m::ordered_euclidean_space) set \<Rightarrow> 'a::real_normed_vector"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1306
  assumes "p tagged_division_of i" "\<And>u v. {u..v} \<noteq> {} \<Longrightarrow> content {u..v} = 0 \<Longrightarrow> d {u..v} = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1307
  shows "setsum (\<lambda>(x,k). d k) p = setsum d (snd ` p)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1308
proof- note assm=tagged_division_ofD[OF assms(1)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1309
  have *:"(\<lambda>(x,k). d k) = d \<circ> snd" unfolding o_def apply(rule ext) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1310
  show ?thesis unfolding * apply(subst eq_commute) proof(rule setsum_reindex_nonzero)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1311
    show "finite p" using assm by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1312
    fix x y assume as:"x\<in>p" "y\<in>p" "x\<noteq>y" "snd x = snd y" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1313
    obtain a b where ab:"snd x = {a..b}" using assm(4)[of "fst x" "snd x"] as(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1314
    have "(fst x, snd y) \<in> p" "(fst x, snd y) \<noteq> y" unfolding as(4)[THEN sym] using as(1-3) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1315
    hence "interior (snd x) \<inter> interior (snd y) = {}" apply-apply(rule assm(5)[of "fst x" _ "fst y"]) using as by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1316
    hence "content {a..b} = 0" unfolding as(4)[THEN sym] ab content_eq_0_interior by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1317
    hence "d {a..b} = 0" apply-apply(rule assms(2)) using assm(2)[of "fst x" "snd x"] as(1) unfolding ab[THEN sym] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1318
    thus "d (snd x) = 0" unfolding ab by auto qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1319
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1320
lemma tag_in_interval: "p tagged_division_of i \<Longrightarrow> (x,k) \<in> p \<Longrightarrow> x \<in> i" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1321
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1322
lemma tagged_division_of_empty: "{} tagged_division_of {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1323
  unfolding tagged_division_of by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1324
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1325
lemma tagged_partial_division_of_trivial[simp]:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1326
 "p tagged_partial_division_of {} \<longleftrightarrow> p = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1327
  unfolding tagged_partial_division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1328
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1329
lemma tagged_division_of_trivial[simp]:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1330
 "p tagged_division_of {} \<longleftrightarrow> p = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1331
  unfolding tagged_division_of by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1332
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1333
lemma tagged_division_of_self:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1334
 "x \<in> {a..b} \<Longrightarrow> {(x,{a..b})} tagged_division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1335
  apply(rule tagged_division_ofI) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1336
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1337
lemma tagged_division_union:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1338
  assumes "p1 tagged_division_of s1"  "p2 tagged_division_of s2" "interior s1 \<inter> interior s2 = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1339
  shows "(p1 \<union> p2) tagged_division_of (s1 \<union> s2)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1340
proof(rule tagged_division_ofI) note p1=tagged_division_ofD[OF assms(1)] and p2=tagged_division_ofD[OF assms(2)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1341
  show "finite (p1 \<union> p2)" using p1(1) p2(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1342
  show "\<Union>{k. \<exists>x. (x, k) \<in> p1 \<union> p2} = s1 \<union> s2" using p1(6) p2(6) by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1343
  fix x k assume xk:"(x,k)\<in>p1\<union>p2" show "x\<in>k" "\<exists>a b. k = {a..b}" using xk p1(2,4) p2(2,4) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1344
  show "k\<subseteq>s1\<union>s2" using xk p1(3) p2(3) by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1345
  fix x' k' assume xk':"(x',k')\<in>p1\<union>p2" "(x,k) \<noteq> (x',k')"
44522
2f7e9d890efe rename subset_{interior,closure} to {interior,closure}_mono;
huffman
parents: 44514
diff changeset
  1346
  have *:"\<And>a b. a\<subseteq> s1 \<Longrightarrow> b\<subseteq> s2 \<Longrightarrow> interior a \<inter> interior b = {}" using assms(3) interior_mono by blast
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1347
  show "interior k \<inter> interior k' = {}" apply(cases "(x,k)\<in>p1", case_tac[!] "(x',k')\<in>p1")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1348
    apply(rule p1(5)) prefer 4 apply(rule *) prefer 6 apply(subst Int_commute,rule *) prefer 8 apply(rule p2(5))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1349
    using p1(3) p2(3) using xk xk' by auto qed 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1350
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1351
lemma tagged_division_unions:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1352
  assumes "finite iset" "\<forall>i\<in>iset. (pfn(i) tagged_division_of i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1353
  "\<forall>i1 \<in> iset. \<forall>i2 \<in> iset. ~(i1 = i2) \<longrightarrow> (interior(i1) \<inter> interior(i2) = {})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1354
  shows "\<Union>(pfn ` iset) tagged_division_of (\<Union>iset)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1355
proof(rule tagged_division_ofI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1356
  note assm = tagged_division_ofD[OF assms(2)[rule_format]]
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1357
  show "finite (\<Union>(pfn ` iset))" apply(rule finite_Union) using assms by auto
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1358
  have "\<Union>{k. \<exists>x. (x, k) \<in> \<Union>(pfn ` iset)} = \<Union>((\<lambda>i. \<Union>{k. \<exists>x. (x, k) \<in> pfn i}) ` iset)" by blast 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1359
  also have "\<dots> = \<Union>iset" using assm(6) by auto
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1360
  finally show "\<Union>{k. \<exists>x. (x, k) \<in> \<Union>(pfn ` iset)} = \<Union>iset" . 
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1361
  fix x k assume xk:"(x,k)\<in>\<Union>(pfn ` iset)" then obtain i where i:"i \<in> iset" "(x, k) \<in> pfn i" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1362
  show "x\<in>k" "\<exists>a b. k = {a..b}" "k \<subseteq> \<Union>iset" using assm(2-4)[OF i] using i(1) by auto
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  1363
  fix x' k' assume xk':"(x',k')\<in>\<Union>(pfn ` iset)" "(x, k) \<noteq> (x', k')" then obtain i' where i':"i' \<in> iset" "(x', k') \<in> pfn i'" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1364
  have *:"\<And>a b. i\<noteq>i' \<Longrightarrow> a\<subseteq> i \<Longrightarrow> b\<subseteq> i' \<Longrightarrow> interior a \<inter> interior b = {}" using i(1) i'(1)
44522
2f7e9d890efe rename subset_{interior,closure} to {interior,closure}_mono;
huffman
parents: 44514
diff changeset
  1365
    using assms(3)[rule_format] interior_mono by blast
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1366
  show "interior k \<inter> interior k' = {}" apply(cases "i=i'")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1367
    using assm(5)[OF i _ xk'(2)]  i'(2) using assm(3)[OF i] assm(3)[OF i'] defer apply-apply(rule *) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1368
qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1369
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1370
lemma tagged_partial_division_of_union_self:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1371
  assumes "p tagged_partial_division_of s" shows "p tagged_division_of (\<Union>(snd ` p))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1372
  apply(rule tagged_division_ofI) using tagged_partial_division_ofD[OF assms] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1373
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1374
lemma tagged_division_of_union_self: assumes "p tagged_division_of s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1375
  shows "p tagged_division_of (\<Union>(snd ` p))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1376
  apply(rule tagged_division_ofI) using tagged_division_ofD[OF assms] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1377
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1378
subsection {* Fine-ness of a partition w.r.t. a gauge. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1379
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1380
definition fine (infixr "fine" 46) where
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1381
  "d fine s \<longleftrightarrow> (\<forall>(x,k) \<in> s. k \<subseteq> d(x))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1382
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1383
lemma fineI: assumes "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> d x"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1384
  shows "d fine s" using assms unfolding fine_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1385
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1386
lemma fineD[dest]: assumes "d fine s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1387
  shows "\<And>x k. (x,k) \<in> s \<Longrightarrow> k \<subseteq> d x" using assms unfolding fine_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1388
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1389
lemma fine_inter: "(\<lambda>x. d1 x \<inter> d2 x) fine p \<longleftrightarrow> d1 fine p \<and> d2 fine p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1390
  unfolding fine_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1391
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1392
lemma fine_inters:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1393
 "(\<lambda>x. \<Inter> {f d x | d.  d \<in> s}) fine p \<longleftrightarrow> (\<forall>d\<in>s. (f d) fine p)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1394
  unfolding fine_def by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1395
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1396
lemma fine_union:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1397
  "d fine p1 \<Longrightarrow> d fine p2 \<Longrightarrow> d fine (p1 \<union> p2)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1398
  unfolding fine_def by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1399
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1400
lemma fine_unions:"(\<And>p. p \<in> ps \<Longrightarrow> d fine p) \<Longrightarrow> d fine (\<Union>ps)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1401
  unfolding fine_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1402
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1403
lemma fine_subset:  "p \<subseteq> q \<Longrightarrow> d fine q \<Longrightarrow> d fine p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1404
  unfolding fine_def by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1405
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1406
subsection {* Gauge integral. Define on compact intervals first, then use a limit. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1407
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1408
definition has_integral_compact_interval (infixr "has'_integral'_compact'_interval" 46) where
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1409
  "(f has_integral_compact_interval y) i \<equiv>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1410
        (\<forall>e>0. \<exists>d. gauge d \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1411
          (\<forall>p. p tagged_division_of i \<and> d fine p
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1412
                        \<longrightarrow> norm(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - y) < e))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1413
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1414
definition has_integral (infixr "has'_integral" 46) where 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1415
"((f::('n::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector)) has_integral y) i \<equiv>
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1416
        if (\<exists>a b. i = {a..b}) then (f has_integral_compact_interval y) i
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1417
        else (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1418
              \<longrightarrow> (\<exists>z. ((\<lambda>x. if x \<in> i then f x else 0) has_integral_compact_interval z) {a..b} \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1419
                                       norm(z - y) < e))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1420
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1421
lemma has_integral:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1422
 "(f has_integral y) ({a..b}) \<longleftrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1423
        (\<forall>e>0. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1424
                        \<longrightarrow> norm(setsum (\<lambda>(x,k). content(k) *\<^sub>R f x) p - y) < e))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1425
  unfolding has_integral_def has_integral_compact_interval_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1426
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1427
lemma has_integralD[dest]: assumes
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1428
 "(f has_integral y) ({a..b})" "e>0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1429
  obtains d where "gauge d" "\<And>p. p tagged_division_of {a..b} \<Longrightarrow> d fine p
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1430
                        \<Longrightarrow> norm(setsum (\<lambda>(x,k). content(k) *\<^sub>R f(x)) p - y) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1431
  using assms unfolding has_integral by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1432
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1433
lemma has_integral_alt:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1434
 "(f has_integral y) i \<longleftrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1435
      (if (\<exists>a b. i = {a..b}) then (f has_integral y) i
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1436
       else (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1437
                               \<longrightarrow> (\<exists>z. ((\<lambda>x. if x \<in> i then f(x) else 0)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1438
                                        has_integral z) ({a..b}) \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1439
                                       norm(z - y) < e)))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1440
  unfolding has_integral unfolding has_integral_compact_interval_def has_integral_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1441
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1442
lemma has_integral_altD:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1443
  assumes "(f has_integral y) i" "\<not> (\<exists>a b. i = {a..b})" "e>0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1444
  obtains B where "B>0" "\<forall>a b. ball 0 B \<subseteq> {a..b}\<longrightarrow> (\<exists>z. ((\<lambda>x. if x \<in> i then f(x) else 0) has_integral z) ({a..b}) \<and> norm(z - y) < e)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1445
  using assms unfolding has_integral unfolding has_integral_compact_interval_def has_integral_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1446
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1447
definition integrable_on (infixr "integrable'_on" 46) where
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1448
  "(f integrable_on i) \<equiv> \<exists>y. (f has_integral y) i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1449
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1450
definition "integral i f \<equiv> SOME y. (f has_integral y) i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1451
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1452
lemma integrable_integral[dest]:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1453
 "f integrable_on i \<Longrightarrow> (f has_integral (integral i f)) i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1454
  unfolding integrable_on_def integral_def by(rule someI_ex)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1455
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1456
lemma has_integral_integrable[intro]: "(f has_integral i) s \<Longrightarrow> f integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1457
  unfolding integrable_on_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1458
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1459
lemma has_integral_integral:"f integrable_on s \<longleftrightarrow> (f has_integral (integral s f)) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1460
  by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1461
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1462
lemma setsum_content_null:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1463
  assumes "content({a..b}) = 0" "p tagged_division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1464
  shows "setsum (\<lambda>(x,k). content k *\<^sub>R f x) p = (0::'a::real_normed_vector)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1465
proof(rule setsum_0',rule) fix y assume y:"y\<in>p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1466
  obtain x k where xk:"y = (x,k)" using surj_pair[of y] by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1467
  note assm = tagged_division_ofD(3-4)[OF assms(2) y[unfolded xk]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1468
  from this(2) guess c .. then guess d .. note c_d=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1469
  have "(\<lambda>(x, k). content k *\<^sub>R f x) y = content k *\<^sub>R f x" unfolding xk by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1470
  also have "\<dots> = 0" using content_subset[OF assm(1)[unfolded c_d]] content_pos_le[of c d]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1471
    unfolding assms(1) c_d by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1472
  finally show "(\<lambda>(x, k). content k *\<^sub>R f x) y = 0" .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1473
qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1474
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1475
subsection {* Some basic combining lemmas. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1476
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1477
lemma tagged_division_unions_exists:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1478
  assumes "finite iset" "\<forall>i \<in> iset. \<exists>p. p tagged_division_of i \<and> d fine p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1479
  "\<forall>i1\<in>iset. \<forall>i2\<in>iset. ~(i1 = i2) \<longrightarrow> (interior(i1) \<inter> interior(i2) = {})" "(\<Union>iset = i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1480
   obtains p where "p tagged_division_of i" "d fine p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1481
proof- guess pfn using bchoice[OF assms(2)] .. note pfn = conjunctD2[OF this[rule_format]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1482
  show thesis apply(rule_tac p="\<Union>(pfn ` iset)" in that) unfolding assms(4)[THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1483
    apply(rule tagged_division_unions[OF assms(1) _ assms(3)]) defer 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1484
    apply(rule fine_unions) using pfn by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1485
qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1486
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1487
subsection {* The set we're concerned with must be closed. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1488
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1489
lemma division_of_closed: "s division_of i \<Longrightarrow> closed (i::('n::ordered_euclidean_space) set)"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  1490
  unfolding division_of_def by fastforce
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1491
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1492
subsection {* General bisection principle for intervals; might be useful elsewhere. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1493
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1494
lemma interval_bisection_step:  fixes type::"'a::ordered_euclidean_space"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1495
  assumes "P {}" "(\<forall>s t. P s \<and> P t \<and> interior(s) \<inter> interior(t) = {} \<longrightarrow> P(s \<union> t))" "~(P {a..b::'a})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1496
  obtains c d where "~(P{c..d})"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1497
  "\<forall>i\<in>Basis. a\<bullet>i \<le> c\<bullet>i \<and> c\<bullet>i \<le> d\<bullet>i \<and> d\<bullet>i \<le> b\<bullet>i \<and> 2 * (d\<bullet>i - c\<bullet>i) \<le> b\<bullet>i - a\<bullet>i"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1498
proof- have "{a..b} \<noteq> {}" using assms(1,3) by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1499
  then have ab: "\<And>i. i\<in>Basis \<Longrightarrow> a \<bullet> i \<le> b \<bullet> i" by (auto simp: interval_eq_empty not_le)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1500
  { fix f have "finite f \<Longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1501
        (\<forall>s\<in>f. P s) \<Longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1502
        (\<forall>s\<in>f. \<exists>a b. s = {a..b}) \<Longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1503
        (\<forall>s\<in>f.\<forall>t\<in>f. ~(s = t) \<longrightarrow> interior(s) \<inter> interior(t) = {}) \<Longrightarrow> P(\<Union>f)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1504
    proof(induct f rule:finite_induct)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1505
      case empty show ?case using assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1506
    next case (insert x f) show ?case unfolding Union_insert apply(rule assms(2)[rule_format])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1507
        apply rule defer apply rule defer apply(rule inter_interior_unions_intervals)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1508
        using insert by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1509
    qed } note * = this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1510
  let ?A = "{{c..d} | c d::'a. \<forall>i\<in>Basis. (c\<bullet>i = a\<bullet>i) \<and> (d\<bullet>i = (a\<bullet>i + b\<bullet>i) / 2) \<or> (c\<bullet>i = (a\<bullet>i + b\<bullet>i) / 2) \<and> (d\<bullet>i = b\<bullet>i)}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1511
  let ?PP = "\<lambda>c d. \<forall>i\<in>Basis. a\<bullet>i \<le> c\<bullet>i \<and> c\<bullet>i \<le> d\<bullet>i \<and> d\<bullet>i \<le> b\<bullet>i \<and> 2 * (d\<bullet>i - c\<bullet>i) \<le> b\<bullet>i - a\<bullet>i"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1512
  { presume "\<forall>c d. ?PP c d \<longrightarrow> P {c..d} \<Longrightarrow> False"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1513
    thus thesis unfolding atomize_not not_all apply-apply(erule exE)+ apply(rule_tac c=x and d=xa in that) by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1514
  assume as:"\<forall>c d. ?PP c d \<longrightarrow> P {c..d}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1515
  have "P (\<Union> ?A)" proof(rule *, rule_tac[2-] ballI, rule_tac[4] ballI, rule_tac[4] impI) 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1516
    let ?B = "(\<lambda>s.{(\<Sum>i\<in>Basis. (if i \<in> s then a\<bullet>i else (a\<bullet>i + b\<bullet>i) / 2) *\<^sub>R i)::'a ..
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1517
      (\<Sum>i\<in>Basis. (if i \<in> s then (a\<bullet>i + b\<bullet>i) / 2 else b\<bullet>i) *\<^sub>R i)}) ` {s. s \<subseteq> Basis}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1518
    have "?A \<subseteq> ?B" proof case goal1
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1519
      then guess c unfolding mem_Collect_eq .. then guess d apply- by(erule exE,(erule conjE)+) note c_d=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1520
      have *:"\<And>a b c d. a = c \<Longrightarrow> b = d \<Longrightarrow> {a..b} = {c..d}" by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1521
      show "x\<in>?B" unfolding image_iff
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1522
        apply(rule_tac x="{i. i\<in>Basis \<and> c\<bullet>i = a\<bullet>i}" in bexI)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1523
        unfolding c_d
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1524
        apply(rule *)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1525
        apply (simp_all only: euclidean_eq_iff[where 'a='a] inner_setsum_left_Basis mem_Collect_eq simp_thms
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1526
                        cong: ball_cong)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1527
        apply safe
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1528
      proof-
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1529
        fix i :: 'a assume i: "i\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1530
        thus " c \<bullet> i = (if c \<bullet> i = a \<bullet> i then a \<bullet> i else (a \<bullet> i + b \<bullet> i) / 2)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1531
          "d \<bullet> i = (if c \<bullet> i = a \<bullet> i then (a \<bullet> i + b \<bullet> i) / 2 else b \<bullet> i)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1532
          using c_d(2)[of i] ab[OF i] by(auto simp add:field_simps)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1533
      qed qed
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1534
    thus "finite ?A" apply(rule finite_subset) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1535
    fix s assume "s\<in>?A" then guess c unfolding mem_Collect_eq .. then guess d apply- by(erule exE,(erule conjE)+)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1536
    note c_d=this[rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1537
    show "P s" unfolding c_d apply(rule as[rule_format]) proof- case goal1 thus ?case 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1538
        using c_d(2)[of i] using ab[OF `i \<in> Basis`] by auto qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1539
    show "\<exists>a b. s = {a..b}" unfolding c_d by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1540
    fix t assume "t\<in>?A" then guess e unfolding mem_Collect_eq .. then guess f apply- by(erule exE,(erule conjE)+)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1541
    note e_f=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1542
    assume "s \<noteq> t" hence "\<not> (c = e \<and> d = f)" unfolding c_d e_f by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1543
    then obtain i where "c\<bullet>i \<noteq> e\<bullet>i \<or> d\<bullet>i \<noteq> f\<bullet>i" and i':"i\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1544
      unfolding euclidean_eq_iff[where 'a='a] by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1545
    hence i:"c\<bullet>i \<noteq> e\<bullet>i" "d\<bullet>i \<noteq> f\<bullet>i" apply- apply(erule_tac[!] disjE)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1546
    proof- assume "c\<bullet>i \<noteq> e\<bullet>i" thus "d\<bullet>i \<noteq> f\<bullet>i" using c_d(2)[OF i'] e_f(2)[OF i'] by fastforce
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1547
    next   assume "d\<bullet>i \<noteq> f\<bullet>i" thus "c\<bullet>i \<noteq> e\<bullet>i" using c_d(2)[OF i'] e_f(2)[OF i'] by fastforce
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1548
    qed have *:"\<And>s t. (\<And>a. a\<in>s \<Longrightarrow> a\<in>t \<Longrightarrow> False) \<Longrightarrow> s \<inter> t = {}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1549
    show "interior s \<inter> interior t = {}" unfolding e_f c_d interior_closed_interval proof(rule *)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1550
      fix x assume "x\<in>{c<..<d}" "x\<in>{e<..<f}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1551
      hence x:"c\<bullet>i < d\<bullet>i" "e\<bullet>i < f\<bullet>i" "c\<bullet>i < f\<bullet>i" "e\<bullet>i < d\<bullet>i" unfolding mem_interval using i'
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1552
        apply-apply(erule_tac[!] x=i in ballE)+ by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1553
      show False using c_d(2)[OF i'] apply- apply(erule_tac disjE)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1554
      proof(erule_tac[!] conjE) assume as:"c \<bullet> i = a \<bullet> i" "d \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1555
        show False using e_f(2)[OF i'] and i x unfolding as by(fastforce simp add:field_simps)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1556
      next assume as:"c \<bullet> i = (a \<bullet> i + b \<bullet> i) / 2" "d \<bullet> i = b \<bullet> i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1557
        show False using e_f(2)[OF i'] and i x unfolding as by(fastforce simp add:field_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1558
      qed qed qed
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 38656
diff changeset
  1559
  also have "\<Union> ?A = {a..b}" proof(rule set_eqI,rule)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1560
    fix x assume "x\<in>\<Union>?A" then guess Y unfolding Union_iff ..
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1561
    from this(1) guess c unfolding mem_Collect_eq .. then guess d ..
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1562
    note c_d = this[THEN conjunct2,rule_format] `x\<in>Y`[unfolded this[THEN conjunct1]]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1563
    show "x\<in>{a..b}" unfolding mem_interval proof safe
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1564
      fix i :: 'a assume i: "i\<in>Basis" thus "a \<bullet> i \<le> x \<bullet> i" "x \<bullet> i \<le> b \<bullet> i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1565
        using c_d(1)[OF i] c_d(2)[unfolded mem_interval,THEN bspec, OF i] by auto qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1566
  next fix x assume x:"x\<in>{a..b}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1567
    have "\<forall>i\<in>Basis. \<exists>c d. (c = a\<bullet>i \<and> d = (a\<bullet>i + b\<bullet>i) / 2 \<or> c = (a\<bullet>i + b\<bullet>i) / 2 \<and> d = b\<bullet>i) \<and> c\<le>x\<bullet>i \<and> x\<bullet>i \<le> d"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1568
      (is "\<forall>i\<in>Basis. \<exists>c d. ?P i c d") unfolding mem_interval
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1569
    proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1570
      fix i :: 'a assume i: "i \<in> Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1571
      have "?P i (a\<bullet>i) ((a \<bullet> i + b \<bullet> i) / 2) \<or> ?P i ((a \<bullet> i + b \<bullet> i) / 2) (b\<bullet>i)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1572
        using x[unfolded mem_interval,THEN bspec, OF i] by auto thus "\<exists>c d. ?P i c d" by blast
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1573
    qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1574
    thus "x\<in>\<Union>?A"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1575
      unfolding Union_iff Bex_def mem_Collect_eq choice_Basis_iff
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1576
      apply-apply(erule exE)+ apply(rule_tac x="{xa..xaa}" in exI) unfolding mem_interval by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1577
  qed finally show False using assms by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1578
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1579
lemma interval_bisection: fixes type::"'a::ordered_euclidean_space"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1580
  assumes "P {}" "(\<forall>s t. P s \<and> P t \<and> interior(s) \<inter> interior(t) = {} \<longrightarrow> P(s \<union> t))" "\<not> P {a..b::'a}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1581
  obtains x where "x \<in> {a..b}" "\<forall>e>0. \<exists>c d. x \<in> {c..d} \<and> {c..d} \<subseteq> ball x e \<and> {c..d} \<subseteq> {a..b} \<and> ~P({c..d})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1582
proof-
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1583
  have "\<forall>x. \<exists>y. \<not> P {fst x..snd x} \<longrightarrow> (\<not> P {fst y..snd y} \<and>
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1584
    (\<forall>i\<in>Basis. fst x\<bullet>i \<le> fst y\<bullet>i \<and> fst y\<bullet>i \<le> snd y\<bullet>i \<and> snd y\<bullet>i \<le> snd x\<bullet>i \<and>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1585
                           2 * (snd y\<bullet>i - fst y\<bullet>i) \<le> snd x\<bullet>i - fst x\<bullet>i))" proof case goal1 thus ?case proof-
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1586
      presume "\<not> P {fst x..snd x} \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1587
      thus ?thesis apply(cases "P {fst x..snd x}") by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1588
    next assume as:"\<not> P {fst x..snd x}" from interval_bisection_step[of P, OF assms(1-2) as] guess c d . 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1589
      thus ?thesis apply- apply(rule_tac x="(c,d)" in exI) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1590
    qed qed then guess f apply-apply(drule choice) by(erule exE) note f=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1591
  def AB \<equiv> "\<lambda>n. (f ^^ n) (a,b)" def A \<equiv> "\<lambda>n. fst(AB n)" and B \<equiv> "\<lambda>n. snd(AB n)" note ab_def = this AB_def
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1592
  have "A 0 = a" "B 0 = b" "\<And>n. \<not> P {A(Suc n)..B(Suc n)} \<and>
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1593
    (\<forall>i\<in>Basis. A(n)\<bullet>i \<le> A(Suc n)\<bullet>i \<and> A(Suc n)\<bullet>i \<le> B(Suc n)\<bullet>i \<and> B(Suc n)\<bullet>i \<le> B(n)\<bullet>i \<and> 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1594
    2 * (B(Suc n)\<bullet>i - A(Suc n)\<bullet>i) \<le> B(n)\<bullet>i - A(n)\<bullet>i)" (is "\<And>n. ?P n")
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1595
  proof- show "A 0 = a" "B 0 = b" unfolding ab_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1596
    case goal3 note S = ab_def funpow.simps o_def id_apply show ?case
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1597
    proof(induct n) case 0 thus ?case unfolding S apply(rule f[rule_format]) using assms(3) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1598
    next case (Suc n) show ?case unfolding S apply(rule f[rule_format]) using Suc unfolding S by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1599
    qed qed note AB = this(1-2) conjunctD2[OF this(3),rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1600
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1601
  have interv:"\<And>e. 0 < e \<Longrightarrow> \<exists>n. \<forall>x\<in>{A n..B n}. \<forall>y\<in>{A n..B n}. dist x y < e"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1602
  proof- case goal1 guess n using real_arch_pow2[of "(setsum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis) / e"] .. note n=this
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1603
    show ?case apply(rule_tac x=n in exI) proof(rule,rule)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1604
      fix x y assume xy:"x\<in>{A n..B n}" "y\<in>{A n..B n}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1605
      have "dist x y \<le> setsum (\<lambda>i. abs((x - y)\<bullet>i)) Basis" unfolding dist_norm by(rule norm_le_l1)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1606
      also have "\<dots> \<le> setsum (\<lambda>i. B n\<bullet>i - A n\<bullet>i) Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1607
      proof(rule setsum_mono)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1608
        fix i :: 'a assume i: "i \<in> Basis" show "\<bar>(x - y) \<bullet> i\<bar> \<le> B n \<bullet> i - A n \<bullet> i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1609
          using xy[unfolded mem_interval,THEN bspec, OF i] by (auto simp: inner_diff_left) qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1610
      also have "\<dots> \<le> setsum (\<lambda>i. b\<bullet>i - a\<bullet>i) Basis / 2^n" unfolding setsum_divide_distrib
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1611
      proof(rule setsum_mono) case goal1 thus ?case
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1612
        proof(induct n) case 0 thus ?case unfolding AB by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1613
        next case (Suc n) have "B (Suc n) \<bullet> i - A (Suc n) \<bullet> i \<le> (B n \<bullet> i - A n \<bullet> i) / 2"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1614
            using AB(4)[of i n] using goal1 by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1615
          also have "\<dots> \<le> (b \<bullet> i - a \<bullet> i) / 2 ^ Suc n" using Suc by(auto simp add:field_simps) finally show ?case .
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1616
        qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1617
      also have "\<dots> < e" using n using goal1 by(auto simp add:field_simps) finally show "dist x y < e" .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1618
    qed qed
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1619
  { fix n m :: nat assume "m \<le> n" then have "{A n..B n} \<subseteq> {A m..B m}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1620
    proof(induct rule: inc_induct)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1621
      case (step i) show ?case
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1622
        using AB(4) by (intro order_trans[OF step(2)] subset_interval_imp) auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1623
    qed simp } note ABsubset = this 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1624
  have "\<exists>a. \<forall>n. a\<in>{A n..B n}" apply(rule decreasing_closed_nest[rule_format,OF closed_interval _ ABsubset interv])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1625
  proof- fix n show "{A n..B n} \<noteq> {}" apply(cases "0<n") using AB(3)[of "n - 1"] assms(1,3) AB(1-2) by auto qed auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1626
  then guess x0 .. note x0=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1627
  show thesis proof(rule that[rule_format,of x0])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1628
    show "x0\<in>{a..b}" using x0[of 0] unfolding AB .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1629
    fix e assume "0 < (e::real)" from interv[OF this] guess n .. note n=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1630
    show "\<exists>c d. x0 \<in> {c..d} \<and> {c..d} \<subseteq> ball x0 e \<and> {c..d} \<subseteq> {a..b} \<and> \<not> P {c..d}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1631
      apply(rule_tac x="A n" in exI,rule_tac x="B n" in exI) apply(rule,rule x0) apply rule defer 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1632
    proof show "\<not> P {A n..B n}" apply(cases "0<n") using AB(3)[of "n - 1"] assms(3) AB(1-2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1633
      show "{A n..B n} \<subseteq> ball x0 e" using n using x0[of n] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1634
      show "{A n..B n} \<subseteq> {a..b}" unfolding AB(1-2)[symmetric] apply(rule ABsubset) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1635
    qed qed qed 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1636
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1637
subsection {* Cousin's lemma. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1638
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1639
lemma fine_division_exists: assumes "gauge g" 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1640
  obtains p where "p tagged_division_of {a..b::'a::ordered_euclidean_space}" "g fine p"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1641
proof- presume "\<not> (\<exists>p. p tagged_division_of {a..b} \<and> g fine p) \<Longrightarrow> False"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1642
  then guess p unfolding atomize_not not_not .. thus thesis apply-apply(rule that[of p]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1643
next assume as:"\<not> (\<exists>p. p tagged_division_of {a..b} \<and> g fine p)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1644
  guess x apply(rule interval_bisection[of "\<lambda>s. \<exists>p. p tagged_division_of s \<and> g fine p",rule_format,OF _ _ as])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1645
    apply(rule_tac x="{}" in exI) defer apply(erule conjE exE)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1646
  proof- show "{} tagged_division_of {} \<and> g fine {}" unfolding fine_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1647
    fix s t p p' assume "p tagged_division_of s" "g fine p" "p' tagged_division_of t" "g fine p'" "interior s \<inter> interior t = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1648
    thus "\<exists>p. p tagged_division_of s \<union> t \<and> g fine p" apply-apply(rule_tac x="p \<union> p'" in exI) apply rule
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1649
      apply(rule tagged_division_union) prefer 4 apply(rule fine_union) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1650
  qed note x=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1651
  obtain e where e:"e>0" "ball x e \<subseteq> g x" using gaugeD[OF assms, of x] unfolding open_contains_ball by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1652
  from x(2)[OF e(1)] guess c d apply-apply(erule exE conjE)+ . note c_d = this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1653
  have "g fine {(x, {c..d})}" unfolding fine_def using e using c_d(2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1654
  thus False using tagged_division_of_self[OF c_d(1)] using c_d by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1655
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1656
subsection {* Basic theorems about integrals. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1657
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1658
lemma has_integral_unique: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1659
  assumes "(f has_integral k1) i" "(f has_integral k2) i" shows "k1 = k2"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1660
proof(rule ccontr) let ?e = "norm(k1 - k2) / 2" assume as:"k1 \<noteq> k2" hence e:"?e > 0" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1661
  have lem:"\<And>f::'n \<Rightarrow> 'a.  \<And> a b k1 k2.
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1662
    (f has_integral k1) ({a..b}) \<Longrightarrow> (f has_integral k2) ({a..b}) \<Longrightarrow> k1 \<noteq> k2 \<Longrightarrow> False"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1663
  proof- case goal1 let ?e = "norm(k1 - k2) / 2" from goal1(3) have e:"?e > 0" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1664
    guess d1 by(rule has_integralD[OF goal1(1) e]) note d1=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1665
    guess d2 by(rule has_integralD[OF goal1(2) e]) note d2=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1666
    guess p by(rule fine_division_exists[OF gauge_inter[OF d1(1) d2(1)],of a b]) note p=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1667
    let ?c = "(\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)" have "norm (k1 - k2) \<le> norm (?c - k2) + norm (?c - k1)"
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  1668
      using norm_triangle_ineq4[of "k1 - ?c" "k2 - ?c"] by(auto simp add:algebra_simps norm_minus_commute)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1669
    also have "\<dots> < norm (k1 - k2) / 2 + norm (k1 - k2) / 2"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1670
      apply(rule add_strict_mono) apply(rule_tac[!] d2(2) d1(2)) using p unfolding fine_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1671
    finally show False by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1672
  qed { presume "\<not> (\<exists>a b. i = {a..b}) \<Longrightarrow> False"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1673
    thus False apply-apply(cases "\<exists>a b. i = {a..b}")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1674
      using assms by(auto simp add:has_integral intro:lem[OF _ _ as]) }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1675
  assume as:"\<not> (\<exists>a b. i = {a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1676
  guess B1 by(rule has_integral_altD[OF assms(1) as,OF e]) note B1=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1677
  guess B2 by(rule has_integral_altD[OF assms(2) as,OF e]) note B2=this[rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1678
  have "\<exists>a b::'n. ball 0 B1 \<union> ball 0 B2 \<subseteq> {a..b}" apply(rule bounded_subset_closed_interval)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1679
    using bounded_Un bounded_ball by auto then guess a b apply-by(erule exE)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1680
  note ab=conjunctD2[OF this[unfolded Un_subset_iff]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1681
  guess w using B1(2)[OF ab(1)] .. note w=conjunctD2[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1682
  guess z using B2(2)[OF ab(2)] .. note z=conjunctD2[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1683
  have "z = w" using lem[OF w(1) z(1)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1684
  hence "norm (k1 - k2) \<le> norm (z - k2) + norm (w - k1)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1685
    using norm_triangle_ineq4[of "k1 - w" "k2 - z"] by(auto simp add: norm_minus_commute) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1686
  also have "\<dots> < norm (k1 - k2) / 2 + norm (k1 - k2) / 2" apply(rule add_strict_mono) by(rule_tac[!] z(2) w(2))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1687
  finally show False by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1688
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1689
lemma integral_unique[intro]:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1690
  "(f has_integral y) k \<Longrightarrow> integral k f = y"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1691
  unfolding integral_def apply(rule some_equality) by(auto intro: has_integral_unique) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1692
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1693
lemma has_integral_is_0: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1694
  assumes "\<forall>x\<in>s. f x = 0" shows "(f has_integral 0) s"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1695
proof- have lem:"\<And>a b. \<And>f::'n \<Rightarrow> 'a.
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1696
    (\<forall>x\<in>{a..b}. f(x) = 0) \<Longrightarrow> (f has_integral 0) ({a..b})" unfolding has_integral
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1697
  proof(rule,rule) fix a b e and f::"'n \<Rightarrow> 'a"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1698
    assume as:"\<forall>x\<in>{a..b}. f x = 0" "0 < (e::real)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1699
    show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) < e)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1700
      apply(rule_tac x="\<lambda>x. ball x 1" in exI)  apply(rule,rule gaugeI) unfolding centre_in_ball defer apply(rule open_ball)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1701
    proof(rule,rule,erule conjE) case goal1
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1702
      have "(\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) = 0" proof(rule setsum_0',rule)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1703
        fix x assume x:"x\<in>p" have "f (fst x) = 0" using tagged_division_ofD(2-3)[OF goal1(1), of "fst x" "snd x"] using as x by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1704
        thus "(\<lambda>(x, k). content k *\<^sub>R f x) x = 0" apply(subst surjective_pairing[of x]) unfolding split_conv by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1705
      qed thus ?case using as by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1706
    qed auto qed  { presume "\<not> (\<exists>a b. s = {a..b}) \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1707
    thus ?thesis apply-apply(cases "\<exists>a b. s = {a..b}")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1708
      using assms by(auto simp add:has_integral intro:lem) }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1709
  have *:"(\<lambda>x. if x \<in> s then f x else 0) = (\<lambda>x. 0)" apply(rule ext) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1710
  assume "\<not> (\<exists>a b. s = {a..b})" thus ?thesis apply(subst has_integral_alt) unfolding if_not_P *
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1711
  apply(rule,rule,rule_tac x=1 in exI,rule) defer apply(rule,rule,rule)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1712
  proof- fix e::real and a b assume "e>0"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1713
    thus "\<exists>z. ((\<lambda>x::'n. 0::'a) has_integral z) {a..b} \<and> norm (z - 0) < e"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1714
      apply(rule_tac x=0 in exI) apply(rule,rule lem) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1715
  qed auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1716
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1717
lemma has_integral_0[simp]: "((\<lambda>x::'n::ordered_euclidean_space. 0) has_integral 0) s"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1718
  apply(rule has_integral_is_0) by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1719
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1720
lemma has_integral_0_eq[simp]: "((\<lambda>x. 0) has_integral i) s \<longleftrightarrow> i = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1721
  using has_integral_unique[OF has_integral_0] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1722
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1723
lemma has_integral_linear: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1724
  assumes "(f has_integral y) s" "bounded_linear h" shows "((h o f) has_integral ((h y))) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1725
proof- interpret bounded_linear h using assms(2) . from pos_bounded guess B .. note B=conjunctD2[OF this,rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1726
  have lem:"\<And>f::'n \<Rightarrow> 'a. \<And> y a b.
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1727
    (f has_integral y) ({a..b}) \<Longrightarrow> ((h o f) has_integral h(y)) ({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1728
  proof(subst has_integral,rule,rule) case goal1
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1729
    from pos_bounded guess B .. note B=conjunctD2[OF this,rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1730
    have *:"e / B > 0" apply(rule divide_pos_pos) using goal1(2) B by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1731
    guess g using has_integralD[OF goal1(1) *] . note g=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1732
    show ?case apply(rule_tac x=g in exI) apply(rule,rule g(1))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1733
    proof(rule,rule,erule conjE) fix p assume as:"p tagged_division_of {a..b}" "g fine p" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1734
      have *:"\<And>x k. h ((\<lambda>(x, k). content k *\<^sub>R f x) x) = (\<lambda>(x, k). h (content k *\<^sub>R f x)) x" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1735
      have "(\<Sum>(x, k)\<in>p. content k *\<^sub>R (h \<circ> f) x) = setsum (h \<circ> (\<lambda>(x, k). content k *\<^sub>R f x)) p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1736
        unfolding o_def unfolding scaleR[THEN sym] * by simp
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1737
      also have "\<dots> = h (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)" using setsum[of "\<lambda>(x,k). content k *\<^sub>R f x" p] using as by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1738
      finally have *:"(\<Sum>(x, k)\<in>p. content k *\<^sub>R (h \<circ> f) x) = h (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)" .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1739
      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (h \<circ> f) x) - h y) < e" unfolding * diff[THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1740
        apply(rule le_less_trans[OF B(2)]) using g(2)[OF as] B(1) by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1741
    qed qed { presume "\<not> (\<exists>a b. s = {a..b}) \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1742
    thus ?thesis apply-apply(cases "\<exists>a b. s = {a..b}") using assms by(auto simp add:has_integral intro!:lem) }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1743
  assume as:"\<not> (\<exists>a b. s = {a..b})" thus ?thesis apply(subst has_integral_alt) unfolding if_not_P
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1744
  proof(rule,rule) fix e::real  assume e:"0<e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1745
    have *:"0 < e/B" by(rule divide_pos_pos,rule e,rule B(1))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1746
    guess M using has_integral_altD[OF assms(1) as *,rule_format] . note M=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1747
    show "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow> (\<exists>z. ((\<lambda>x. if x \<in> s then (h \<circ> f) x else 0) has_integral z) {a..b} \<and> norm (z - h y) < e)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1748
      apply(rule_tac x=M in exI) apply(rule,rule M(1))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1749
    proof(rule,rule,rule) case goal1 guess z using M(2)[OF goal1(1)] .. note z=conjunctD2[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1750
      have *:"(\<lambda>x. if x \<in> s then (h \<circ> f) x else 0) = h \<circ> (\<lambda>x. if x \<in> s then f x else 0)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1751
        unfolding o_def apply(rule ext) using zero by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1752
      show ?case apply(rule_tac x="h z" in exI,rule) unfolding * apply(rule lem[OF z(1)]) unfolding diff[THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1753
        apply(rule le_less_trans[OF B(2)]) using B(1) z(2) by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1754
    qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1755
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1756
lemma has_integral_cmul:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1757
  shows "(f has_integral k) s \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x) has_integral (c *\<^sub>R k)) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1758
  unfolding o_def[THEN sym] apply(rule has_integral_linear,assumption)
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  1759
  by(rule bounded_linear_scaleR_right)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1760
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1761
lemma has_integral_cmult_real:
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1762
  fixes c :: real
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1763
  assumes "c \<noteq> 0 \<Longrightarrow> (f has_integral x) A"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1764
  shows "((\<lambda>x. c * f x) has_integral c * x) A"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1765
proof cases
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1766
  assume "c \<noteq> 0"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1767
  from has_integral_cmul[OF assms[OF this], of c] show ?thesis
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1768
    unfolding real_scaleR_def .
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1769
qed simp
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1770
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1771
lemma has_integral_neg:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1772
  shows "(f has_integral k) s \<Longrightarrow> ((\<lambda>x. -(f x)) has_integral (-k)) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1773
  apply(drule_tac c="-1" in has_integral_cmul) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1774
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1775
lemma has_integral_add: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1776
  assumes "(f has_integral k) s" "(g has_integral l) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1777
  shows "((\<lambda>x. f x + g x) has_integral (k + l)) s"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1778
proof- have lem:"\<And>f g::'n \<Rightarrow> 'a. \<And>a b k l.
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1779
    (f has_integral k) ({a..b}) \<Longrightarrow> (g has_integral l) ({a..b}) \<Longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1780
     ((\<lambda>x. f(x) + g(x)) has_integral (k + l)) ({a..b})" proof- case goal1
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1781
    show ?case unfolding has_integral proof(rule,rule) fix e::real assume e:"e>0" hence *:"e/2>0" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1782
      guess d1 using has_integralD[OF goal1(1) *] . note d1=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1783
      guess d2 using has_integralD[OF goal1(2) *] . note d2=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1784
      show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (f x + g x)) - (k + l)) < e)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1785
        apply(rule_tac x="\<lambda>x. (d1 x) \<inter> (d2 x)" in exI) apply(rule,rule gauge_inter[OF d1(1) d2(1)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1786
      proof(rule,rule,erule conjE) fix p assume as:"p tagged_division_of {a..b}" "(\<lambda>x. d1 x \<inter> d2 x) fine p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1787
        have *:"(\<Sum>(x, k)\<in>p. content k *\<^sub>R (f x + g x)) = (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p. content k *\<^sub>R g x)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1788
          unfolding scaleR_right_distrib setsum_addf[of "\<lambda>(x,k). content k *\<^sub>R f x" "\<lambda>(x,k). content k *\<^sub>R g x" p,THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1789
          by(rule setsum_cong2,auto)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1790
        have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (f x + g x)) - (k + l)) = norm (((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k) + ((\<Sum>(x, k)\<in>p. content k *\<^sub>R g x) - l))"
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  1791
          unfolding * by(auto simp add:algebra_simps) also let ?res = "\<dots>"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1792
        from as have *:"d1 fine p" "d2 fine p" unfolding fine_inter by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1793
        have "?res < e/2 + e/2" apply(rule le_less_trans[OF norm_triangle_ineq])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1794
          apply(rule add_strict_mono) using d1(2)[OF as(1) *(1)] and d2(2)[OF as(1) *(2)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1795
        finally show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R (f x + g x)) - (k + l)) < e" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1796
      qed qed qed { presume "\<not> (\<exists>a b. s = {a..b}) \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1797
    thus ?thesis apply-apply(cases "\<exists>a b. s = {a..b}") using assms by(auto simp add:has_integral intro!:lem) }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1798
  assume as:"\<not> (\<exists>a b. s = {a..b})" thus ?thesis apply(subst has_integral_alt) unfolding if_not_P
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1799
  proof(rule,rule) case goal1 hence *:"e/2 > 0" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1800
    from has_integral_altD[OF assms(1) as *] guess B1 . note B1=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1801
    from has_integral_altD[OF assms(2) as *] guess B2 . note B2=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1802
    show ?case apply(rule_tac x="max B1 B2" in exI) apply(rule,rule min_max.less_supI1,rule B1)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1803
    proof(rule,rule,rule) fix a b assume "ball 0 (max B1 B2) \<subseteq> {a..b::'n}"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1804
      hence *:"ball 0 B1 \<subseteq> {a..b::'n}" "ball 0 B2 \<subseteq> {a..b::'n}" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1805
      guess w using B1(2)[OF *(1)] .. note w=conjunctD2[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1806
      guess z using B2(2)[OF *(2)] .. note z=conjunctD2[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1807
      have *:"\<And>x. (if x \<in> s then f x + g x else 0) = (if x \<in> s then f x else 0) + (if x \<in> s then g x else 0)" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1808
      show "\<exists>z. ((\<lambda>x. if x \<in> s then f x + g x else 0) has_integral z) {a..b} \<and> norm (z - (k + l)) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1809
        apply(rule_tac x="w + z" in exI) apply(rule,rule lem[OF w(1) z(1), unfolded *[THEN sym]])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1810
        using norm_triangle_ineq[of "w - k" "z - l"] w(2) z(2) by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1811
    qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1812
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1813
lemma has_integral_sub:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1814
  shows "(f has_integral k) s \<Longrightarrow> (g has_integral l) s \<Longrightarrow> ((\<lambda>x. f(x) - g(x)) has_integral (k - l)) s"
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  1815
  using has_integral_add[OF _ has_integral_neg,of f k s g l] unfolding algebra_simps by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1816
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1817
lemma integral_0: "integral s (\<lambda>x::'n::ordered_euclidean_space. 0::'m::real_normed_vector) = 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1818
  by(rule integral_unique has_integral_0)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1819
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1820
lemma integral_add:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1821
  shows "f integrable_on s \<Longrightarrow> g integrable_on s \<Longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1822
   integral s (\<lambda>x. f x + g x) = integral s f + integral s g"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1823
  apply(rule integral_unique) apply(drule integrable_integral)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1824
  apply(rule has_integral_add) by assumption+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1825
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1826
lemma integral_cmul:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1827
  shows "f integrable_on s \<Longrightarrow> integral s (\<lambda>x. c *\<^sub>R f x) = c *\<^sub>R integral s f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1828
  apply(rule integral_unique) apply(drule integrable_integral)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1829
  apply(rule has_integral_cmul) by assumption+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1830
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1831
lemma integral_neg:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1832
  shows "f integrable_on s \<Longrightarrow> integral s (\<lambda>x. - f x) = - integral s f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1833
  apply(rule integral_unique) apply(drule integrable_integral)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1834
  apply(rule has_integral_neg) by assumption+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1835
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1836
lemma integral_sub:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1837
  shows "f integrable_on s \<Longrightarrow> g integrable_on s \<Longrightarrow> integral s (\<lambda>x. f x - g x) = integral s f - integral s g"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1838
  apply(rule integral_unique) apply(drule integrable_integral)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1839
  apply(rule has_integral_sub) by assumption+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1840
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1841
lemma integrable_0: "(\<lambda>x. 0) integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1842
  unfolding integrable_on_def using has_integral_0 by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1843
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1844
lemma integrable_add:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1845
  shows "f integrable_on s \<Longrightarrow> g integrable_on s \<Longrightarrow> (\<lambda>x. f x + g x) integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1846
  unfolding integrable_on_def by(auto intro: has_integral_add)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1847
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1848
lemma integrable_cmul:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1849
  shows "f integrable_on s \<Longrightarrow> (\<lambda>x. c *\<^sub>R f(x)) integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1850
  unfolding integrable_on_def by(auto intro: has_integral_cmul)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1851
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1852
lemma integrable_on_cmult_iff:
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1853
  fixes c :: real assumes "c \<noteq> 0"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1854
  shows "(\<lambda>x. c * f x) integrable_on s \<longleftrightarrow> f integrable_on s"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1855
  using integrable_cmul[of "\<lambda>x. c * f x" s "1 / c"] integrable_cmul[of f s c] `c \<noteq> 0`
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1856
  by auto
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  1857
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1858
lemma integrable_neg:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1859
  shows "f integrable_on s \<Longrightarrow> (\<lambda>x. -f(x)) integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1860
  unfolding integrable_on_def by(auto intro: has_integral_neg)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1861
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1862
lemma integrable_sub:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1863
  shows "f integrable_on s \<Longrightarrow> g integrable_on s \<Longrightarrow> (\<lambda>x. f x - g x) integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1864
  unfolding integrable_on_def by(auto intro: has_integral_sub)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1865
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1866
lemma integrable_linear:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1867
  shows "f integrable_on s \<Longrightarrow> bounded_linear h \<Longrightarrow> (h o f) integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1868
  unfolding integrable_on_def by(auto intro: has_integral_linear)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1869
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1870
lemma integral_linear:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1871
  shows "f integrable_on s \<Longrightarrow> bounded_linear h \<Longrightarrow> integral s (h o f) = h(integral s f)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1872
  apply(rule has_integral_unique) defer unfolding has_integral_integral 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1873
  apply(drule has_integral_linear,assumption,assumption) unfolding has_integral_integral[THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1874
  apply(rule integrable_linear) by assumption+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1875
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1876
lemma integral_component_eq[simp]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1877
  assumes "f integrable_on s" shows "integral s (\<lambda>x. f x \<bullet> k) = integral s f \<bullet> k"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1878
  unfolding integral_linear[OF assms(1) bounded_linear_component,unfolded o_def] ..
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  1879
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1880
lemma has_integral_setsum:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1881
  assumes "finite t" "\<forall>a\<in>t. ((f a) has_integral (i a)) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1882
  shows "((\<lambda>x. setsum (\<lambda>a. f a x) t) has_integral (setsum i t)) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1883
proof(insert assms(1) subset_refl[of t],induct rule:finite_subset_induct)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1884
  case (insert x F) show ?case unfolding setsum_insert[OF insert(1,3)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1885
    apply(rule has_integral_add) using insert assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1886
qed auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1887
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1888
lemma integral_setsum:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1889
  shows "finite t \<Longrightarrow> \<forall>a\<in>t. (f a) integrable_on s \<Longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1890
  integral s (\<lambda>x. setsum (\<lambda>a. f a x) t) = setsum (\<lambda>a. integral s (f a)) t"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1891
  apply(rule integral_unique) apply(rule has_integral_setsum)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1892
  using integrable_integral by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1893
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1894
lemma integrable_setsum:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1895
  shows "finite t \<Longrightarrow> \<forall>a \<in> t.(f a) integrable_on s \<Longrightarrow> (\<lambda>x. setsum (\<lambda>a. f a x) t) integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1896
  unfolding integrable_on_def apply(drule bchoice) using has_integral_setsum[of t] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1897
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1898
lemma has_integral_eq:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1899
  assumes "\<forall>x\<in>s. f x = g x" "(f has_integral k) s" shows "(g has_integral k) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1900
  using has_integral_sub[OF assms(2), of "\<lambda>x. f x - g x" 0]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1901
  using has_integral_is_0[of s "\<lambda>x. f x - g x"] using assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1902
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1903
lemma integrable_eq:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1904
  shows "\<forall>x\<in>s. f x = g x \<Longrightarrow> f integrable_on s \<Longrightarrow> g integrable_on s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1905
  unfolding integrable_on_def using has_integral_eq[of s f g] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1906
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1907
lemma has_integral_eq_eq:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1908
  shows "\<forall>x\<in>s. f x = g x \<Longrightarrow> ((f has_integral k) s \<longleftrightarrow> (g has_integral k) s)"
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36359
diff changeset
  1909
  using has_integral_eq[of s f g] has_integral_eq[of s g f] by rule auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1910
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1911
lemma has_integral_null[dest]:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1912
  assumes "content({a..b}) = 0" shows  "(f has_integral 0) ({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1913
  unfolding has_integral apply(rule,rule,rule_tac x="\<lambda>x. ball x 1" in exI,rule) defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1914
proof(rule,rule,erule conjE) fix e::real assume e:"e>0" thus "gauge (\<lambda>x. ball x 1)" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1915
  fix p assume p:"p tagged_division_of {a..b}" (*"(\<lambda>x. ball x 1) fine p"*)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1916
  have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) = 0" unfolding norm_eq_zero diff_0_right
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1917
    using setsum_content_null[OF assms(1) p, of f] . 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1918
  thus "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) < e" using e by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1919
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1920
lemma has_integral_null_eq[simp]:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1921
  shows "content({a..b}) = 0 \<Longrightarrow> ((f has_integral i) ({a..b}) \<longleftrightarrow> i = 0)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1922
  apply rule apply(rule has_integral_unique,assumption) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1923
  apply(drule has_integral_null,assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1924
  apply(drule has_integral_null) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1925
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1926
lemma integral_null[dest]: shows "content({a..b}) = 0 \<Longrightarrow> integral({a..b}) f = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1927
  by(rule integral_unique,drule has_integral_null)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1928
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1929
lemma integrable_on_null[dest]: shows "content({a..b}) = 0 \<Longrightarrow> f integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1930
  unfolding integrable_on_def apply(drule has_integral_null) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1931
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1932
lemma has_integral_empty[intro]: shows "(f has_integral 0) {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1933
  unfolding empty_as_interval apply(rule has_integral_null) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1934
  using content_empty unfolding empty_as_interval .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1935
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1936
lemma has_integral_empty_eq[simp]: shows "(f has_integral i) {} \<longleftrightarrow> i = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1937
  apply(rule,rule has_integral_unique,assumption) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1938
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1939
lemma integrable_on_empty[intro]: shows "f integrable_on {}" unfolding integrable_on_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1940
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1941
lemma integral_empty[simp]: shows "integral {} f = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1942
  apply(rule integral_unique) using has_integral_empty .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1943
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1944
lemma has_integral_refl[intro]: shows "(f has_integral 0) {a..a}" "(f has_integral 0) {a::'a::ordered_euclidean_space}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1945
proof-
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1946
  have *:"{a} = {a..a}" apply(rule set_eqI) unfolding mem_interval singleton_iff euclidean_eq_iff[where 'a='a]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  1947
    apply safe prefer 3 apply(erule_tac x=b in ballE) by(auto simp add: field_simps)
35540
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35292
diff changeset
  1948
  show "(f has_integral 0) {a..a}" "(f has_integral 0) {a}" unfolding *
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35292
diff changeset
  1949
    apply(rule_tac[!] has_integral_null) unfolding content_eq_0_interior
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35292
diff changeset
  1950
    unfolding interior_closed_interval using interval_sing by auto qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1951
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1952
lemma integrable_on_refl[intro]: shows "f integrable_on {a..a}" unfolding integrable_on_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1953
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1954
lemma integral_refl: shows "integral {a..a} f = 0" apply(rule integral_unique) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1955
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1956
subsection {* Cauchy-type criterion for integrability. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1957
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1958
(* XXXXXXX *)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  1959
lemma integrable_cauchy: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::{real_normed_vector,complete_space}" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1960
  shows "f integrable_on {a..b} \<longleftrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1961
  (\<forall>e>0.\<exists>d. gauge d \<and> (\<forall>p1 p2. p1 tagged_division_of {a..b} \<and> d fine p1 \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1962
                            p2 tagged_division_of {a..b} \<and> d fine p2
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1963
                            \<longrightarrow> norm(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p1 -
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1964
                                     setsum (\<lambda>(x,k). content k *\<^sub>R f x) p2) < e))" (is "?l = (\<forall>e>0. \<exists>d. ?P e d)")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1965
proof assume ?l
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1966
  then guess y unfolding integrable_on_def has_integral .. note y=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1967
  show "\<forall>e>0. \<exists>d. ?P e d" proof(rule,rule) case goal1 hence "e/2 > 0" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1968
    then guess d apply- apply(drule y[rule_format]) by(erule exE,erule conjE) note d=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1969
    show ?case apply(rule_tac x=d in exI,rule,rule d) apply(rule,rule,rule,(erule conjE)+)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1970
    proof- fix p1 p2 assume as:"p1 tagged_division_of {a..b}" "d fine p1" "p2 tagged_division_of {a..b}" "d fine p2"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1971
      show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e"
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  1972
        apply(rule dist_triangle_half_l[where y=y,unfolded dist_norm])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1973
        using d(2)[OF conjI[OF as(1-2)]] d(2)[OF conjI[OF as(3-4)]] .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1974
    qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1975
next assume "\<forall>e>0. \<exists>d. ?P e d" hence "\<forall>n::nat. \<exists>d. ?P (inverse(real (n + 1))) d" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1976
  from choice[OF this] guess d .. note d=conjunctD2[OF this[rule_format],rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1977
  have "\<And>n. gauge (\<lambda>x. \<Inter>{d i x |i. i \<in> {0..n}})" apply(rule gauge_inters) using d(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1978
  hence "\<forall>n. \<exists>p. p tagged_division_of {a..b} \<and> (\<lambda>x. \<Inter>{d i x |i. i \<in> {0..n}}) fine p" apply-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1979
  proof case goal1 from this[of n] show ?case apply(drule_tac fine_division_exists) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1980
  from choice[OF this] guess p .. note p = conjunctD2[OF this[rule_format]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1981
  have dp:"\<And>i n. i\<le>n \<Longrightarrow> d i fine p n" using p(2) unfolding fine_inters by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1982
  have "Cauchy (\<lambda>n. setsum (\<lambda>(x,k). content k *\<^sub>R (f x)) (p n))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1983
  proof(rule CauchyI) case goal1 then guess N unfolding real_arch_inv[of e] .. note N=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1984
    show ?case apply(rule_tac x=N in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1985
    proof(rule,rule,rule,rule) fix m n assume mn:"N \<le> m" "N \<le> n" have *:"N = (N - 1) + 1" using N by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1986
      show "norm ((\<Sum>(x, k)\<in>p m. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p n. content k *\<^sub>R f x)) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1987
        apply(rule less_trans[OF _ N[THEN conjunct2,THEN conjunct2]]) apply(subst *) apply(rule d(2))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1988
        using dp p(1) using mn by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1989
    qed qed
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  1990
  then guess y unfolding convergent_eq_cauchy[THEN sym] .. note y=this[THEN LIMSEQ_D]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1991
  show ?l unfolding integrable_on_def has_integral apply(rule_tac x=y in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1992
  proof(rule,rule) fix e::real assume "e>0" hence *:"e/2 > 0" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1993
    then guess N1 unfolding real_arch_inv[of "e/2"] .. note N1=this hence N1':"N1 = N1 - 1 + 1" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1994
    guess N2 using y[OF *] .. note N2=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1995
    show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - y) < e)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1996
      apply(rule_tac x="d (N1 + N2)" in exI) apply rule defer 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1997
    proof(rule,rule,erule conjE) show "gauge (d (N1 + N2))" using d by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1998
      fix q assume as:"q tagged_division_of {a..b}" "d (N1 + N2) fine q"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  1999
      have *:"inverse (real (N1 + N2 + 1)) < e / 2" apply(rule less_trans) using N1 by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2000
      show "norm ((\<Sum>(x, k)\<in>q. content k *\<^sub>R f x) - y) < e" apply(rule norm_triangle_half_r)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2001
        apply(rule less_trans[OF _ *]) apply(subst N1', rule d(2)[of "p (N1+N2)"]) defer
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  2002
        using N2[rule_format,of "N1+N2"]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2003
        using as dp[of "N1 - 1 + 1 + N2" "N1 + N2"] using p(1)[of "N1 + N2"] using N1 by auto qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2004
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2005
subsection {* Additivity of integral on abutting intervals. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2006
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2007
lemma interval_split:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2008
  fixes a::"'a::ordered_euclidean_space" assumes "k \<in> Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2009
  shows
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2010
    "{a..b} \<inter> {x. x\<bullet>k \<le> c} = {a .. (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) c else b\<bullet>i) *\<^sub>R i)}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2011
    "{a..b} \<inter> {x. x\<bullet>k \<ge> c} = {(\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) c else a\<bullet>i) *\<^sub>R i) .. b}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2012
  apply(rule_tac[!] set_eqI) unfolding Int_iff mem_interval mem_Collect_eq using assms
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2013
  by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2014
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2015
lemma content_split: fixes a::"'a::ordered_euclidean_space" assumes "k\<in>Basis" shows
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2016
  "content {a..b} = content({a..b} \<inter> {x. x\<bullet>k \<le> c}) + content({a..b} \<inter> {x. x\<bullet>k >= c})"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2017
proof cases
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2018
  note simps = interval_split[OF assms] content_closed_interval_cases eucl_le[where 'a='a]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2019
  have *:"Basis = insert k (Basis - {k})" "\<And>x. finite (Basis-{x})" "\<And>x. x\<notin>Basis-{x}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2020
    using assms by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2021
  have *:"\<And>X Y Z. (\<Prod>i\<in>Basis. Z i (if i = k then X else Y i)) = Z k X * (\<Prod>i\<in>Basis-{k}. Z i (Y i))"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2022
    "(\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i) = (\<Prod>i\<in>Basis-{k}. b\<bullet>i - a\<bullet>i) * (b\<bullet>k - a\<bullet>k)" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2023
    apply(subst *(1)) defer apply(subst *(1)) unfolding setprod_insert[OF *(2-)] by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2024
  assume as:"a\<le>b" moreover have "\<And>x. min (b \<bullet> k) c = max (a \<bullet> k) c
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2025
    \<Longrightarrow> x* (b\<bullet>k - a\<bullet>k) = x*(max (a \<bullet> k) c - a \<bullet> k) + x*(b \<bullet> k - max (a \<bullet> k) c)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2026
    by  (auto simp add:field_simps)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2027
  moreover have **:"(\<Prod>i\<in>Basis. ((\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) *\<^sub>R i) \<bullet> i - a \<bullet> i)) = 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2028
      (\<Prod>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) - a \<bullet> i)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2029
    "(\<Prod>i\<in>Basis. b \<bullet> i - ((\<Sum>i\<in>Basis. (if i = k then max (a \<bullet> k) c else a \<bullet> i) *\<^sub>R i) \<bullet> i)) =
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2030
      (\<Prod>i\<in>Basis. b \<bullet> i - (if i = k then max (a \<bullet> k) c else a \<bullet> i))"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2031
    by (auto intro!: setprod_cong)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2032
  have "\<not> a \<bullet> k \<le> c \<Longrightarrow> \<not> c \<le> b \<bullet> k \<Longrightarrow> False"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2033
    unfolding not_le using as[unfolded eucl_le[where 'a='a],rule_format,of k] assms by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2034
  ultimately show ?thesis using assms unfolding simps **
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2035
    unfolding *(1)[of "\<lambda>i x. b\<bullet>i - x"] *(1)[of "\<lambda>i x. x - a\<bullet>i"] unfolding *(2)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2036
    by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2037
next
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2038
  assume "\<not> a \<le> b" then have "{a .. b} = {}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2039
    unfolding interval_eq_empty by (auto simp: eucl_le[where 'a='a] not_le)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2040
  then show ?thesis by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2041
qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2042
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2043
lemma division_split_left_inj: fixes type::"'a::ordered_euclidean_space"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2044
  assumes "d division_of i" "k1 \<in> d" "k2 \<in> d"  "k1 \<noteq> k2" 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2045
  "k1 \<inter> {x::'a. x\<bullet>k \<le> c} = k2 \<inter> {x. x\<bullet>k \<le> c}"and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2046
  shows "content(k1 \<inter> {x. x\<bullet>k \<le> c}) = 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2047
proof- note d=division_ofD[OF assms(1)]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2048
  have *:"\<And>a b::'a. \<And> c. (content({a..b} \<inter> {x. x\<bullet>k \<le> c}) = 0 \<longleftrightarrow> interior({a..b} \<inter> {x. x\<bullet>k \<le> c}) = {})"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2049
    unfolding  interval_split[OF k] content_eq_0_interior by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2050
  guess u1 v1 using d(4)[OF assms(2)] apply-by(erule exE)+ note uv1=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2051
  guess u2 v2 using d(4)[OF assms(3)] apply-by(erule exE)+ note uv2=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2052
  have **:"\<And>s t u. s \<inter> t = {} \<Longrightarrow> u \<subseteq> s \<Longrightarrow> u \<subseteq> t \<Longrightarrow> u = {}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2053
  show ?thesis unfolding uv1 uv2 * apply(rule **[OF d(5)[OF assms(2-4)]])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2054
    defer apply(subst assms(5)[unfolded uv1 uv2]) unfolding uv1 uv2 by auto qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2055
 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2056
lemma division_split_right_inj: fixes type::"'a::ordered_euclidean_space"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2057
  assumes "d division_of i" "k1 \<in> d" "k2 \<in> d"  "k1 \<noteq> k2"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2058
  "k1 \<inter> {x::'a. x\<bullet>k \<ge> c} = k2 \<inter> {x. x\<bullet>k \<ge> c}" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2059
  shows "content(k1 \<inter> {x. x\<bullet>k \<ge> c}) = 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2060
proof- note d=division_ofD[OF assms(1)]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2061
  have *:"\<And>a b::'a. \<And> c. (content({a..b} \<inter> {x. x\<bullet>k >= c}) = 0 \<longleftrightarrow> interior({a..b} \<inter> {x. x\<bullet>k >= c}) = {})"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2062
    unfolding interval_split[OF k] content_eq_0_interior by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2063
  guess u1 v1 using d(4)[OF assms(2)] apply-by(erule exE)+ note uv1=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2064
  guess u2 v2 using d(4)[OF assms(3)] apply-by(erule exE)+ note uv2=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2065
  have **:"\<And>s t u. s \<inter> t = {} \<Longrightarrow> u \<subseteq> s \<Longrightarrow> u \<subseteq> t \<Longrightarrow> u = {}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2066
  show ?thesis unfolding uv1 uv2 * apply(rule **[OF d(5)[OF assms(2-4)]])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2067
    defer apply(subst assms(5)[unfolded uv1 uv2]) unfolding uv1 uv2 by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2068
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2069
lemma tagged_division_split_left_inj: fixes x1::"'a::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2070
  assumes "d tagged_division_of i" "(x1,k1) \<in> d" "(x2,k2) \<in> d" "k1 \<noteq> k2"  "k1 \<inter> {x. x\<bullet>k \<le> c} = k2 \<inter> {x. x\<bullet>k \<le> c}" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2071
  and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2072
  shows "content(k1 \<inter> {x. x\<bullet>k \<le> c}) = 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2073
proof- have *:"\<And>a b c. (a,b) \<in> c \<Longrightarrow> b \<in> snd ` c" unfolding image_iff apply(rule_tac x="(a,b)" in bexI) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2074
  show ?thesis apply(rule division_split_left_inj[OF division_of_tagged_division[OF assms(1)]])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2075
    apply(rule_tac[1-2] *) using assms(2-) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2076
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2077
lemma tagged_division_split_right_inj: fixes x1::"'a::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2078
  assumes "d tagged_division_of i" "(x1,k1) \<in> d" "(x2,k2) \<in> d" "k1 \<noteq> k2"  "k1 \<inter> {x. x\<bullet>k \<ge> c} = k2 \<inter> {x. x\<bullet>k \<ge> c}" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2079
  and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2080
  shows "content(k1 \<inter> {x. x\<bullet>k \<ge> c}) = 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2081
proof- have *:"\<And>a b c. (a,b) \<in> c \<Longrightarrow> b \<in> snd ` c" unfolding image_iff apply(rule_tac x="(a,b)" in bexI) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2082
  show ?thesis apply(rule division_split_right_inj[OF division_of_tagged_division[OF assms(1)]])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2083
    apply(rule_tac[1-2] *) using assms(2-) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2084
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2085
lemma division_split: fixes a::"'a::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2086
  assumes "p division_of {a..b}" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2087
  shows "{l \<inter> {x. x\<bullet>k \<le> c} | l. l \<in> p \<and> ~(l \<inter> {x. x\<bullet>k \<le> c} = {})} division_of({a..b} \<inter> {x. x\<bullet>k \<le> c})" (is "?p1 division_of ?I1") and 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2088
        "{l \<inter> {x. x\<bullet>k \<ge> c} | l. l \<in> p \<and> ~(l \<inter> {x. x\<bullet>k \<ge> c} = {})} division_of ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" (is "?p2 division_of ?I2")
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2089
proof(rule_tac[!] division_ofI) note p=division_ofD[OF assms(1)]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2090
  show "finite ?p1" "finite ?p2" using p(1) by auto show "\<Union>?p1 = ?I1" "\<Union>?p2 = ?I2" unfolding p(6)[THEN sym] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2091
  { fix k assume "k\<in>?p1" then guess l unfolding mem_Collect_eq apply-by(erule exE,(erule conjE)+) note l=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2092
    guess u v using p(4)[OF l(2)] apply-by(erule exE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2093
    show "k\<subseteq>?I1" "k \<noteq> {}" "\<exists>a b. k = {a..b}" unfolding l
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2094
      using p(2-3)[OF l(2)] l(3) unfolding uv apply- prefer 3 apply(subst interval_split[OF k]) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2095
    fix k' assume "k'\<in>?p1" then guess l' unfolding mem_Collect_eq apply-by(erule exE,(erule conjE)+) note l'=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2096
    assume "k\<noteq>k'" thus "interior k \<inter> interior k' = {}" unfolding l l' using p(5)[OF l(2) l'(2)] by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2097
  { fix k assume "k\<in>?p2" then guess l unfolding mem_Collect_eq apply-by(erule exE,(erule conjE)+) note l=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2098
    guess u v using p(4)[OF l(2)] apply-by(erule exE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2099
    show "k\<subseteq>?I2" "k \<noteq> {}" "\<exists>a b. k = {a..b}" unfolding l
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2100
      using p(2-3)[OF l(2)] l(3) unfolding uv apply- prefer 3 apply(subst interval_split[OF k]) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2101
    fix k' assume "k'\<in>?p2" then guess l' unfolding mem_Collect_eq apply-by(erule exE,(erule conjE)+) note l'=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2102
    assume "k\<noteq>k'" thus "interior k \<inter> interior k' = {}" unfolding l l' using p(5)[OF l(2) l'(2)] by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2103
qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2104
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2105
lemma has_integral_split: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2106
  assumes "(f has_integral i) ({a..b} \<inter> {x. x\<bullet>k \<le> c})"  "(f has_integral j) ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" and k:"k\<in>Basis"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2107
  shows "(f has_integral (i + j)) ({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2108
proof(unfold has_integral,rule,rule) case goal1 hence e:"e/2>0" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2109
  guess d1 using has_integralD[OF assms(1)[unfolded interval_split[OF k]] e] . note d1=this[unfolded interval_split[THEN sym,OF k]]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2110
  guess d2 using has_integralD[OF assms(2)[unfolded interval_split[OF k]] e] . note d2=this[unfolded interval_split[THEN sym,OF k]]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2111
  let ?d = "\<lambda>x. if x\<bullet>k = c then (d1 x \<inter> d2 x) else ball x (abs(x\<bullet>k - c)) \<inter> d1 x \<inter> d2 x"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2112
  show ?case apply(rule_tac x="?d" in exI,rule) defer apply(rule,rule,(erule conjE)+)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2113
  proof- show "gauge ?d" using d1(1) d2(1) unfolding gauge_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2114
    fix p assume "p tagged_division_of {a..b}" "?d fine p" note p = this tagged_division_ofD[OF this(1)]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2115
    have lem0:"\<And>x kk. (x,kk) \<in> p \<Longrightarrow> ~(kk \<inter> {x. x\<bullet>k \<le> c} = {}) \<Longrightarrow> x\<bullet>k \<le> c"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2116
         "\<And>x kk. (x,kk) \<in> p \<Longrightarrow> ~(kk \<inter> {x. x\<bullet>k \<ge> c} = {}) \<Longrightarrow> x\<bullet>k \<ge> c"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2117
    proof- fix x kk assume as:"(x,kk)\<in>p"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2118
      show "~(kk \<inter> {x. x\<bullet>k \<le> c} = {}) \<Longrightarrow> x\<bullet>k \<le> c"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2119
      proof(rule ccontr) case goal1
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2120
        from this(2)[unfolded not_le] have "kk \<subseteq> ball x \<bar>x \<bullet> k - c\<bar>"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2121
          using p(2)[unfolded fine_def,rule_format,OF as,unfolded split_conv] by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2122
        hence "\<exists>y. y \<in> ball x \<bar>x \<bullet> k - c\<bar> \<inter> {x. x \<bullet> k \<le> c}" using goal1(1) by blast 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2123
        then guess y .. hence "\<bar>x \<bullet> k - y \<bullet> k\<bar> < \<bar>x \<bullet> k - c\<bar>" "y\<bullet>k \<le> c" apply-apply(rule le_less_trans)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2124
          using Basis_le_norm[OF k, of "x - y"] by (auto simp add: dist_norm inner_diff_left)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2125
        thus False using goal1(2)[unfolded not_le] by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2126
      qed
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2127
      show "~(kk \<inter> {x. x\<bullet>k \<ge> c} = {}) \<Longrightarrow> x\<bullet>k \<ge> c"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2128
      proof(rule ccontr) case goal1
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2129
        from this(2)[unfolded not_le] have "kk \<subseteq> ball x \<bar>x \<bullet> k - c\<bar>"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2130
          using p(2)[unfolded fine_def,rule_format,OF as,unfolded split_conv] by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2131
        hence "\<exists>y. y \<in> ball x \<bar>x \<bullet> k - c\<bar> \<inter> {x. x \<bullet> k \<ge> c}" using goal1(1) by blast 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2132
        then guess y .. hence "\<bar>x \<bullet> k - y \<bullet> k\<bar> < \<bar>x \<bullet> k - c\<bar>" "y\<bullet>k \<ge> c" apply-apply(rule le_less_trans)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2133
          using Basis_le_norm[OF k, of "x - y"] by (auto simp add: dist_norm inner_diff_left)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2134
        thus False using goal1(2)[unfolded not_le] by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2135
      qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2136
    qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2137
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2138
    have lem1: "\<And>f P Q. (\<forall>x k. (x,k) \<in> {(x,f k) | x k. P x k} \<longrightarrow> Q x k) \<longleftrightarrow> (\<forall>x k. P x k \<longrightarrow> Q x (f k))" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2139
    have lem2: "\<And>f s P f. finite s \<Longrightarrow> finite {(x,f k) | x k. (x,k) \<in> s \<and> P x k}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2140
    proof- case goal1 thus ?case apply-apply(rule finite_subset[of _ "(\<lambda>(x,k). (x,f k)) ` s"]) by auto qed
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44167
diff changeset
  2141
    have lem3: "\<And>g::'a set \<Rightarrow> 'a set. finite p \<Longrightarrow>
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2142
      setsum (\<lambda>(x,k). content k *\<^sub>R f x) {(x,g k) |x k. (x,k) \<in> p \<and> ~(g k = {})}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2143
               = setsum (\<lambda>(x,k). content k *\<^sub>R f x) ((\<lambda>(x,k). (x,g k)) ` p)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2144
      apply(rule setsum_mono_zero_left) prefer 3
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44167
diff changeset
  2145
    proof fix g::"'a set \<Rightarrow> 'a set" and i::"('a) \<times> (('a) set)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2146
      assume "i \<in> (\<lambda>(x, k). (x, g k)) ` p - {(x, g k) |x k. (x, k) \<in> p \<and> g k \<noteq> {}}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2147
      then obtain x k where xk:"i=(x,g k)" "(x,k)\<in>p" "(x,g k) \<notin> {(x, g k) |x k. (x, k) \<in> p \<and> g k \<noteq> {}}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2148
      have "content (g k) = 0" using xk using content_empty by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2149
      thus "(\<lambda>(x, k). content k *\<^sub>R f x) i = 0" unfolding xk split_conv by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2150
    qed auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2151
    have lem4:"\<And>g. (\<lambda>(x,l). content (g l) *\<^sub>R f x) = (\<lambda>(x,l). content l *\<^sub>R f x) o (\<lambda>(x,l). (x,g l))" apply(rule ext) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2152
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2153
    let ?M1 = "{(x,kk \<inter> {x. x\<bullet>k \<le> c}) |x kk. (x,kk) \<in> p \<and> kk \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2154
    have "norm ((\<Sum>(x, k)\<in>?M1. content k *\<^sub>R f x) - i) < e/2" apply(rule d1(2),rule tagged_division_ofI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2155
      apply(rule lem2 p(3))+ prefer 6 apply(rule fineI)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2156
    proof- show "\<Union>{k. \<exists>x. (x, k) \<in> ?M1} = {a..b} \<inter> {x. x\<bullet>k \<le> c}" unfolding p(8)[THEN sym] by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2157
      fix x l assume xl:"(x,l)\<in>?M1"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2158
      then guess x' l' unfolding mem_Collect_eq apply- unfolding Pair_eq apply((erule exE)+,(erule conjE)+) .  note xl'=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2159
      have "l' \<subseteq> d1 x'" apply(rule order_trans[OF fineD[OF p(2) xl'(3)]]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2160
      thus "l \<subseteq> d1 x" unfolding xl' by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2161
      show "x\<in>l" "l \<subseteq> {a..b} \<inter> {x. x \<bullet> k \<le> c}" unfolding xl' using p(4-6)[OF xl'(3)] using xl'(4)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2162
        using lem0(1)[OF xl'(3-4)] by auto
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  2163
      show  "\<exists>a b. l = {a..b}" unfolding xl' using p(6)[OF xl'(3)] by(fastforce simp add: interval_split[OF k,where c=c])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2164
      fix y r let ?goal = "interior l \<inter> interior r = {}" assume yr:"(y,r)\<in>?M1"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2165
      then guess y' r' unfolding mem_Collect_eq apply- unfolding Pair_eq apply((erule exE)+,(erule conjE)+) .  note yr'=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2166
      assume as:"(x,l) \<noteq> (y,r)" show "interior l \<inter> interior r = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2167
      proof(cases "l' = r' \<longrightarrow> x' = y'")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2168
        case False thus ?thesis using p(7)[OF xl'(3) yr'(3)] using as unfolding xl' yr' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2169
      next case True hence "l' \<noteq> r'" using as unfolding xl' yr' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2170
        thus ?thesis using p(7)[OF xl'(3) yr'(3)] using as unfolding xl' yr' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2171
      qed qed moreover
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2172
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2173
    let ?M2 = "{(x,kk \<inter> {x. x\<bullet>k \<ge> c}) |x kk. (x,kk) \<in> p \<and> kk \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}}" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2174
    have "norm ((\<Sum>(x, k)\<in>?M2. content k *\<^sub>R f x) - j) < e/2" apply(rule d2(2),rule tagged_division_ofI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2175
      apply(rule lem2 p(3))+ prefer 6 apply(rule fineI)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2176
    proof- show "\<Union>{k. \<exists>x. (x, k) \<in> ?M2} = {a..b} \<inter> {x. x\<bullet>k \<ge> c}" unfolding p(8)[THEN sym] by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2177
      fix x l assume xl:"(x,l)\<in>?M2"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2178
      then guess x' l' unfolding mem_Collect_eq apply- unfolding Pair_eq apply((erule exE)+,(erule conjE)+) .  note xl'=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2179
      have "l' \<subseteq> d2 x'" apply(rule order_trans[OF fineD[OF p(2) xl'(3)]]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2180
      thus "l \<subseteq> d2 x" unfolding xl' by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2181
      show "x\<in>l" "l \<subseteq> {a..b} \<inter> {x. x \<bullet> k \<ge> c}" unfolding xl' using p(4-6)[OF xl'(3)] using xl'(4)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2182
        using lem0(2)[OF xl'(3-4)] by auto
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  2183
      show  "\<exists>a b. l = {a..b}" unfolding xl' using p(6)[OF xl'(3)] by(fastforce simp add: interval_split[OF k, where c=c])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2184
      fix y r let ?goal = "interior l \<inter> interior r = {}" assume yr:"(y,r)\<in>?M2"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2185
      then guess y' r' unfolding mem_Collect_eq apply- unfolding Pair_eq apply((erule exE)+,(erule conjE)+) .  note yr'=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2186
      assume as:"(x,l) \<noteq> (y,r)" show "interior l \<inter> interior r = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2187
      proof(cases "l' = r' \<longrightarrow> x' = y'")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2188
        case False thus ?thesis using p(7)[OF xl'(3) yr'(3)] using as unfolding xl' yr' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2189
      next case True hence "l' \<noteq> r'" using as unfolding xl' yr' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2190
        thus ?thesis using p(7)[OF xl'(3) yr'(3)] using as unfolding xl' yr' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2191
      qed qed ultimately
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2192
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2193
    have "norm (((\<Sum>(x, k)\<in>?M1. content k *\<^sub>R f x) - i) + ((\<Sum>(x, k)\<in>?M2. content k *\<^sub>R f x) - j)) < e/2 + e/2"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2194
      apply- apply(rule norm_triangle_lt) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2195
    also { have *:"\<And>x y. x = (0::real) \<Longrightarrow> x *\<^sub>R (y::'b) = 0" using scaleR_zero_left by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2196
      have "((\<Sum>(x, k)\<in>?M1. content k *\<^sub>R f x) - i) + ((\<Sum>(x, k)\<in>?M2. content k *\<^sub>R f x) - j)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2197
       = (\<Sum>(x, k)\<in>?M1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>?M2. content k *\<^sub>R f x) - (i + j)" by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2198
      also have "\<dots> = (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f x) +
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2199
        (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f x) - (i + j)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2200
        unfolding lem3[OF p(3)] apply(subst setsum_reindex_nonzero[OF p(3)]) defer apply(subst setsum_reindex_nonzero[OF p(3)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2201
        defer unfolding lem4[THEN sym] apply(rule refl) unfolding split_paired_all split_conv apply(rule_tac[!] *)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2202
      proof- case goal1 thus ?case apply- apply(rule tagged_division_split_left_inj [OF p(1), of a b aa ba]) using k by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2203
      next case   goal2 thus ?case apply- apply(rule tagged_division_split_right_inj[OF p(1), of a b aa ba]) using k by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2204
      qed also note setsum_addf[THEN sym]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2205
      also have *:"\<And>x. x\<in>p \<Longrightarrow> (\<lambda>(x, ka). content (ka \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f x) x + (\<lambda>(x, ka). content (ka \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f x) x
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2206
        = (\<lambda>(x,ka). content ka *\<^sub>R f x) x" unfolding split_paired_all split_conv
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2207
      proof- fix a b assume "(a,b) \<in> p" from p(6)[OF this] guess u v apply-by(erule exE)+ note uv=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2208
        thus "content (b \<inter> {x. x \<bullet> k \<le> c}) *\<^sub>R f a + content (b \<inter> {x. c \<le> x \<bullet> k}) *\<^sub>R f a = content b *\<^sub>R f a"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2209
          unfolding scaleR_left_distrib[THEN sym] unfolding uv content_split[OF k,of u v c] by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2210
      qed note setsum_cong2[OF this]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2211
      finally have "(\<Sum>(x, k)\<in>{(x, kk \<inter> {x. x \<bullet> k \<le> c}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. x \<bullet> k \<le> c} \<noteq> {}}. content k *\<^sub>R f x) - i +
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2212
        ((\<Sum>(x, k)\<in>{(x, kk \<inter> {x. c \<le> x \<bullet> k}) |x kk. (x, kk) \<in> p \<and> kk \<inter> {x. c \<le> x \<bullet> k} \<noteq> {}}. content k *\<^sub>R f x) - j) =
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2213
        (\<Sum>(x, ka)\<in>p. content ka *\<^sub>R f x) - (i + j)" by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2214
    finally show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - (i + j)) < e" by auto qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2215
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2216
subsection {* A sort of converse, integrability on subintervals. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2217
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2218
lemma tagged_division_union_interval: fixes a::"'a::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2219
  assumes "p1 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<le> (c::real)})"  "p2 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2220
  and k:"k\<in>Basis"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2221
  shows "(p1 \<union> p2) tagged_division_of ({a..b})"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2222
proof- have *:"{a..b} = ({a..b} \<inter> {x. x\<bullet>k \<le> c}) \<union> ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2223
  show ?thesis apply(subst *) apply(rule tagged_division_union[OF assms(1-2)])
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2224
    unfolding interval_split[OF k] interior_closed_interval using k
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2225
    by(auto simp add: eucl_less[where 'a='a] elim!: ballE[where x=k]) qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2226
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2227
lemma has_integral_separate_sides: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2228
  assumes "(f has_integral i) ({a..b})" "e>0" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2229
  obtains d where "gauge d" "(\<forall>p1 p2. p1 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<le> c}) \<and> d fine p1 \<and>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2230
                                p2 tagged_division_of ({a..b} \<inter> {x. x\<bullet>k \<ge> c}) \<and> d fine p2
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2231
                                \<longrightarrow> norm((setsum (\<lambda>(x,k). content k *\<^sub>R f x) p1 +
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2232
                                          setsum (\<lambda>(x,k). content k *\<^sub>R f x) p2) - i) < e)"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2233
proof- guess d using has_integralD[OF assms(1-2)] . note d=this
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2234
  show ?thesis apply(rule that[of d]) apply(rule d) apply(rule,rule,rule,(erule conjE)+)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2235
  proof- fix p1 p2 assume "p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c}" "d fine p1" note p1=tagged_division_ofD[OF this(1)] this
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2236
                   assume "p2 tagged_division_of {a..b} \<inter> {x. c \<le> x \<bullet> k}" "d fine p2" note p2=tagged_division_ofD[OF this(1)] this
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2237
    note tagged_division_union_interval[OF p1(7) p2(7)] note p12 = tagged_division_ofD[OF this] this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2238
    have "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - i) = norm ((\<Sum>(x, k)\<in>p1 \<union> p2. content k *\<^sub>R f x) - i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2239
      apply(subst setsum_Un_zero) apply(rule p1 p2)+ apply(rule) unfolding split_paired_all split_conv
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2240
    proof- fix a b assume ab:"(a,b) \<in> p1 \<inter> p2"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2241
      have "(a,b) \<in> p1" using ab by auto from p1(4)[OF this] guess u v apply-by(erule exE)+ note uv =this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2242
      have "b \<subseteq> {x. x\<bullet>k = c}" using ab p1(3)[of a b] p2(3)[of a b] by fastforce
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2243
      moreover have "interior {x::'a. x \<bullet> k = c} = {}" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2244
      proof(rule ccontr) case goal1 then obtain x where x:"x\<in>interior {x::'a. x\<bullet>k = c}" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2245
        then guess e unfolding mem_interior .. note e=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2246
        have x:"x\<bullet>k = c" using x interior_subset by fastforce
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2247
        have *:"\<And>i. i\<in>Basis \<Longrightarrow> \<bar>(x - (x + (e / 2) *\<^sub>R k)) \<bullet> i\<bar>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2248
          = (if i = k then e/2 else 0)" using e k by (auto simp: inner_simps inner_not_same_Basis)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2249
        have "(\<Sum>i\<in>Basis. \<bar>(x - (x + (e / 2 ) *\<^sub>R k)) \<bullet> i\<bar>) =
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2250
          (\<Sum>i\<in>Basis. (if i = k then e / 2 else 0))" apply(rule setsum_cong2) apply(subst *) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2251
        also have "... < e" apply(subst setsum_delta) using e by auto 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2252
        finally have "x + (e/2) *\<^sub>R k \<in> ball x e"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2253
          unfolding mem_ball dist_norm by(rule le_less_trans[OF norm_le_l1])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2254
        hence "x + (e/2) *\<^sub>R k \<in> {x. x\<bullet>k = c}" using e by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2255
        thus False unfolding mem_Collect_eq using e x k by (auto simp: inner_simps)
44522
2f7e9d890efe rename subset_{interior,closure} to {interior,closure}_mono;
huffman
parents: 44514
diff changeset
  2256
      qed ultimately have "content b = 0" unfolding uv content_eq_0_interior apply-apply(drule interior_mono) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2257
      thus "content b *\<^sub>R f a = 0" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2258
    qed auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2259
    also have "\<dots> < e" by(rule k d(2) p12 fine_union p1 p2)+
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2260
    finally show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - i) < e" . qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2261
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2262
lemma integrable_split[intro]:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2263
  fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::{real_normed_vector,complete_space}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2264
  assumes "f integrable_on {a..b}" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2265
  shows "f integrable_on ({a..b} \<inter> {x. x\<bullet>k \<le> c})" (is ?t1) and "f integrable_on ({a..b} \<inter> {x. x\<bullet>k \<ge> c})" (is ?t2) 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2266
proof- guess y using assms(1) unfolding integrable_on_def .. note y=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2267
  def b' \<equiv> "\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) c else b\<bullet>i)*\<^sub>R i::'a"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2268
  def a' \<equiv> "\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) c else a\<bullet>i)*\<^sub>R i::'a"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2269
  show ?t1 ?t2 unfolding interval_split[OF k] integrable_cauchy unfolding interval_split[THEN sym,OF k]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2270
  proof(rule_tac[!] allI impI)+ fix e::real assume "e>0" hence "e/2>0" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2271
    from has_integral_separate_sides[OF y this k,of c] guess d . note d=this[rule_format]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2272
    let ?P = "\<lambda>A. \<exists>d. gauge d \<and> (\<forall>p1 p2. p1 tagged_division_of {a..b} \<inter> A \<and> d fine p1
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2273
      \<and> p2 tagged_division_of {a..b} \<inter> A \<and> d fine p2 \<longrightarrow>
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2274
      norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2275
    show "?P {x. x \<bullet> k \<le> c}" apply(rule_tac x=d in exI) apply(rule,rule d) apply(rule,rule,rule)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2276
    proof- fix p1 p2 assume as:"p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c} \<and> d fine p1
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2277
        \<and> p2 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<le> c} \<and> d fine p2"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2278
      show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2279
      proof- guess p using fine_division_exists[OF d(1), of a' b] . note p=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2280
        show ?thesis using norm_triangle_half_l[OF d(2)[of p1 p] d(2)[of p2 p]]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2281
          using as unfolding interval_split[OF k] b'_def[symmetric] a'_def[symmetric]
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  2282
          using p using assms by(auto simp add:algebra_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2283
      qed qed  
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2284
    show "?P {x. x \<bullet> k \<ge> c}" apply(rule_tac x=d in exI) apply(rule,rule d) apply(rule,rule,rule)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2285
    proof- fix p1 p2 assume as:"p1 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p1
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2286
        \<and> p2 tagged_division_of {a..b} \<inter> {x. x \<bullet> k \<ge> c} \<and> d fine p2"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2287
      show "norm ((\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2288
      proof- guess p using fine_division_exists[OF d(1), of a b'] . note p=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2289
        show ?thesis using norm_triangle_half_l[OF d(2)[of p p1] d(2)[of p p2]]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2290
          using as unfolding interval_split[OF k] b'_def[symmetric] a'_def[symmetric]
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  2291
          using p using assms by(auto simp add:algebra_simps) qed qed qed qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2292
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2293
subsection {* Generalized notion of additivity. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2294
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2295
definition "neutral opp = (SOME x. \<forall>y. opp x y = y \<and> opp y x = y)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2296
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2297
definition operative :: "('a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> (('b::ordered_euclidean_space) set \<Rightarrow> 'a) \<Rightarrow> bool" where
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2298
  "operative opp f \<equiv> 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2299
    (\<forall>a b. content {a..b} = 0 \<longrightarrow> f {a..b} = neutral(opp)) \<and>
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2300
    (\<forall>a b c. \<forall>k\<in>Basis. f({a..b}) =
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2301
                   opp (f({a..b} \<inter> {x. x\<bullet>k \<le> c}))
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2302
                       (f({a..b} \<inter> {x. x\<bullet>k \<ge> c})))"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2303
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2304
lemma operativeD[dest]: fixes type::"'a::ordered_euclidean_space"  assumes "operative opp f"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2305
  shows "\<And>a b. content {a..b} = 0 \<Longrightarrow> f {a..b::'a} = neutral(opp)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2306
  "\<And>a b c k. k\<in>Basis \<Longrightarrow> f({a..b}) = opp (f({a..b} \<inter> {x. x\<bullet>k \<le> c})) (f({a..b} \<inter> {x. x\<bullet>k \<ge> c}))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2307
  using assms unfolding operative_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2308
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2309
lemma operative_trivial:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2310
 "operative opp f \<Longrightarrow> content({a..b}) = 0 \<Longrightarrow> f({a..b}) = neutral opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2311
  unfolding operative_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2312
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2313
lemma property_empty_interval:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2314
 "(\<forall>a b. content({a..b}) = 0 \<longrightarrow> P({a..b})) \<Longrightarrow> P {}" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2315
  using content_empty unfolding empty_as_interval by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2316
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2317
lemma operative_empty: "operative opp f \<Longrightarrow> f {} = neutral opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2318
  unfolding operative_def apply(rule property_empty_interval) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2319
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2320
subsection {* Using additivity of lifted function to encode definedness. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2321
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2322
lemma forall_option: "(\<forall>x. P x) \<longleftrightarrow> P None \<and> (\<forall>x. P(Some x))"
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36359
diff changeset
  2323
  by (metis option.nchotomy)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2324
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2325
lemma exists_option: "(\<exists>x. P x) \<longleftrightarrow> P None \<or> (\<exists>x. P(Some x))"
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36359
diff changeset
  2326
  by (metis option.nchotomy)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2327
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2328
fun lifted
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2329
where
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2330
  "lifted (opp::'a\<Rightarrow>'a\<Rightarrow>'b) (Some x) (Some y) = Some (opp x y)"
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2331
| "lifted opp None _ = (None::'b option)"
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2332
| "lifted opp _ None = None"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2333
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2334
lemma lifted_simp_1[simp]: "lifted opp v None = None"
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2335
  by (induct v) auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2336
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2337
definition "monoidal opp \<equiv>  (\<forall>x y. opp x y = opp y x) \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2338
                   (\<forall>x y z. opp x (opp y z) = opp (opp x y) z) \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2339
                   (\<forall>x. opp (neutral opp) x = x)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2340
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2341
lemma monoidalI:
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2342
  assumes "\<And>x y. opp x y = opp y x"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2343
  "\<And>x y z. opp x (opp y z) = opp (opp x y) z"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2344
  "\<And>x. opp (neutral opp) x = x" shows "monoidal opp"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  2345
  unfolding monoidal_def using assms by fastforce
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2346
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2347
lemma monoidal_ac:
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2348
  assumes "monoidal opp"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2349
  shows "opp (neutral opp) a = a" "opp a (neutral opp) = a" "opp a b = opp b a"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2350
  "opp (opp a b) c = opp a (opp b c)"  "opp a (opp b c) = opp b (opp a c)"
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2351
  using assms unfolding monoidal_def by metis+
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2352
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2353
lemma monoidal_simps[simp]: assumes "monoidal opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2354
  shows "opp (neutral opp) a = a" "opp a (neutral opp) = a"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2355
  using monoidal_ac[OF assms] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2356
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2357
lemma neutral_lifted[cong]: assumes "monoidal opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2358
  shows "neutral (lifted opp) = Some(neutral opp)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2359
  apply(subst neutral_def) apply(rule some_equality) apply(rule,induct_tac y) prefer 3
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2360
proof -
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2361
  fix x assume "\<forall>y. lifted opp x y = y \<and> lifted opp y x = y"
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2362
  thus "x = Some (neutral opp)"
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2363
    apply(induct x) defer
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2364
    apply rule apply(subst neutral_def) apply(subst eq_commute,rule some_equality)
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2365
    apply(rule,erule_tac x="Some y" in allE) defer apply(erule_tac x="Some x" in allE)
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2366
    apply auto
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2367
    done
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2368
qed(auto simp add:monoidal_ac[OF assms])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2369
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2370
lemma monoidal_lifted[intro]: assumes "monoidal opp" shows "monoidal(lifted opp)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2371
  unfolding monoidal_def forall_option neutral_lifted[OF assms] using monoidal_ac[OF assms] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2372
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2373
definition "support opp f s = {x. x\<in>s \<and> f x \<noteq> neutral opp}"
45994
38a46e029784 be explicit about Finite_Set.fold
haftmann
parents: 44906
diff changeset
  2374
definition "fold' opp e s \<equiv> (if finite s then Finite_Set.fold opp e s else e)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2375
definition "iterate opp s f \<equiv> fold' (\<lambda>x a. opp (f x) a) (neutral opp) (support opp f s)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2376
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2377
lemma support_subset[intro]:"support opp f s \<subseteq> s" unfolding support_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2378
lemma support_empty[simp]:"support opp f {} = {}" using support_subset[of opp f "{}"] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2379
42871
1c0b99f950d9 names of fold_set locales resemble name of characteristic property more closely
haftmann
parents: 42869
diff changeset
  2380
lemma comp_fun_commute_monoidal[intro]: assumes "monoidal opp" shows "comp_fun_commute opp"
1c0b99f950d9 names of fold_set locales resemble name of characteristic property more closely
haftmann
parents: 42869
diff changeset
  2381
  unfolding comp_fun_commute_def using monoidal_ac[OF assms] by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2382
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2383
lemma support_clauses:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2384
  "\<And>f g s. support opp f {} = {}"
49197
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2385
  "\<And>f g s. support opp f (insert x s) =
e5224d887e12 tuned proofs;
wenzelm
parents: 49194
diff changeset
  2386
    (if f(x) = neutral opp then support opp f s else insert x (support opp f s))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2387
  "\<And>f g s. support opp f (s - {x}) = (support opp f s) - {x}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2388
  "\<And>f g s. support opp f (s \<union> t) = (support opp f s) \<union> (support opp f t)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2389
  "\<And>f g s. support opp f (s \<inter> t) = (support opp f s) \<inter> (support opp f t)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2390
  "\<And>f g s. support opp f (s - t) = (support opp f s) - (support opp f t)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2391
  "\<And>f g s. support opp g (f ` s) = f ` (support opp (g o f) s)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2392
unfolding support_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2393
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2394
lemma finite_support[intro]:"finite s \<Longrightarrow> finite (support opp f s)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2395
  unfolding support_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2396
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2397
lemma iterate_empty[simp]:"iterate opp {} f = neutral opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2398
  unfolding iterate_def fold'_def by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2399
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2400
lemma iterate_insert[simp]: assumes "monoidal opp" "finite s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2401
  shows "iterate opp (insert x s) f = (if x \<in> s then iterate opp s f else opp (f x) (iterate opp s f))" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2402
proof(cases "x\<in>s") case True hence *:"insert x s = s" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2403
  show ?thesis unfolding iterate_def if_P[OF True] * by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2404
next case False note x=this
42871
1c0b99f950d9 names of fold_set locales resemble name of characteristic property more closely
haftmann
parents: 42869
diff changeset
  2405
  note * = comp_fun_commute.comp_comp_fun_commute [OF comp_fun_commute_monoidal[OF assms(1)]]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2406
  show ?thesis proof(cases "f x = neutral opp")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2407
    case True show ?thesis unfolding iterate_def if_not_P[OF x] support_clauses if_P[OF True]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2408
      unfolding True monoidal_simps[OF assms(1)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2409
  next case False show ?thesis unfolding iterate_def fold'_def  if_not_P[OF x] support_clauses if_not_P[OF False]
42871
1c0b99f950d9 names of fold_set locales resemble name of characteristic property more closely
haftmann
parents: 42869
diff changeset
  2410
      apply(subst comp_fun_commute.fold_insert[OF * finite_support, simplified comp_def])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2411
      using `finite s` unfolding support_def using False x by auto qed qed 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2412
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2413
lemma iterate_some:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2414
  assumes "monoidal opp"  "finite s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2415
  shows "iterate (lifted opp) s (\<lambda>x. Some(f x)) = Some (iterate opp s f)" using assms(2)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2416
proof(induct s) case empty thus ?case using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2417
next case (insert x F) show ?case apply(subst iterate_insert) prefer 3 apply(subst if_not_P)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2418
    defer unfolding insert(3) lifted.simps apply rule using assms insert by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2419
subsection {* Two key instances of additivity. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2420
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2421
lemma neutral_add[simp]:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2422
  "neutral op + = (0::_::comm_monoid_add)" unfolding neutral_def 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2423
  apply(rule some_equality) defer apply(erule_tac x=0 in allE) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2424
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2425
lemma operative_content[intro]: "operative (op +) content" 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2426
  unfolding operative_def neutral_add apply safe 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2427
  unfolding content_split[THEN sym] ..
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2428
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36359
diff changeset
  2429
lemma neutral_monoid: "neutral ((op +)::('a::comm_monoid_add) \<Rightarrow> 'a \<Rightarrow> 'a) = 0"
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36359
diff changeset
  2430
  by (rule neutral_add) (* FIXME: duplicate *)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2431
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2432
lemma monoidal_monoid[intro]:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2433
  shows "monoidal ((op +)::('a::comm_monoid_add) \<Rightarrow> 'a \<Rightarrow> 'a)"
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  2434
  unfolding monoidal_def neutral_monoid by(auto simp add: algebra_simps) 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2435
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2436
lemma operative_integral: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2437
  shows "operative (lifted(op +)) (\<lambda>i. if f integrable_on i then Some(integral i f) else None)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2438
  unfolding operative_def unfolding neutral_lifted[OF monoidal_monoid] neutral_add
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2439
  apply(rule,rule,rule,rule) defer apply(rule allI ballI)+
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2440
proof-
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2441
  fix a b c and k :: 'a assume k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2442
  show "(if f integrable_on {a..b} then Some (integral {a..b} f) else None) =
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2443
    lifted op + (if f integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c} then Some (integral ({a..b} \<inter> {x. x \<bullet> k \<le> c}) f) else None)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2444
    (if f integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k} then Some (integral ({a..b} \<inter> {x. c \<le> x \<bullet> k}) f) else None)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2445
  proof(cases "f integrable_on {a..b}") 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2446
    case True show ?thesis unfolding if_P[OF True] using k apply-
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2447
      unfolding if_P[OF integrable_split(1)[OF True]] unfolding if_P[OF integrable_split(2)[OF True]]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2448
      unfolding lifted.simps option.inject apply(rule integral_unique) apply(rule has_integral_split[OF _ _ k]) 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2449
      apply(rule_tac[!] integrable_integral integrable_split)+ using True k by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2450
  next case False have "(\<not> (f integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c})) \<or> (\<not> ( f integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k}))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2451
    proof(rule ccontr) case goal1 hence "f integrable_on {a..b}" apply- unfolding integrable_on_def
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2452
        apply(rule_tac x="integral ({a..b} \<inter> {x. x \<bullet> k \<le> c}) f + integral ({a..b} \<inter> {x. x \<bullet> k \<ge> c}) f" in exI)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2453
        apply(rule has_integral_split[OF _ _ k]) apply(rule_tac[!] integrable_integral) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2454
      thus False using False by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2455
    qed thus ?thesis using False by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2456
  qed next 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2457
  fix a b assume as:"content {a..b::'a} = 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2458
  thus "(if f integrable_on {a..b} then Some (integral {a..b} f) else None) = Some 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2459
    unfolding if_P[OF integrable_on_null[OF as]] using has_integral_null_eq[OF as] by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2460
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2461
subsection {* Points of division of a partition. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2462
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2463
definition "division_points (k::('a::ordered_euclidean_space) set) d = 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2464
    {(j,x). j\<in>Basis \<and> (interval_lowerbound k)\<bullet>j < x \<and> x < (interval_upperbound k)\<bullet>j \<and>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2465
           (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2466
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2467
lemma division_points_finite: fixes i::"('a::ordered_euclidean_space) set"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2468
  assumes "d division_of i" shows "finite (division_points i d)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2469
proof- note assm = division_ofD[OF assms]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2470
  let ?M = "\<lambda>j. {(j,x)|x. (interval_lowerbound i)\<bullet>j < x \<and> x < (interval_upperbound i)\<bullet>j \<and>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2471
           (\<exists>i\<in>d. (interval_lowerbound i)\<bullet>j = x \<or> (interval_upperbound i)\<bullet>j = x)}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2472
  have *:"division_points i d = \<Union>(?M ` Basis)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2473
    unfolding division_points_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2474
  show ?thesis unfolding * using assm by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2475
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2476
lemma division_points_subset: fixes a::"'a::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2477
  assumes "d division_of {a..b}" "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2478
  shows "division_points ({a..b} \<inter> {x. x\<bullet>k \<le> c}) {l \<inter> {x. x\<bullet>k \<le> c} | l . l \<in> d \<and> ~(l \<inter> {x. x\<bullet>k \<le> c} = {})}
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2479
                  \<subseteq> division_points ({a..b}) d" (is ?t1) and
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2480
        "division_points ({a..b} \<inter> {x. x\<bullet>k \<ge> c}) {l \<inter> {x. x\<bullet>k \<ge> c} | l . l \<in> d \<and> ~(l \<inter> {x. x\<bullet>k \<ge> c} = {})}
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2481
                  \<subseteq> division_points ({a..b}) d" (is ?t2)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2482
proof- note assm = division_ofD[OF assms(1)]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2483
  have *:"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2484
    "\<forall>i\<in>Basis. a\<bullet>i \<le> (\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) *\<^sub>R i) \<bullet> i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2485
    "\<forall>i\<in>Basis. (\<Sum>i\<in>Basis. (if i = k then max (a \<bullet> k) c else a \<bullet> i) *\<^sub>R i) \<bullet> i \<le> b\<bullet>i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2486
    "min (b \<bullet> k) c = c" "max (a \<bullet> k) c = c"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2487
    using assms using less_imp_le by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2488
  show ?t1
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2489
    unfolding division_points_def interval_split[OF k, of a b]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2490
    unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2491
    unfolding *
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2492
    unfolding subset_eq
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2493
    apply(rule)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2494
    unfolding mem_Collect_eq split_beta
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2495
    apply(erule bexE conjE)+
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2496
    apply(simp only: mem_Collect_eq inner_setsum_left_Basis simp_thms)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2497
    apply(erule exE conjE)+
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2498
  proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2499
    fix i l x assume as:"a \<bullet> fst x < snd x" "snd x < (if fst x = k then c else b \<bullet> fst x)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2500
      "interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2501
      "i = l \<inter> {x. x \<bullet> k \<le> c}" "l \<in> d" "l \<inter> {x. x \<bullet> k \<le> c} \<noteq> {}" and fstx:"fst x \<in>Basis"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2502
    from assm(4)[OF this(5)] guess u v apply-by(erule exE)+ note l=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2503
    have *:"\<forall>i\<in>Basis. u \<bullet> i \<le> (\<Sum>i\<in>Basis. (if i = k then min (v \<bullet> k) c else v \<bullet> i) *\<^sub>R i) \<bullet> i"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2504
      using as(6) unfolding l interval_split[OF k] interval_ne_empty as .
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2505
    have **:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" using l using as(6) unfolding interval_ne_empty[THEN sym] by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2506
    show "\<exists>i\<in>d. interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2507
      apply (rule bexI[OF _ `l \<in> d`])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2508
      using as(1-3,5) fstx
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2509
      unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] as
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2510
      by (auto split: split_if_asm)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2511
    show "snd x < b \<bullet> fst x"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2512
      using as(2) `c < b\<bullet>k` by (auto split: split_if_asm)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2513
  qed
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2514
  show ?t2
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2515
    unfolding division_points_def interval_split[OF k, of a b]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2516
    unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)] unfolding *
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2517
    unfolding subset_eq apply(rule) unfolding mem_Collect_eq split_beta
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2518
    apply(erule bexE conjE)+
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2519
    apply(simp only: mem_Collect_eq inner_setsum_left_Basis simp_thms)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2520
    apply(erule exE conjE)+
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2521
  proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2522
    fix i l x assume as:"(if fst x = k then c else a \<bullet> fst x) < snd x" "snd x < b \<bullet> fst x"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2523
      "interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2524
      "i = l \<inter> {x. c \<le> x \<bullet> k}" "l \<in> d" "l \<inter> {x. c \<le> x \<bullet> k} \<noteq> {}" and fstx:"fst x \<in> Basis"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2525
    from assm(4)[OF this(5)] guess u v apply-by(erule exE)+ note l=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2526
    have *:"\<forall>i\<in>Basis. (\<Sum>i\<in>Basis. (if i = k then max (u \<bullet> k) c else u \<bullet> i) *\<^sub>R i) \<bullet> i \<le> v \<bullet> i"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2527
      using as(6) unfolding l interval_split[OF k] interval_ne_empty as .
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2528
    have **:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" using l using as(6) unfolding interval_ne_empty[THEN sym] by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2529
    show "\<exists>i\<in>d. interval_lowerbound i \<bullet> fst x = snd x \<or> interval_upperbound i \<bullet> fst x = snd x"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2530
      apply (rule bexI[OF _ `l \<in> d`])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2531
      using as(1-3,5) fstx
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2532
      unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] as
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2533
      by (auto split: split_if_asm)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2534
    show "a \<bullet> fst x < snd x"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2535
      using as(1) `a\<bullet>k < c` by (auto split: split_if_asm)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2536
   qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2537
qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2538
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2539
lemma division_points_psubset: fixes a::"'a::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2540
  assumes "d division_of {a..b}"  "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"  "a\<bullet>k < c" "c < b\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2541
  "l \<in> d" "interval_lowerbound l\<bullet>k = c \<or> interval_upperbound l\<bullet>k = c" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2542
  shows "division_points ({a..b} \<inter> {x. x\<bullet>k \<le> c}) {l \<inter> {x. x\<bullet>k \<le> c} | l. l\<in>d \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}}
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2543
              \<subset> division_points ({a..b}) d" (is "?D1 \<subset> ?D") 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2544
        "division_points ({a..b} \<inter> {x. x\<bullet>k \<ge> c}) {l \<inter> {x. x\<bullet>k \<ge> c} | l. l\<in>d \<and> l \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}}
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2545
              \<subset> division_points ({a..b}) d" (is "?D2 \<subset> ?D") 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2546
proof- have ab:"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i" using assms(2) by(auto intro!:less_imp_le)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2547
  guess u v using division_ofD(4)[OF assms(1,5)] apply-by(erule exE)+ note l=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2548
  have uv:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" "\<forall>i\<in>Basis. a\<bullet>i \<le> u\<bullet>i \<and> v\<bullet>i \<le> b\<bullet>i"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2549
    using division_ofD(2,2,3)[OF assms(1,5)] unfolding l interval_ne_empty
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2550
    unfolding subset_eq apply- defer apply(erule_tac x=u in ballE, erule_tac x=v in ballE) unfolding mem_interval by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2551
  have *:"interval_upperbound ({a..b} \<inter> {x. x \<bullet> k \<le> interval_upperbound l \<bullet> k}) \<bullet> k = interval_upperbound l \<bullet> k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2552
         "interval_upperbound ({a..b} \<inter> {x. x \<bullet> k \<le> interval_lowerbound l \<bullet> k}) \<bullet> k = interval_lowerbound l \<bullet> k"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2553
    unfolding interval_split[OF k] apply(subst interval_bounds) prefer 3 apply(subst interval_bounds)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2554
    unfolding l interval_bounds[OF uv(1)] using uv[rule_format,of k] ab k by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2555
  have "\<exists>x. x \<in> ?D - ?D1" using assms(2-) apply-apply(erule disjE)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2556
    apply(rule_tac x="(k,(interval_lowerbound l)\<bullet>k)" in exI) defer
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2557
    apply(rule_tac x="(k,(interval_upperbound l)\<bullet>k)" in exI)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2558
    unfolding division_points_def unfolding interval_bounds[OF ab] by(auto simp add:*) 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2559
  thus "?D1 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4)]) using k by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2560
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2561
  have *:"interval_lowerbound ({a..b} \<inter> {x. x \<bullet> k \<ge> interval_lowerbound l \<bullet> k}) \<bullet> k = interval_lowerbound l \<bullet> k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2562
         "interval_lowerbound ({a..b} \<inter> {x. x \<bullet> k \<ge> interval_upperbound l \<bullet> k}) \<bullet> k = interval_upperbound l \<bullet> k"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2563
    unfolding interval_split[OF k] apply(subst interval_bounds) prefer 3 apply(subst interval_bounds)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2564
    unfolding l interval_bounds[OF uv(1)] using uv[rule_format,of k] ab k by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2565
  have "\<exists>x. x \<in> ?D - ?D2" using assms(2-) apply-apply(erule disjE)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2566
    apply(rule_tac x="(k,(interval_lowerbound l)\<bullet>k)" in exI) defer
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2567
    apply(rule_tac x="(k,(interval_upperbound l)\<bullet>k)" in exI)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2568
    unfolding division_points_def unfolding interval_bounds[OF ab] by(auto simp add:*) 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2569
  thus "?D2 \<subset> ?D" apply-apply(rule,rule division_points_subset[OF assms(1-4) k]) by auto qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2570
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2571
subsection {* Preservation by divisions and tagged divisions. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2572
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2573
lemma support_support[simp]:"support opp f (support opp f s) = support opp f s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2574
  unfolding support_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2575
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2576
lemma iterate_support[simp]: "iterate opp (support opp f s) f = iterate opp s f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2577
  unfolding iterate_def support_support by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2578
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2579
lemma iterate_expand_cases:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2580
  "iterate opp s f = (if finite(support opp f s) then iterate opp (support opp f s) f else neutral opp)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2581
  apply(cases) apply(subst if_P,assumption) unfolding iterate_def support_support fold'_def by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2582
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2583
lemma iterate_image: assumes "monoidal opp"  "inj_on f s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2584
  shows "iterate opp (f ` s) g = iterate opp s (g \<circ> f)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2585
proof- have *:"\<And>s. finite s \<Longrightarrow>  \<forall>x\<in>s. \<forall>y\<in>s. f x = f y \<longrightarrow> x = y \<Longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2586
     iterate opp (f ` s) g = iterate opp s (g \<circ> f)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2587
  proof- case goal1 show ?case using goal1
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2588
    proof(induct s) case empty thus ?case using assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2589
    next case (insert x s) show ?case unfolding iterate_insert[OF assms(1) insert(1)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2590
        unfolding if_not_P[OF insert(2)] apply(subst insert(3)[THEN sym])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2591
        unfolding image_insert defer apply(subst iterate_insert[OF assms(1)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2592
        apply(rule finite_imageI insert)+ apply(subst if_not_P)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2593
        unfolding image_iff o_def using insert(2,4) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2594
    qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2595
  show ?thesis 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2596
    apply(cases "finite (support opp g (f ` s))")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2597
    apply(subst (1) iterate_support[THEN sym],subst (2) iterate_support[THEN sym])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2598
    unfolding support_clauses apply(rule *)apply(rule finite_imageD,assumption) unfolding inj_on_def[symmetric]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2599
    apply(rule subset_inj_on[OF assms(2) support_subset])+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2600
    apply(subst iterate_expand_cases) unfolding support_clauses apply(simp only: if_False)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2601
    apply(subst iterate_expand_cases) apply(subst if_not_P) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2602
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2603
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2604
(* This lemma about iterations comes up in a few places.                     *)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2605
lemma iterate_nonzero_image_lemma:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2606
  assumes "monoidal opp" "finite s" "g(a) = neutral opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2607
  "\<forall>x\<in>s. \<forall>y\<in>s. f x = f y \<and> x \<noteq> y \<longrightarrow> g(f x) = neutral opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2608
  shows "iterate opp {f x | x. x \<in> s \<and> f x \<noteq> a} g = iterate opp s (g \<circ> f)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2609
proof- have *:"{f x |x. x \<in> s \<and> ~(f x = a)} = f ` {x. x \<in> s \<and> ~(f x = a)}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2610
  have **:"support opp (g \<circ> f) {x \<in> s. f x \<noteq> a} = support opp (g \<circ> f) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2611
    unfolding support_def using assms(3) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2612
  show ?thesis unfolding *
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2613
    apply(subst iterate_support[THEN sym]) unfolding support_clauses
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2614
    apply(subst iterate_image[OF assms(1)]) defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2615
    apply(subst(2) iterate_support[THEN sym]) apply(subst **)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2616
    unfolding inj_on_def using assms(3,4) unfolding support_def by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2617
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2618
lemma iterate_eq_neutral:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2619
  assumes "monoidal opp"  "\<forall>x \<in> s. (f(x) = neutral opp)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2620
  shows "(iterate opp s f = neutral opp)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2621
proof- have *:"support opp f s = {}" unfolding support_def using assms(2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2622
  show ?thesis apply(subst iterate_support[THEN sym]) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2623
    unfolding * using assms(1) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2624
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2625
lemma iterate_op: assumes "monoidal opp" "finite s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2626
  shows "iterate opp s (\<lambda>x. opp (f x) (g x)) = opp (iterate opp s f) (iterate opp s g)" using assms(2)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2627
proof(induct s) case empty thus ?case unfolding iterate_insert[OF assms(1)] using assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2628
next case (insert x F) show ?case unfolding iterate_insert[OF assms(1) insert(1)] if_not_P[OF insert(2)] insert(3)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2629
    unfolding monoidal_ac[OF assms(1)] by(rule refl) qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2630
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2631
lemma iterate_eq: assumes "monoidal opp" "\<And>x. x \<in> s \<Longrightarrow> f x = g x"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2632
  shows "iterate opp s f = iterate opp s g"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2633
proof- have *:"support opp g s = support opp f s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2634
    unfolding support_def using assms(2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2635
  show ?thesis
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2636
  proof(cases "finite (support opp f s)")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2637
    case False thus ?thesis apply(subst iterate_expand_cases,subst(2) iterate_expand_cases)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2638
      unfolding * by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2639
  next def su \<equiv> "support opp f s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2640
    case True note support_subset[of opp f s] 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2641
    thus ?thesis apply- apply(subst iterate_support[THEN sym],subst(2) iterate_support[THEN sym]) unfolding * using True
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2642
      unfolding su_def[symmetric]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2643
    proof(induct su) case empty show ?case by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2644
    next case (insert x s) show ?case unfolding iterate_insert[OF assms(1) insert(1)] 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2645
        unfolding if_not_P[OF insert(2)] apply(subst insert(3))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2646
        defer apply(subst assms(2)[of x]) using insert by auto qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2647
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2648
lemma nonempty_witness: assumes "s \<noteq> {}" obtains x where "x \<in> s" using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2649
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2650
lemma operative_division: fixes f::"('a::ordered_euclidean_space) set \<Rightarrow> 'b"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2651
  assumes "monoidal opp" "operative opp f" "d division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2652
  shows "iterate opp d f = f {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2653
proof- def C \<equiv> "card (division_points {a..b} d)" thus ?thesis using assms
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2654
  proof(induct C arbitrary:a b d rule:full_nat_induct)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2655
    case goal1
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2656
    { presume *:"content {a..b} \<noteq> 0 \<Longrightarrow> ?case"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2657
      thus ?case apply-apply(cases) defer apply assumption
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2658
      proof- assume as:"content {a..b} = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2659
        show ?case unfolding operativeD(1)[OF assms(2) as] apply(rule iterate_eq_neutral[OF goal1(2)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2660
        proof fix x assume x:"x\<in>d"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2661
          then guess u v apply(drule_tac division_ofD(4)[OF goal1(4)]) by(erule exE)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2662
          thus "f x = neutral opp" using division_of_content_0[OF as goal1(4)] 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2663
            using operativeD(1)[OF assms(2)] x by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2664
        qed qed }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2665
    assume "content {a..b} \<noteq> 0" note ab = this[unfolded content_lt_nz[THEN sym] content_pos_lt_eq]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2666
    hence ab':"\<forall>i\<in>Basis. a\<bullet>i \<le> b\<bullet>i" by (auto intro!: less_imp_le) show ?case 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2667
    proof(cases "division_points {a..b} d = {}")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2668
      case True have d':"\<forall>i\<in>d. \<exists>u v. i = {u..v} \<and>
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2669
        (\<forall>j\<in>Basis. u\<bullet>j = a\<bullet>j \<and> v\<bullet>j = a\<bullet>j \<or> u\<bullet>j = b\<bullet>j \<and> v\<bullet>j = b\<bullet>j \<or> u\<bullet>j = a\<bullet>j \<and> v\<bullet>j = b\<bullet>j)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2670
        unfolding forall_in_division[OF goal1(4)] apply(rule,rule,rule)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2671
        apply(rule_tac x=a in exI,rule_tac x=b in exI) apply(rule,rule refl)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2672
      proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2673
        fix u v and j :: 'a assume j:"j\<in>Basis" assume as:"{u..v} \<in> d" note division_ofD(3)[OF goal1(4) this]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2674
        hence uv:"\<forall>i\<in>Basis. u\<bullet>i \<le> v\<bullet>i" "u\<bullet>j \<le> v\<bullet>j" using j unfolding interval_ne_empty by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2675
        have *:"\<And>p r Q. \<not> j\<in>Basis \<or> p \<or> r \<or> (\<forall>x\<in>d. Q x) \<Longrightarrow> p \<or> r \<or> (Q {u..v})" using as j by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2676
        have "(j, u\<bullet>j) \<notin> division_points {a..b} d"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2677
          "(j, v\<bullet>j) \<notin> division_points {a..b} d" using True by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2678
        note this[unfolded de_Morgan_conj division_points_def mem_Collect_eq split_conv interval_bounds[OF ab'] bex_simps]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2679
        note *[OF this(1)] *[OF this(2)] note this[unfolded interval_bounds[OF uv(1)]]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2680
        moreover have "a\<bullet>j \<le> u\<bullet>j" "v\<bullet>j \<le> b\<bullet>j" using division_ofD(2,2,3)[OF goal1(4) as] 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2681
          unfolding subset_eq apply- apply(erule_tac x=u in ballE,erule_tac[3] x=v in ballE)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2682
          unfolding interval_ne_empty mem_interval using j by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2683
        ultimately show "u\<bullet>j = a\<bullet>j \<and> v\<bullet>j = a\<bullet>j \<or> u\<bullet>j = b\<bullet>j \<and> v\<bullet>j = b\<bullet>j \<or> u\<bullet>j = a\<bullet>j \<and> v\<bullet>j = b\<bullet>j"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2684
          unfolding not_less de_Morgan_disj using ab[rule_format,of j] uv(2) j by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2685
      qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2686
      have "(1/2) *\<^sub>R (a+b) \<in> {a..b}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2687
        unfolding mem_interval using ab by(auto intro!: less_imp_le simp: inner_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2688
      note this[unfolded division_ofD(6)[OF goal1(4),THEN sym] Union_iff]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2689
      then guess i .. note i=this guess u v using d'[rule_format,OF i(1)] apply-by(erule exE conjE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2690
      have "{a..b} \<in> d"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2691
      proof- { presume "i = {a..b}" thus ?thesis using i by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2692
        { presume "u = a" "v = b" thus "i = {a..b}" using uv by auto }
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2693
        show "u = a" "v = b" unfolding euclidean_eq_iff[where 'a='a]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2694
        proof(safe)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2695
          fix j :: 'a assume j:"j\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2696
          note i(2)[unfolded uv mem_interval,rule_format,of j]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2697
          thus "u \<bullet> j = a \<bullet> j" "v \<bullet> j = b \<bullet> j" using uv(2)[rule_format,of j] j by (auto simp: inner_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2698
        qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2699
      hence *:"d = insert {a..b} (d - {{a..b}})" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2700
      have "iterate opp (d - {{a..b}}) f = neutral opp" apply(rule iterate_eq_neutral[OF goal1(2)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2701
      proof fix x assume x:"x \<in> d - {{a..b}}" hence "x\<in>d" by auto note d'[rule_format,OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2702
        then guess u v apply-by(erule exE conjE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2703
        have "u\<noteq>a \<or> v\<noteq>b" using x[unfolded uv] by auto  
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2704
        then obtain j where "u\<bullet>j \<noteq> a\<bullet>j \<or> v\<bullet>j \<noteq> b\<bullet>j" and j:"j\<in>Basis" unfolding euclidean_eq_iff[where 'a='a] by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2705
        hence "u\<bullet>j = v\<bullet>j" using uv(2)[rule_format,OF j] by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2706
        hence "content {u..v} = 0"  unfolding content_eq_0 apply(rule_tac x=j in bexI) using j by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2707
        thus "f x = neutral opp" unfolding uv(1) by(rule operativeD(1)[OF goal1(3)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2708
      qed thus "iterate opp d f = f {a..b}" apply-apply(subst *) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2709
        apply(subst iterate_insert[OF goal1(2)]) using goal1(2,4) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2710
    next case False hence "\<exists>x. x\<in>division_points {a..b} d" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2711
      then guess k c unfolding split_paired_Ex apply- unfolding division_points_def mem_Collect_eq split_conv
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2712
        by(erule exE conjE)+ note this(2-4,1) note kc=this[unfolded interval_bounds[OF ab']]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2713
      from this(3) guess j .. note j=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2714
      def d1 \<equiv> "{l \<inter> {x. x\<bullet>k \<le> c} | l. l \<in> d \<and> l \<inter> {x. x\<bullet>k \<le> c} \<noteq> {}}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2715
      def d2 \<equiv> "{l \<inter> {x. x\<bullet>k \<ge> c} | l. l \<in> d \<and> l \<inter> {x. x\<bullet>k \<ge> c} \<noteq> {}}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2716
      def cb \<equiv> "(\<Sum>i\<in>Basis. (if i = k then c else b\<bullet>i) *\<^sub>R i)::'a"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2717
      def ca \<equiv> "(\<Sum>i\<in>Basis. (if i = k then c else a\<bullet>i) *\<^sub>R i)::'a"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2718
      note division_points_psubset[OF goal1(4) ab kc(1-2) j]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2719
      note psubset_card_mono[OF _ this(1)] psubset_card_mono[OF _ this(2)]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2720
      hence *:"(iterate opp d1 f) = f ({a..b} \<inter> {x. x\<bullet>k \<le> c})" "(iterate opp d2 f) = f ({a..b} \<inter> {x. x\<bullet>k \<ge> c})"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2721
        apply- unfolding interval_split[OF kc(4)] apply(rule_tac[!] goal1(1)[rule_format])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2722
        using division_split[OF goal1(4), where k=k and c=c]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2723
        unfolding interval_split[OF kc(4)] d1_def[symmetric] d2_def[symmetric] unfolding goal1(2) Suc_le_mono
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2724
        using goal1(2-3) using division_points_finite[OF goal1(4)] using kc(4) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2725
      have "f {a..b} = opp (iterate opp d1 f) (iterate opp d2 f)" (is "_ = ?prev")
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2726
        unfolding * apply(rule operativeD(2)) using goal1(3) using kc(4) by auto 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2727
      also have "iterate opp d1 f = iterate opp d (\<lambda>l. f(l \<inter> {x. x\<bullet>k \<le> c}))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2728
        unfolding d1_def apply(rule iterate_nonzero_image_lemma[unfolded o_def])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2729
        unfolding empty_as_interval apply(rule goal1 division_of_finite operativeD[OF goal1(3)])+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2730
        unfolding empty_as_interval[THEN sym] apply(rule content_empty)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2731
      proof(rule,rule,rule,erule conjE) fix l y assume as:"l \<in> d" "y \<in> d" "l \<inter> {x. x \<bullet> k \<le> c} = y \<inter> {x. x \<bullet> k \<le> c}" "l \<noteq> y" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2732
        from division_ofD(4)[OF goal1(4) this(1)] guess u v apply-by(erule exE)+ note l=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2733
        show "f (l \<inter> {x. x \<bullet> k \<le> c}) = neutral opp" unfolding l interval_split[OF kc(4)] 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2734
          apply(rule operativeD(1) goal1)+ unfolding interval_split[THEN sym,OF kc(4)] apply(rule division_split_left_inj)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2735
          apply(rule goal1) unfolding l[THEN sym] apply(rule as(1),rule as(2)) by(rule kc(4) as)+
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2736
      qed also have "iterate opp d2 f = iterate opp d (\<lambda>l. f(l \<inter> {x. x\<bullet>k \<ge> c}))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2737
        unfolding d2_def apply(rule iterate_nonzero_image_lemma[unfolded o_def])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2738
        unfolding empty_as_interval apply(rule goal1 division_of_finite operativeD[OF goal1(3)])+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2739
        unfolding empty_as_interval[THEN sym] apply(rule content_empty)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2740
      proof(rule,rule,rule,erule conjE) fix l y assume as:"l \<in> d" "y \<in> d" "l \<inter> {x. c \<le> x \<bullet> k} = y \<inter> {x. c \<le> x \<bullet> k}" "l \<noteq> y" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2741
        from division_ofD(4)[OF goal1(4) this(1)] guess u v apply-by(erule exE)+ note l=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2742
        show "f (l \<inter> {x. x \<bullet> k \<ge> c}) = neutral opp" unfolding l interval_split[OF kc(4)] 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2743
          apply(rule operativeD(1) goal1)+ unfolding interval_split[THEN sym,OF kc(4)] apply(rule division_split_right_inj)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2744
          apply(rule goal1) unfolding l[THEN sym] apply(rule as(1),rule as(2)) by(rule as kc(4))+
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2745
      qed also have *:"\<forall>x\<in>d. f x = opp (f (x \<inter> {x. x \<bullet> k \<le> c})) (f (x \<inter> {x. c \<le> x \<bullet> k}))"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2746
        unfolding forall_in_division[OF goal1(4)] apply(rule,rule,rule,rule operativeD(2)) using goal1(3) kc by auto 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2747
      have "opp (iterate opp d (\<lambda>l. f (l \<inter> {x. x \<bullet> k \<le> c}))) (iterate opp d (\<lambda>l. f (l \<inter> {x. c \<le> x \<bullet> k})))
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2748
        = iterate opp d f" apply(subst(3) iterate_eq[OF _ *[rule_format]]) prefer 3
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2749
        apply(rule iterate_op[THEN sym]) using goal1 by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2750
      finally show ?thesis by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2751
    qed qed qed 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2752
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2753
lemma iterate_image_nonzero: assumes "monoidal opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2754
  "finite s" "\<forall>x\<in>s. \<forall>y\<in>s. ~(x = y) \<and> f x = f y \<longrightarrow> g(f x) = neutral opp"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2755
  shows "iterate opp (f ` s) g = iterate opp s (g \<circ> f)" using assms
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2756
proof(induct rule:finite_subset_induct[OF assms(2) subset_refl])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2757
  case goal1 show ?case using assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2758
next case goal2 have *:"\<And>x y. y = neutral opp \<Longrightarrow> x = opp y x" using assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2759
  show ?case unfolding image_insert apply(subst iterate_insert[OF assms(1)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2760
    apply(rule finite_imageI goal2)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2761
    apply(cases "f a \<in> f ` F") unfolding if_P if_not_P apply(subst goal2(4)[OF assms(1) goal2(1)]) defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2762
    apply(subst iterate_insert[OF assms(1) goal2(1)]) defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2763
    apply(subst iterate_insert[OF assms(1) goal2(1)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2764
    unfolding if_not_P[OF goal2(3)] defer unfolding image_iff defer apply(erule bexE)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2765
    apply(rule *) unfolding o_def apply(rule_tac y=x in goal2(7)[rule_format])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2766
    using goal2 unfolding o_def by auto qed 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2767
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2768
lemma operative_tagged_division: assumes "monoidal opp" "operative opp f" "d tagged_division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2769
  shows "iterate(opp) d (\<lambda>(x,l). f l) = f {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2770
proof- have *:"(\<lambda>(x,l). f l) = (f o snd)" unfolding o_def by(rule,auto) note assm = tagged_division_ofD[OF assms(3)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2771
  have "iterate(opp) d (\<lambda>(x,l). f l) = iterate opp (snd ` d) f" unfolding *
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2772
    apply(rule iterate_image_nonzero[THEN sym,OF assms(1)]) apply(rule tagged_division_of_finite assms)+ 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2773
    unfolding Ball_def split_paired_All snd_conv apply(rule,rule,rule,rule,rule,rule,rule,erule conjE)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2774
  proof- fix a b aa ba assume as:"(a, b) \<in> d" "(aa, ba) \<in> d" "(a, b) \<noteq> (aa, ba)" "b = ba"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2775
    guess u v using assm(4)[OF as(1)] apply-by(erule exE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2776
    show "f b = neutral opp" unfolding uv apply(rule operativeD(1)[OF assms(2)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2777
      unfolding content_eq_0_interior using tagged_division_ofD(5)[OF assms(3) as(1-3)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2778
      unfolding as(4)[THEN sym] uv by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2779
  qed also have "\<dots> = f {a..b}" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2780
    using operative_division[OF assms(1-2) division_of_tagged_division[OF assms(3)]] .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2781
  finally show ?thesis . qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2782
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2783
subsection {* Additivity of content. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2784
51489
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51475
diff changeset
  2785
lemma setsum_iterate:
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51475
diff changeset
  2786
  assumes "finite s" shows "setsum f s = iterate op + s f"
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51475
diff changeset
  2787
proof -
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51475
diff changeset
  2788
  have *: "setsum f s = setsum f (support op + f s)"
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51475
diff changeset
  2789
    apply (rule setsum_mono_zero_right)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2790
    unfolding support_def neutral_monoid using assms by auto
51489
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51475
diff changeset
  2791
  then show ?thesis unfolding * iterate_def fold'_def setsum.eq_fold
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51475
diff changeset
  2792
    unfolding neutral_monoid by (simp add: comp_def)
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51475
diff changeset
  2793
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2794
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2795
lemma additive_content_division: assumes "d division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2796
  shows "setsum content d = content({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2797
  unfolding operative_division[OF monoidal_monoid operative_content assms,THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2798
  apply(subst setsum_iterate) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2799
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2800
lemma additive_content_tagged_division:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2801
  assumes "d tagged_division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2802
  shows "setsum (\<lambda>(x,l). content l) d = content({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2803
  unfolding operative_tagged_division[OF monoidal_monoid operative_content assms,THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2804
  apply(subst setsum_iterate) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2805
36334
068a01b4bc56 document generation for Multivariate_Analysis
huffman
parents: 36318
diff changeset
  2806
subsection {* Finally, the integral of a constant *}
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2807
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2808
lemma has_integral_const[intro]:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2809
  "((\<lambda>x. c) has_integral (content({a..b::'a::ordered_euclidean_space}) *\<^sub>R c)) ({a..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2810
  unfolding has_integral apply(rule,rule,rule_tac x="\<lambda>x. ball x 1" in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2811
  apply(rule,rule gauge_trivial)apply(rule,rule,erule conjE)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2812
  unfolding split_def apply(subst scaleR_left.setsum[THEN sym, unfolded o_def])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2813
  defer apply(subst additive_content_tagged_division[unfolded split_def]) apply assumption by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2814
50104
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  2815
lemma integral_const[simp]:
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  2816
  fixes a b :: "'a::ordered_euclidean_space"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  2817
  shows "integral {a .. b} (\<lambda>x. c) = content {a .. b} *\<^sub>R c"
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  2818
  by (rule integral_unique) (rule has_integral_const)
de19856feb54 move theorems to be more generally useable
hoelzl
parents: 49996
diff changeset
  2819
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2820
subsection {* Bounds on the norm of Riemann sums and the integral itself. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2821
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2822
lemma dsum_bound: assumes "p division_of {a..b}" "norm(c) \<le> e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2823
  shows "norm(setsum (\<lambda>l. content l *\<^sub>R c) p) \<le> e * content({a..b})" (is "?l \<le> ?r")
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
  2824
  apply(rule order_trans,rule norm_setsum) unfolding norm_scaleR setsum_left_distrib[THEN sym]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2825
  apply(rule order_trans[OF mult_left_mono],rule assms,rule setsum_abs_ge_zero)
36778
739a9379e29b avoid using real-specific versions of generic lemmas
huffman
parents: 36725
diff changeset
  2826
  apply(subst mult_commute) apply(rule mult_left_mono)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2827
  apply(rule order_trans[of _ "setsum content p"]) apply(rule eq_refl,rule setsum_cong2)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2828
  apply(subst abs_of_nonneg) unfolding additive_content_division[OF assms(1)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2829
proof- from order_trans[OF norm_ge_zero[of c] assms(2)] show "0 \<le> e" .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2830
  fix x assume "x\<in>p" from division_ofD(4)[OF assms(1) this] guess u v apply-by(erule exE)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2831
  thus "0 \<le> content x" using content_pos_le by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2832
qed(insert assms,auto)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2833
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2834
lemma rsum_bound: assumes "p tagged_division_of {a..b}" "\<forall>x\<in>{a..b}. norm(f x) \<le> e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2835
  shows "norm(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p) \<le> e * content({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2836
proof(cases "{a..b} = {}") case True
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2837
  show ?thesis using assms(1) unfolding True tagged_division_of_trivial by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2838
next case False show ?thesis
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
  2839
    apply(rule order_trans,rule norm_setsum) unfolding split_def norm_scaleR
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2840
    apply(rule order_trans[OF setsum_mono]) apply(rule mult_left_mono[OF _ abs_ge_zero, of _ e]) defer
36778
739a9379e29b avoid using real-specific versions of generic lemmas
huffman
parents: 36725
diff changeset
  2841
    unfolding setsum_left_distrib[THEN sym] apply(subst mult_commute) apply(rule mult_left_mono)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2842
    apply(rule order_trans[of _ "setsum (content \<circ> snd) p"]) apply(rule eq_refl,rule setsum_cong2)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2843
    apply(subst o_def, rule abs_of_nonneg)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2844
  proof- show "setsum (content \<circ> snd) p \<le> content {a..b}" apply(rule eq_refl)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2845
      unfolding additive_content_tagged_division[OF assms(1),THEN sym] split_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2846
    guess w using nonempty_witness[OF False] .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2847
    thus "e\<ge>0" apply-apply(rule order_trans) defer apply(rule assms(2)[rule_format],assumption) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2848
    fix xk assume *:"xk\<in>p" guess x k  using surj_pair[of xk] apply-by(erule exE)+ note xk = this *[unfolded this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2849
    from tagged_division_ofD(4)[OF assms(1) xk(2)] guess u v apply-by(erule exE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2850
    show "0\<le> content (snd xk)" unfolding xk snd_conv uv by(rule content_pos_le)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2851
    show "norm (f (fst xk)) \<le> e" unfolding xk fst_conv using tagged_division_ofD(2,3)[OF assms(1) xk(2)] assms(2) by auto
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
  2852
  qed qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2853
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2854
lemma rsum_diff_bound:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2855
  assumes "p tagged_division_of {a..b}"  "\<forall>x\<in>{a..b}. norm(f x - g x) \<le> e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2856
  shows "norm(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - setsum (\<lambda>(x,k). content k *\<^sub>R g x) p) \<le> e * content({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2857
  apply(rule order_trans[OF _ rsum_bound[OF assms]]) apply(rule eq_refl) apply(rule arg_cong[where f=norm])
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  2858
  unfolding setsum_subtractf[THEN sym] apply(rule setsum_cong2) unfolding scaleR_diff_right by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2859
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2860
lemma has_integral_bound: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::real_normed_vector"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2861
  assumes "0 \<le> B" "(f has_integral i) ({a..b})" "\<forall>x\<in>{a..b}. norm(f x) \<le> B"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2862
  shows "norm i \<le> B * content {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2863
proof- let ?P = "content {a..b} > 0" { presume "?P \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2864
    thus ?thesis proof(cases ?P) case False
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2865
      hence *:"content {a..b} = 0" using content_lt_nz by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2866
      hence **:"i = 0" using assms(2) apply(subst has_integral_null_eq[THEN sym]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2867
      show ?thesis unfolding * ** using assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2868
    qed auto } assume ab:?P
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2869
  { presume "\<not> ?thesis \<Longrightarrow> False" thus ?thesis by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2870
  assume "\<not> ?thesis" hence *:"norm i - B * content {a..b} > 0" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2871
  from assms(2)[unfolded has_integral,rule_format,OF *] guess d apply-by(erule exE conjE)+ note d=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2872
  from fine_division_exists[OF this(1), of a b] guess p . note p=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2873
  have *:"\<And>s B. norm s \<le> B \<Longrightarrow> \<not> (norm (s - i) < norm i - B)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2874
  proof- case goal1 thus ?case unfolding not_less
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2875
    using norm_triangle_sub[of i s] unfolding norm_minus_commute by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2876
  qed show False using d(2)[OF conjI[OF p]] *[OF rsum_bound[OF p(1) assms(3)]] by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2877
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2878
subsection {* Similar theorems about relationship among components. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2879
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2880
lemma rsum_component_le: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2881
  assumes "p tagged_division_of {a..b}"  "\<forall>x\<in>{a..b}. (f x)\<bullet>i \<le> (g x)\<bullet>i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2882
  shows "(setsum (\<lambda>(x,k). content k *\<^sub>R f x) p)\<bullet>i \<le> (setsum (\<lambda>(x,k). content k *\<^sub>R g x) p)\<bullet>i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2883
  unfolding inner_setsum_left apply(rule setsum_mono) apply safe
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2884
proof- fix a b assume ab:"(a,b) \<in> p" note assm = tagged_division_ofD(2-4)[OF assms(1) ab]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2885
  from this(3) guess u v apply-by(erule exE)+ note b=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2886
  show "(content b *\<^sub>R f a) \<bullet> i \<le> (content b *\<^sub>R g a) \<bullet> i" unfolding b
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2887
    unfolding inner_simps real_scaleR_def apply(rule mult_left_mono)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2888
    defer apply(rule content_pos_le,rule assms(2)[rule_format]) using assm by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2889
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2890
lemma has_integral_component_le:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2891
  fixes f g::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2892
  assumes k: "k \<in> Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2893
  assumes "(f has_integral i) s" "(g has_integral j) s"  "\<forall>x\<in>s. (f x)\<bullet>k \<le> (g x)\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2894
  shows "i\<bullet>k \<le> j\<bullet>k"
50348
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2895
proof -
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2896
  have lem:"\<And>a b i (j::'b). \<And>g f::'a \<Rightarrow> 'b. (f has_integral i) ({a..b}) \<Longrightarrow> 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2897
    (g has_integral j) ({a..b}) \<Longrightarrow> \<forall>x\<in>{a..b}. (f x)\<bullet>k \<le> (g x)\<bullet>k \<Longrightarrow> i\<bullet>k \<le> j\<bullet>k"
50348
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2898
  proof (rule ccontr)
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2899
    case goal1
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2900
    then have *: "0 < (i\<bullet>k - j\<bullet>k) / 3" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2901
    guess d1 using goal1(1)[unfolded has_integral,rule_format,OF *] apply-by(erule exE conjE)+ note d1=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2902
    guess d2 using goal1(2)[unfolded has_integral,rule_format,OF *] apply-by(erule exE conjE)+ note d2=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2903
    guess p using fine_division_exists[OF gauge_inter[OF d1(1) d2(1)], of a b] unfolding fine_inter .
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2904
    note p = this(1) conjunctD2[OF this(2)]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2905
    note le_less_trans[OF Basis_le_norm[OF k]]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2906
    note this[OF d1(2)[OF conjI[OF p(1,2)]]] this[OF d2(2)[OF conjI[OF p(1,3)]]]
50348
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2907
    thus False
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2908
      unfolding inner_simps
50348
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2909
      using rsum_component_le[OF p(1) goal1(3)]
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2910
      by (simp add: abs_real_def split: split_if_asm)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2911
  qed let ?P = "\<exists>a b. s = {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2912
  { presume "\<not> ?P \<Longrightarrow> ?thesis" thus ?thesis proof(cases ?P)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2913
      case True then guess a b apply-by(erule exE)+ note s=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2914
      show ?thesis apply(rule lem) using assms[unfolded s] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2915
    qed auto } assume as:"\<not> ?P"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2916
  { presume "\<not> ?thesis \<Longrightarrow> False" thus ?thesis by auto }
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2917
  assume "\<not> i\<bullet>k \<le> j\<bullet>k" hence ij:"(i\<bullet>k - j\<bullet>k) / 3 > 0" by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2918
  note has_integral_altD[OF _ as this]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2919
  from this[OF assms(2)] this[OF assms(3)] guess B1 B2 . note B=this[rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2920
  have "bounded (ball 0 B1 \<union> ball (0::'a) B2)" unfolding bounded_Un by(rule conjI bounded_ball)+
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2921
  from bounded_subset_closed_interval[OF this] guess a b apply- by(erule exE)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2922
  note ab = conjunctD2[OF this[unfolded Un_subset_iff]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2923
  guess w1 using B(2)[OF ab(1)] .. note w1=conjunctD2[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2924
  guess w2 using B(4)[OF ab(2)] .. note w2=conjunctD2[OF this]
50348
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2925
  have *:"\<And>w1 w2 j i::real .\<bar>w1 - i\<bar> < (i - j) / 3 \<Longrightarrow> \<bar>w2 - j\<bar> < (i - j) / 3 \<Longrightarrow> w1 \<le> w2 \<Longrightarrow> False"
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  2926
    by (simp add: abs_real_def split: split_if_asm)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2927
  note le_less_trans[OF Basis_le_norm[OF k]] note this[OF w1(2)] this[OF w2(2)] moreover
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2928
  have "w1\<bullet>k \<le> w2\<bullet>k" apply(rule lem[OF w1(1) w2(1)]) using assms by auto ultimately
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2929
  show False unfolding inner_simps by(rule *)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2930
qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2931
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2932
lemma integral_component_le: fixes g f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2933
  assumes "k\<in>Basis" "f integrable_on s" "g integrable_on s"  "\<forall>x\<in>s. (f x)\<bullet>k \<le> (g x)\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2934
  shows "(integral s f)\<bullet>k \<le> (integral s g)\<bullet>k"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2935
  apply(rule has_integral_component_le) using integrable_integral assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2936
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2937
lemma has_integral_component_nonneg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2938
  assumes "k\<in>Basis" "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> (f x)\<bullet>k" shows "0 \<le> i\<bullet>k" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2939
  using has_integral_component_le[OF assms(1) has_integral_0 assms(2)] using assms(3-) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2940
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2941
lemma integral_component_nonneg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2942
  assumes "k\<in>Basis" "f integrable_on s" "\<forall>x\<in>s. 0 \<le> (f x)\<bullet>k" shows "0 \<le> (integral s f)\<bullet>k"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  2943
  apply(rule has_integral_component_nonneg) using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  2944
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2945
lemma has_integral_component_neg: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2946
  assumes "k\<in>Basis" "(f has_integral i) s" "\<forall>x\<in>s. (f x)\<bullet>k \<le> 0"shows "i\<bullet>k \<le> 0" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2947
  using has_integral_component_le[OF assms(1,2) has_integral_0] assms(2-) by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2948
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2949
lemma has_integral_component_lbound:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2950
  fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2951
  assumes "(f has_integral i) {a..b}"  "\<forall>x\<in>{a..b}. B \<le> f(x)\<bullet>k" "k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2952
  shows "B * content {a..b} \<le> i\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2953
  using has_integral_component_le[OF assms(3) has_integral_const assms(1),of "(\<Sum>i\<in>Basis. B *\<^sub>R i)::'b"] assms(2-)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2954
  by (auto simp add:field_simps)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2955
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2956
lemma has_integral_component_ubound:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2957
  fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2958
  assumes "(f has_integral i) {a..b}" "\<forall>x\<in>{a..b}. f x\<bullet>k \<le> B" "k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2959
  shows "i\<bullet>k \<le> B * content({a..b})"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2960
  using has_integral_component_le[OF assms(3,1) has_integral_const, of "\<Sum>i\<in>Basis. B *\<^sub>R i"]  assms(2-)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2961
  by(auto simp add:field_simps)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2962
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2963
lemma integral_component_lbound: fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2964
  assumes "f integrable_on {a..b}" "\<forall>x\<in>{a..b}. B \<le> f(x)\<bullet>k" "k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2965
  shows "B * content({a..b}) \<le> (integral({a..b}) f)\<bullet>k"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2966
  apply(rule has_integral_component_lbound) using assms unfolding has_integral_integral by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2967
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2968
lemma integral_component_ubound: fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2969
  assumes "f integrable_on {a..b}" "\<forall>x\<in>{a..b}. f(x)\<bullet>k \<le> B" "k\<in>Basis" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  2970
  shows "(integral({a..b}) f)\<bullet>k \<le> B * content({a..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2971
  apply(rule has_integral_component_ubound) using assms unfolding has_integral_integral by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2972
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2973
subsection {* Uniform limit of integrable functions is integrable. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2974
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  2975
lemma integrable_uniform_limit: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2976
  assumes "\<forall>e>0. \<exists>g. (\<forall>x\<in>{a..b}. norm(f x - g x) \<le> e) \<and> g integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2977
  shows "f integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2978
proof- { presume *:"content {a..b} > 0 \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2979
    show ?thesis apply cases apply(rule *,assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2980
      unfolding content_lt_nz integrable_on_def using has_integral_null by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2981
  assume as:"content {a..b} > 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2982
  have *:"\<And>P. \<forall>e>(0::real). P e \<Longrightarrow> \<forall>n::nat. P (inverse (real n+1))" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2983
  from choice[OF *[OF assms]] guess g .. note g=conjunctD2[OF this[rule_format],rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2984
  from choice[OF allI[OF g(2)[unfolded integrable_on_def], of "\<lambda>x. x"]] guess i .. note i=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2985
  
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2986
  have "Cauchy i" unfolding Cauchy_def
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2987
  proof(rule,rule) fix e::real assume "e>0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2988
    hence "e / 4 / content {a..b} > 0" using as by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2989
    then guess M apply-apply(subst(asm) real_arch_inv) by(erule exE conjE)+ note M=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2990
    show "\<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (i m) (i n) < e" apply(rule_tac x=M in exI,rule,rule,rule,rule)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2991
    proof- case goal1 have "e/4>0" using `e>0` by auto note * = i[unfolded has_integral,rule_format,OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2992
      from *[of m] guess gm apply-by(erule conjE exE)+ note gm=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2993
      from *[of n] guess gn apply-by(erule conjE exE)+ note gn=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2994
      from fine_division_exists[OF gauge_inter[OF gm(1) gn(1)], of a b] guess p . note p=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2995
      have lem2:"\<And>s1 s2 i1 i2. norm(s2 - s1) \<le> e/2 \<Longrightarrow> norm(s1 - i1) < e / 4 \<Longrightarrow> norm(s2 - i2) < e / 4 \<Longrightarrow>norm(i1 - i2) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2996
      proof- case goal1 have "norm (i1 - i2) \<le> norm (i1 - s1) + norm (s1 - s2) + norm (s2 - i2)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  2997
          using norm_triangle_ineq[of "i1 - s1" "s1 - i2"]
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  2998
          using norm_triangle_ineq[of "s1 - s2" "s2 - i2"] by(auto simp add:algebra_simps)
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  2999
        also have "\<dots> < e" using goal1 unfolding norm_minus_commute by(auto simp add:algebra_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3000
        finally show ?case .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3001
      qed
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  3002
      show ?case unfolding dist_norm apply(rule lem2) defer
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3003
        apply(rule gm(2)[OF conjI[OF p(1)]],rule_tac[2] gn(2)[OF conjI[OF p(1)]])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3004
        using conjunctD2[OF p(2)[unfolded fine_inter]] apply- apply assumption+ apply(rule order_trans)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3005
        apply(rule rsum_diff_bound[OF p(1), where e="2 / real M"])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3006
      proof show "2 / real M * content {a..b} \<le> e / 2" unfolding divide_inverse 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3007
          using M as by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3008
        fix x assume x:"x \<in> {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3009
        have "norm (f x - g n x) + norm (f x - g m x) \<le> inverse (real n + 1) + inverse (real m + 1)" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3010
            using g(1)[OF x, of n] g(1)[OF x, of m] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3011
        also have "\<dots> \<le> inverse (real M) + inverse (real M)" apply(rule add_mono)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3012
          apply(rule_tac[!] le_imp_inverse_le) using goal1 M by auto
36778
739a9379e29b avoid using real-specific versions of generic lemmas
huffman
parents: 36725
diff changeset
  3013
        also have "\<dots> = 2 / real M" unfolding divide_inverse by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3014
        finally show "norm (g n x - g m x) \<le> 2 / real M"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3015
          using norm_triangle_le[of "g n x - f x" "f x - g m x" "2 / real M"]
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  3016
          by(auto simp add:algebra_simps simp add:norm_minus_commute)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3017
      qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3018
  from this[unfolded convergent_eq_cauchy[THEN sym]] guess s .. note s=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3019
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3020
  show ?thesis unfolding integrable_on_def apply(rule_tac x=s in exI) unfolding has_integral
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3021
  proof(rule,rule)  
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3022
    case goal1 hence *:"e/3 > 0" by auto
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  3023
    from LIMSEQ_D [OF s this] guess N1 .. note N1=this
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3024
    from goal1 as have "e / 3 / content {a..b} > 0" by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3025
    from real_arch_invD[OF this] guess N2 apply-by(erule exE conjE)+ note N2=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3026
    from i[of "N1 + N2",unfolded has_integral,rule_format,OF *] guess g' .. note g'=conjunctD2[OF this,rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3027
    have lem:"\<And>sf sg i. norm(sf - sg) \<le> e / 3 \<Longrightarrow> norm(i - s) < e / 3 \<Longrightarrow> norm(sg - i) < e / 3 \<Longrightarrow> norm(sf - s) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3028
    proof- case goal1 have "norm (sf - s) \<le> norm (sf - sg) + norm (sg - i) + norm (i - s)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3029
        using norm_triangle_ineq[of "sf - sg" "sg - s"]
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  3030
        using norm_triangle_ineq[of "sg -  i" " i - s"] by(auto simp add:algebra_simps)
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  3031
      also have "\<dots> < e" using goal1 unfolding norm_minus_commute by(auto simp add:algebra_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3032
      finally show ?case .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3033
    qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3034
    show ?case apply(rule_tac x=g' in exI) apply(rule,rule g')
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3035
    proof(rule,rule) fix p assume p:"p tagged_division_of {a..b} \<and> g' fine p" note * = g'(2)[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3036
      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - s) < e" apply-apply(rule lem[OF _ _ *])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3037
        apply(rule order_trans,rule rsum_diff_bound[OF p[THEN conjunct1]]) apply(rule,rule g,assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3038
      proof- have "content {a..b} < e / 3 * (real N2)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3039
          using N2 unfolding inverse_eq_divide using as by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3040
        hence "content {a..b} < e / 3 * (real (N1 + N2) + 1)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3041
          apply-apply(rule less_le_trans,assumption) using `e>0` by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3042
        thus "inverse (real (N1 + N2) + 1) * content {a..b} \<le> e / 3"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3043
          unfolding inverse_eq_divide by(auto simp add:field_simps)
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  3044
        show "norm (i (N1 + N2) - s) < e / 3" by(rule N1[rule_format],auto)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3045
      qed qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3046
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3047
subsection {* Negligible sets. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3048
37665
579258a77fec Add theory for indicator function.
hoelzl
parents: 37489
diff changeset
  3049
definition "negligible (s::('a::ordered_euclidean_space) set) \<equiv> (\<forall>a b. ((indicator s :: 'a\<Rightarrow>real) has_integral 0) {a..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3050
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3051
subsection {* Negligibility of hyperplane. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3052
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3053
lemma vsum_nonzero_image_lemma: 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3054
  assumes "finite s" "g(a) = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3055
  "\<forall>x\<in>s. \<forall>y\<in>s. f x = f y \<and> x \<noteq> y \<longrightarrow> g(f x) = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3056
  shows "setsum g {f x |x. x \<in> s \<and> f x \<noteq> a} = setsum (g o f) s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3057
  unfolding setsum_iterate[OF assms(1)] apply(subst setsum_iterate) defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3058
  apply(rule iterate_nonzero_image_lemma) apply(rule assms monoidal_monoid)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3059
  unfolding assms using neutral_add unfolding neutral_add using assms by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3060
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3061
lemma interval_doublesplit:  fixes a::"'a::ordered_euclidean_space" assumes "k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3062
  shows "{a..b} \<inter> {x . abs(x\<bullet>k - c) \<le> (e::real)} = 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3063
  {(\<Sum>i\<in>Basis. (if i = k then max (a\<bullet>k) (c - e) else a\<bullet>i) *\<^sub>R i) .. 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3064
   (\<Sum>i\<in>Basis. (if i = k then min (b\<bullet>k) (c + e) else b\<bullet>i) *\<^sub>R i)}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3065
proof- have *:"\<And>x c e::real. abs(x - c) \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3066
  have **:"\<And>s P Q. s \<inter> {x. P x \<and> Q x} = (s \<inter> {x. Q x}) \<inter> {x. P x}" by blast
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3067
  show ?thesis unfolding * ** interval_split[OF assms] by(rule refl) qed
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3068
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3069
lemma division_doublesplit: fixes a::"'a::ordered_euclidean_space" assumes "p division_of {a..b}" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3070
  shows "{l \<inter> {x. abs(x\<bullet>k - c) \<le> e} |l. l \<in> p \<and> l \<inter> {x. abs(x\<bullet>k - c) \<le> e} \<noteq> {}} division_of ({a..b} \<inter> {x. abs(x\<bullet>k - c) \<le> e})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3071
proof- have *:"\<And>x c. abs(x - c) \<le> e \<longleftrightarrow> x \<ge> c - e \<and> x \<le> c + e" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3072
  have **:"\<And>p q p' q'. p division_of q \<Longrightarrow> p = p' \<Longrightarrow> q = q' \<Longrightarrow> p' division_of q'" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3073
  note division_split(1)[OF assms, where c="c+e",unfolded interval_split[OF k]]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3074
  note division_split(2)[OF this, where c="c-e" and k=k,OF k] 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3075
  thus ?thesis apply(rule **) using k apply- unfolding interval_doublesplit unfolding * unfolding interval_split interval_doublesplit
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 38656
diff changeset
  3076
    apply(rule set_eqI) unfolding mem_Collect_eq apply rule apply(erule conjE exE)+ apply(rule_tac x=la in exI) defer
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3077
    apply(erule conjE exE)+ apply(rule_tac x="l \<inter> {x. c + e \<ge> x \<bullet> k}" in exI) apply rule defer apply rule
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3078
    apply(rule_tac x=l in exI) by blast+ qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3079
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3080
lemma content_doublesplit: fixes a::"'a::ordered_euclidean_space" assumes "0 < e" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3081
  obtains d where "0 < d" "content({a..b} \<inter> {x. abs(x\<bullet>k - c) \<le> d}) < e"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3082
proof(cases "content {a..b} = 0")
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3083
  case True show ?thesis apply(rule that[of 1]) defer unfolding interval_doublesplit[OF k]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3084
    apply(rule le_less_trans[OF content_subset]) defer apply(subst True)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3085
    unfolding interval_doublesplit[THEN sym,OF k] using assms by auto 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3086
next case False def d \<equiv> "e / 3 / setprod (\<lambda>i. b\<bullet>i - a\<bullet>i) (Basis - {k})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3087
  note False[unfolded content_eq_0 not_ex not_le, rule_format]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3088
  hence "\<And>x. x\<in>Basis \<Longrightarrow> b\<bullet>x > a\<bullet>x" by(auto simp add:not_le)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3089
  hence prod0:"0 < setprod (\<lambda>i. b\<bullet>i - a\<bullet>i) (Basis - {k})" apply-apply(rule setprod_pos) by(auto simp add:field_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3090
  hence "d > 0" unfolding d_def using assms by(auto simp add:field_simps) thus ?thesis
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3091
  proof(rule that[of d]) have *:"Basis = insert k (Basis - {k})" using k by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3092
    have **:"{a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {} \<Longrightarrow> 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3093
      (\<Prod>i\<in>Basis - {k}. interval_upperbound ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3094
      - interval_lowerbound ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<bullet> i)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3095
      = (\<Prod>i\<in>Basis - {k}. b\<bullet>i - a\<bullet>i)" apply(rule setprod_cong,rule refl) 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3096
      unfolding interval_doublesplit[OF k] apply(subst interval_bounds) defer apply(subst interval_bounds)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3097
      unfolding interval_eq_empty not_ex not_less by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3098
    show "content ({a..b} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) < e" apply(cases) unfolding content_def apply(subst if_P,assumption,rule assms)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3099
      unfolding if_not_P apply(subst *) apply(subst setprod_insert) unfolding **
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3100
      unfolding interval_doublesplit[OF k] interval_eq_empty not_ex not_less prefer 3
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3101
      apply(subst interval_bounds) defer apply(subst interval_bounds)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3102
      apply (simp_all only: k inner_setsum_left_Basis simp_thms if_P cong: bex_cong ball_cong)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3103
    proof -
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3104
      have "(min (b \<bullet> k) (c + d) - max (a \<bullet> k) (c - d)) \<le> 2 * d" by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3105
      also have "... < e / (\<Prod>i\<in>Basis - {k}. b \<bullet> i - a \<bullet> i)" unfolding d_def using assms prod0 by(auto simp add:field_simps)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3106
      finally show "(min (b \<bullet> k) (c + d) - max (a \<bullet> k) (c - d)) * (\<Prod>i\<in>Basis - {k}. b \<bullet> i - a \<bullet> i) < e"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3107
        unfolding pos_less_divide_eq[OF prod0] .
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3108
    qed auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3109
  qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3110
qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3111
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3112
lemma negligible_standard_hyperplane[intro]: 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3113
  fixes k :: "'a::ordered_euclidean_space"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3114
  assumes k: "k \<in> Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3115
  shows "negligible {x. x\<bullet>k = c}" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3116
  unfolding negligible_def has_integral apply(rule,rule,rule,rule)
37665
579258a77fec Add theory for indicator function.
hoelzl
parents: 37489
diff changeset
  3117
proof-
579258a77fec Add theory for indicator function.
hoelzl
parents: 37489
diff changeset
  3118
  case goal1 from content_doublesplit[OF this k,of a b c] guess d . note d=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3119
  let ?i = "indicator {x::'a. x\<bullet>k = c} :: 'a\<Rightarrow>real"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3120
  show ?case apply(rule_tac x="\<lambda>x. ball x d" in exI) apply(rule,rule gauge_ball,rule d)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3121
  proof(rule,rule) fix p assume p:"p tagged_division_of {a..b} \<and> (\<lambda>x. ball x d) fine p"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3122
    have *:"(\<Sum>(x, ka)\<in>p. content ka *\<^sub>R ?i x) = (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. abs(x\<bullet>k - c) \<le> d}) *\<^sub>R ?i x)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3123
      apply(rule setsum_cong2) unfolding split_paired_all real_scaleR_def mult_cancel_right split_conv
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3124
      apply(cases,rule disjI1,assumption,rule disjI2)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3125
    proof- fix x l assume as:"(x,l)\<in>p" "?i x \<noteq> 0" hence xk:"x\<bullet>k = c" unfolding indicator_def apply-by(rule ccontr,auto)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3126
      show "content l = content (l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})" apply(rule arg_cong[where f=content])
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 38656
diff changeset
  3127
        apply(rule set_eqI,rule,rule) unfolding mem_Collect_eq
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3128
      proof- fix y assume y:"y\<in>l" note p[THEN conjunct2,unfolded fine_def,rule_format,OF as(1),unfolded split_conv]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3129
        note this[unfolded subset_eq mem_ball dist_norm,rule_format,OF y] note le_less_trans[OF Basis_le_norm[OF k] this]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3130
        thus "\<bar>y \<bullet> k - c\<bar> \<le> d" unfolding inner_simps xk by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3131
      qed auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3132
    note p'= tagged_division_ofD[OF p[THEN conjunct1]] and p''=division_of_tagged_division[OF p[THEN conjunct1]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3133
    show "norm ((\<Sum>(x, ka)\<in>p. content ka *\<^sub>R ?i x) - 0) < e" unfolding diff_0_right * unfolding real_scaleR_def real_norm_def
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3134
      apply(subst abs_of_nonneg) apply(rule setsum_nonneg,rule) unfolding split_paired_all split_conv
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3135
      apply(rule mult_nonneg_nonneg) apply(drule p'(4)) apply(erule exE)+ apply(rule_tac b=b in back_subst)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3136
      prefer 2 apply(subst(asm) eq_commute) apply assumption
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3137
      apply(subst interval_doublesplit[OF k]) apply(rule content_pos_le) apply(rule indicator_pos_le)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3138
    proof- have "(\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) * ?i x) \<le> (\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3139
        apply(rule setsum_mono) unfolding split_paired_all split_conv 
44457
d366fa5551ef declare euclidean_simps [simp] at the point they are proved;
huffman
parents: 44282
diff changeset
  3140
        apply(rule mult_right_le_one_le) apply(drule p'(4)) by(auto simp add:interval_doublesplit[OF k])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3141
      also have "... < e" apply(subst setsum_over_tagged_division_lemma[OF p[THEN conjunct1]])
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3142
      proof- case goal1 have "content ({u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<le> content {u..v}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3143
          unfolding interval_doublesplit[OF k] apply(rule content_subset) unfolding interval_doublesplit[THEN sym,OF k] by auto
50348
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  3144
        thus ?case unfolding goal1 unfolding interval_doublesplit[OF k]
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  3145
          by (blast intro: antisym)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3146
      next have *:"setsum content {l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} |l. l \<in> snd ` p \<and> l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} \<noteq> {}} \<ge> 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3147
          apply(rule setsum_nonneg,rule) unfolding mem_Collect_eq image_iff apply(erule exE bexE conjE)+ unfolding split_paired_all 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3148
        proof- fix x l a b assume as:"x = l \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}" "(a, b) \<in> p" "l = snd (a, b)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3149
          guess u v using p'(4)[OF as(2)] apply-by(erule exE)+ note * = this
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3150
          show "content x \<ge> 0" unfolding as snd_conv * interval_doublesplit[OF k] by(rule content_pos_le)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3151
        qed have **:"norm (1::real) \<le> 1" by auto note division_doublesplit[OF p'' k,unfolded interval_doublesplit[OF k]]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3152
        note dsum_bound[OF this **,unfolded interval_doublesplit[THEN sym,OF k]]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3153
        note this[unfolded real_scaleR_def real_norm_def mult_1_right mult_1, of c d] note le_less_trans[OF this d(2)]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3154
        from this[unfolded abs_of_nonneg[OF *]] show "(\<Sum>ka\<in>snd ` p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d})) < e"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3155
          apply(subst vsum_nonzero_image_lemma[of "snd ` p" content "{}", unfolded o_def,THEN sym])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3156
          apply(rule finite_imageI p' content_empty)+ unfolding forall_in_division[OF p'']
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3157
        proof(rule,rule,rule,rule,rule,rule,rule,erule conjE) fix m n u v
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3158
          assume as:"{m..n} \<in> snd ` p" "{u..v} \<in> snd ` p" "{m..n} \<noteq> {u..v}"  "{m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d} = {u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3159
          have "({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<inter> ({u..v} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) \<subseteq> {m..n} \<inter> {u..v}" by blast
44522
2f7e9d890efe rename subset_{interior,closure} to {interior,closure}_mono;
huffman
parents: 44514
diff changeset
  3160
          note interior_mono[OF this, unfolded division_ofD(5)[OF p'' as(1-3)] interior_inter[of "{m..n}"]]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3161
          hence "interior ({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = {}" unfolding as Int_absorb by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3162
          thus "content ({m..n} \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) = 0" unfolding interval_doublesplit[OF k] content_eq_0_interior[THEN sym] .
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3163
        qed qed
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3164
      finally show "(\<Sum>(x, ka)\<in>p. content (ka \<inter> {x. \<bar>x \<bullet> k - c\<bar> \<le> d}) * ?i x) < e" .
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3165
    qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3166
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3167
subsection {* A technical lemma about "refinement" of division. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3168
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3169
lemma tagged_division_finer: fixes p::"(('a::ordered_euclidean_space) \<times> (('a::ordered_euclidean_space) set)) set"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3170
  assumes "p tagged_division_of {a..b}" "gauge d"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3171
  obtains q where "q tagged_division_of {a..b}" "d fine q" "\<forall>(x,k) \<in> p. k \<subseteq> d(x) \<longrightarrow> (x,k) \<in> q"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3172
proof-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3173
  let ?P = "\<lambda>p. p tagged_partial_division_of {a..b} \<longrightarrow> gauge d \<longrightarrow>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3174
    (\<exists>q. q tagged_division_of (\<Union>{k. \<exists>x. (x,k) \<in> p}) \<and> d fine q \<and>
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3175
                   (\<forall>(x,k) \<in> p. k \<subseteq> d(x) \<longrightarrow> (x,k) \<in> q))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3176
  { have *:"finite p" "p tagged_partial_division_of {a..b}" using assms(1) unfolding tagged_division_of_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3177
    presume "\<And>p. finite p \<Longrightarrow> ?P p" from this[rule_format,OF * assms(2)] guess q .. note q=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3178
    thus ?thesis apply-apply(rule that[of q]) unfolding tagged_division_ofD[OF assms(1)] by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3179
  } fix p::"(('a::ordered_euclidean_space) \<times> (('a::ordered_euclidean_space) set)) set" assume as:"finite p"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3180
  show "?P p" apply(rule,rule) using as proof(induct p) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3181
    case empty show ?case apply(rule_tac x="{}" in exI) unfolding fine_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3182
  next case (insert xk p) guess x k using surj_pair[of xk] apply- by(erule exE)+ note xk=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3183
    note tagged_partial_division_subset[OF insert(4) subset_insertI]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3184
    from insert(3)[OF this insert(5)] guess q1 .. note q1 = conjunctD3[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3185
    have *:"\<Union>{l. \<exists>y. (y,l) \<in> insert xk p} = k \<union> \<Union>{l. \<exists>y. (y,l) \<in> p}" unfolding xk by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3186
    note p = tagged_partial_division_ofD[OF insert(4)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3187
    from p(4)[unfolded xk, OF insertI1] guess u v apply-by(erule exE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3188
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3189
    have "finite {k. \<exists>x. (x, k) \<in> p}" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3190
      apply(rule finite_subset[of _ "snd ` p"],rule) unfolding subset_eq image_iff mem_Collect_eq
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3191
      apply(erule exE,rule_tac x="(xa,x)" in bexI) using p by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3192
    hence int:"interior {u..v} \<inter> interior (\<Union>{k. \<exists>x. (x, k) \<in> p}) = {}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3193
      apply(rule inter_interior_unions_intervals) apply(rule open_interior) apply(rule_tac[!] ballI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3194
      unfolding mem_Collect_eq apply(erule_tac[!] exE) apply(drule p(4)[OF insertI2],assumption)      
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3195
      apply(rule p(5))  unfolding uv xk apply(rule insertI1,rule insertI2) apply assumption
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3196
      using insert(2) unfolding uv xk by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3197
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3198
    show ?case proof(cases "{u..v} \<subseteq> d x")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3199
      case True thus ?thesis apply(rule_tac x="{(x,{u..v})} \<union> q1" in exI) apply rule
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3200
        unfolding * uv apply(rule tagged_division_union,rule tagged_division_of_self)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3201
        apply(rule p[unfolded xk uv] insertI1)+  apply(rule q1,rule int) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3202
        apply(rule,rule fine_union,subst fine_def) defer apply(rule q1)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3203
        unfolding Ball_def split_paired_All split_conv apply(rule,rule,rule,rule)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3204
        apply(erule insertE) defer apply(rule UnI2) apply(drule q1(3)[rule_format]) unfolding xk uv by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3205
    next case False from fine_division_exists[OF assms(2), of u v] guess q2 . note q2=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3206
      show ?thesis apply(rule_tac x="q2 \<union> q1" in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3207
        apply rule unfolding * uv apply(rule tagged_division_union q2 q1 int fine_union)+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3208
        unfolding Ball_def split_paired_All split_conv apply rule apply(rule fine_union)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3209
        apply(rule q1 q2)+ apply(rule,rule,rule,rule) apply(erule insertE)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3210
        apply(rule UnI2) defer apply(drule q1(3)[rule_format])using False unfolding xk uv by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3211
    qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3212
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3213
subsection {* Hence the main theorem about negligible sets. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3214
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3215
lemma finite_product_dependent: assumes "finite s" "\<And>x. x\<in>s\<Longrightarrow> finite (t x)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3216
  shows "finite {(i, j) |i j. i \<in> s \<and> j \<in> t i}" using assms
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3217
proof(induct) case (insert x s) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3218
  have *:"{(i, j) |i j. i \<in> insert x s \<and> j \<in> t i} = (\<lambda>y. (x,y)) ` (t x) \<union> {(i, j) |i j. i \<in> s \<and> j \<in> t i}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3219
  show ?case unfolding * apply(rule finite_UnI) using insert by auto qed auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3220
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3221
lemma sum_sum_product: assumes "finite s" "\<forall>i\<in>s. finite (t i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3222
  shows "setsum (\<lambda>i. setsum (x i) (t i)::real) s = setsum (\<lambda>(i,j). x i j) {(i,j) | i j. i \<in> s \<and> j \<in> t i}" using assms
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3223
proof(induct) case (insert a s)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3224
  have *:"{(i, j) |i j. i \<in> insert a s \<and> j \<in> t i} = (\<lambda>y. (a,y)) ` (t a) \<union> {(i, j) |i j. i \<in> s \<and> j \<in> t i}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3225
  show ?case unfolding * apply(subst setsum_Un_disjoint) unfolding setsum_insert[OF insert(1-2)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3226
    prefer 4 apply(subst insert(3)) unfolding add_right_cancel
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3227
  proof- show "setsum (x a) (t a) = (\<Sum>(xa, y)\<in>Pair a ` t a. x xa y)" apply(subst setsum_reindex) unfolding inj_on_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3228
    show "finite {(i, j) |i j. i \<in> s \<and> j \<in> t i}" apply(rule finite_product_dependent) using insert by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3229
  qed(insert insert, auto) qed auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3230
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3231
lemma has_integral_negligible: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3232
  assumes "negligible s" "\<forall>x\<in>(t - s). f x = 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3233
  shows "(f has_integral 0) t"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3234
proof- presume P:"\<And>f::'b::ordered_euclidean_space \<Rightarrow> 'a. \<And>a b. (\<forall>x. ~(x \<in> s) \<longrightarrow> f x = 0) \<Longrightarrow> (f has_integral 0) ({a..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3235
  let ?f = "(\<lambda>x. if x \<in> t then f x else 0)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3236
  show ?thesis apply(rule_tac f="?f" in has_integral_eq) apply(rule) unfolding if_P apply(rule refl)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3237
    apply(subst has_integral_alt) apply(cases,subst if_P,assumption) unfolding if_not_P
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3238
  proof- assume "\<exists>a b. t = {a..b}" then guess a b apply-by(erule exE)+ note t = this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3239
    show "(?f has_integral 0) t" unfolding t apply(rule P) using assms(2) unfolding t by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3240
  next show "\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow> (\<exists>z. ((\<lambda>x. if x \<in> t then ?f x else 0) has_integral z) {a..b} \<and> norm (z - 0) < e)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3241
      apply(safe,rule_tac x=1 in exI,rule) apply(rule zero_less_one,safe) apply(rule_tac x=0 in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3242
      apply(rule,rule P) using assms(2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3243
  qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3244
next fix f::"'b \<Rightarrow> 'a" and a b::"'b" assume assm:"\<forall>x. x \<notin> s \<longrightarrow> f x = 0" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3245
  show "(f has_integral 0) {a..b}" unfolding has_integral
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3246
  proof(safe) case goal1
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3247
    hence "\<And>n. e / 2 / ((real n+1) * (2 ^ n)) > 0" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3248
      apply-apply(rule divide_pos_pos) defer apply(rule mult_pos_pos) by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3249
    note assms(1)[unfolded negligible_def has_integral,rule_format,OF this,of a b] note allI[OF this,of "\<lambda>x. x"] 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3250
    from choice[OF this] guess d .. note d=conjunctD2[OF this[rule_format]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3251
    show ?case apply(rule_tac x="\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x" in exI) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3252
    proof safe show "gauge (\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x)" using d(1) unfolding gauge_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3253
      fix p assume as:"p tagged_division_of {a..b}" "(\<lambda>x. d (nat \<lfloor>norm (f x)\<rfloor>) x) fine p" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3254
      let ?goal = "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3255
      { presume "p\<noteq>{} \<Longrightarrow> ?goal" thus ?goal apply(cases "p={}") using goal1 by auto  }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3256
      assume as':"p \<noteq> {}" from real_arch_simple[of "Sup((\<lambda>(x,k). norm(f x)) ` p)"] guess N ..
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  3257
      hence N:"\<forall>x\<in>(\<lambda>(x, k). norm (f x)) ` p. x \<le> real N" apply(subst(asm) cSup_finite_le_iff) using as as' by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3258
      have "\<forall>i. \<exists>q. q tagged_division_of {a..b} \<and> (d i) fine q \<and> (\<forall>(x, k)\<in>p. k \<subseteq> (d i) x \<longrightarrow> (x, k) \<in> q)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3259
        apply(rule,rule tagged_division_finer[OF as(1) d(1)]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3260
      from choice[OF this] guess q .. note q=conjunctD3[OF this[rule_format]]
37665
579258a77fec Add theory for indicator function.
hoelzl
parents: 37489
diff changeset
  3261
      have *:"\<And>i. (\<Sum>(x, k)\<in>q i. content k *\<^sub>R indicator s x) \<ge> (0::real)" apply(rule setsum_nonneg,safe) 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3262
        unfolding real_scaleR_def apply(rule mult_nonneg_nonneg) apply(drule tagged_division_ofD(4)[OF q(1)]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3263
      have **:"\<And>f g s t. finite s \<Longrightarrow> finite t \<Longrightarrow> (\<forall>(x,y) \<in> t. (0::real) \<le> g(x,y)) \<Longrightarrow> (\<forall>y\<in>s. \<exists>x. (x,y) \<in> t \<and> f(y) \<le> g(x,y)) \<Longrightarrow> setsum f s \<le> setsum g t"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3264
      proof- case goal1 thus ?case apply-apply(rule setsum_le_included[of s t g snd f]) prefer 4
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3265
          apply safe apply(erule_tac x=x in ballE) apply(erule exE) apply(rule_tac x="(xa,x)" in bexI) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3266
      have "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - 0) \<le> setsum (\<lambda>i. (real i + 1) *
37665
579258a77fec Add theory for indicator function.
hoelzl
parents: 37489
diff changeset
  3267
                     norm(setsum (\<lambda>(x,k). content k *\<^sub>R indicator s x :: real) (q i))) {0..N+1}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3268
        unfolding real_norm_def setsum_right_distrib abs_of_nonneg[OF *] diff_0_right
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
  3269
        apply(rule order_trans,rule norm_setsum) apply(subst sum_sum_product) prefer 3 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3270
      proof(rule **,safe) show "finite {(i, j) |i j. i \<in> {0..N + 1} \<and> j \<in> q i}" apply(rule finite_product_dependent) using q by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3271
        fix i a b assume as'':"(a,b) \<in> q i" show "0 \<le> (real i + 1) * (content b *\<^sub>R indicator s a)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3272
          unfolding real_scaleR_def apply(rule mult_nonneg_nonneg) defer apply(rule mult_nonneg_nonneg)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3273
          using tagged_division_ofD(4)[OF q(1) as''] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3274
      next fix i::nat show "finite (q i)" using q by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3275
      next fix x k assume xk:"(x,k) \<in> p" def n \<equiv> "nat \<lfloor>norm (f x)\<rfloor>"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3276
        have *:"norm (f x) \<in> (\<lambda>(x, k). norm (f x)) ` p" using xk by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3277
        have nfx:"real n \<le> norm(f x)" "norm(f x) \<le> real n + 1" unfolding n_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3278
        hence "n \<in> {0..N + 1}" using N[rule_format,OF *] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3279
        moreover  note as(2)[unfolded fine_def,rule_format,OF xk,unfolded split_conv]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3280
        note q(3)[rule_format,OF xk,unfolded split_conv,rule_format,OF this] note this[unfolded n_def[symmetric]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3281
        moreover have "norm (content k *\<^sub>R f x) \<le> (real n + 1) * (content k * indicator s x)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3282
        proof(cases "x\<in>s") case False thus ?thesis using assm by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3283
        next case True have *:"content k \<ge> 0" using tagged_division_ofD(4)[OF as(1) xk] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3284
          moreover have "content k * norm (f x) \<le> content k * (real n + 1)" apply(rule mult_mono) using nfx * by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3285
          ultimately show ?thesis unfolding abs_mult using nfx True by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3286
        qed ultimately show "\<exists>y. (y, x, k) \<in> {(i, j) |i j. i \<in> {0..N + 1} \<and> j \<in> q i} \<and> norm (content k *\<^sub>R f x) \<le> (real y + 1) * (content k *\<^sub>R indicator s x)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3287
          apply(rule_tac x=n in exI,safe) apply(rule_tac x=n in exI,rule_tac x="(x,k)" in exI,safe) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3288
      qed(insert as, auto)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3289
      also have "... \<le> setsum (\<lambda>i. e / 2 / 2 ^ i) {0..N+1}" apply(rule setsum_mono) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3290
      proof- case goal1 thus ?case apply(subst mult_commute, subst pos_le_divide_eq[THEN sym])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3291
          using d(2)[rule_format,of "q i" i] using q[rule_format] by(auto simp add:field_simps)
36778
739a9379e29b avoid using real-specific versions of generic lemmas
huffman
parents: 36725
diff changeset
  3292
      qed also have "... < e * inverse 2 * 2" unfolding divide_inverse setsum_right_distrib[THEN sym]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3293
        apply(rule mult_strict_left_mono) unfolding power_inverse atLeastLessThanSuc_atLeastAtMost[THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3294
        apply(subst sumr_geometric) using goal1 by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3295
      finally show "?goal" by auto qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3296
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3297
lemma has_integral_spike: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::real_normed_vector"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3298
  assumes "negligible s" "(\<forall>x\<in>(t - s). g x = f x)" "(f has_integral y) t"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3299
  shows "(g has_integral y) t"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3300
proof- { fix a b::"'b" and f g ::"'b \<Rightarrow> 'a" and y::'a
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3301
    assume as:"\<forall>x \<in> {a..b} - s. g x = f x" "(f has_integral y) {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3302
    have "((\<lambda>x. f x + (g x - f x)) has_integral (y + 0)) {a..b}" apply(rule has_integral_add[OF as(2)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3303
      apply(rule has_integral_negligible[OF assms(1)]) using as by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3304
    hence "(g has_integral y) {a..b}" by auto } note * = this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3305
  show ?thesis apply(subst has_integral_alt) using assms(2-) apply-apply(rule cond_cases,safe)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3306
    apply(rule *, assumption+) apply(subst(asm) has_integral_alt) unfolding if_not_P
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3307
    apply(erule_tac x=e in allE,safe,rule_tac x=B in exI,safe) apply(erule_tac x=a in allE,erule_tac x=b in allE,safe)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3308
    apply(rule_tac x=z in exI,safe) apply(rule *[where fa2="\<lambda>x. if x\<in>t then f x else 0"]) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3309
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3310
lemma has_integral_spike_eq:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3311
  assumes "negligible s" "\<forall>x\<in>(t - s). g x = f x"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3312
  shows "((f has_integral y) t \<longleftrightarrow> (g has_integral y) t)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3313
  apply rule apply(rule_tac[!] has_integral_spike[OF assms(1)]) using assms(2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3314
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3315
lemma integrable_spike: assumes "negligible s" "\<forall>x\<in>(t - s). g x = f x" "f integrable_on t"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3316
  shows "g integrable_on  t"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3317
  using assms unfolding integrable_on_def apply-apply(erule exE)
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  3318
  apply(rule,rule has_integral_spike) by fastforce+
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3319
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3320
lemma integral_spike: assumes "negligible s" "\<forall>x\<in>(t - s). g x = f x"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3321
  shows "integral t f = integral t g"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3322
  unfolding integral_def using has_integral_spike_eq[OF assms] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3323
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3324
subsection {* Some other trivialities about negligible sets. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3325
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3326
lemma negligible_subset[intro]: assumes "negligible s" "t \<subseteq> s" shows "negligible t" unfolding negligible_def 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3327
proof(safe) case goal1 show ?case using assms(1)[unfolded negligible_def,rule_format,of a b]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3328
    apply-apply(rule has_integral_spike[OF assms(1)]) defer apply assumption
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3329
    using assms(2) unfolding indicator_def by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3330
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3331
lemma negligible_diff[intro?]: assumes "negligible s" shows "negligible(s - t)" using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3332
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3333
lemma negligible_inter: assumes "negligible s \<or> negligible t" shows "negligible(s \<inter> t)" using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3334
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3335
lemma negligible_union: assumes "negligible s" "negligible t" shows "negligible (s \<union> t)" unfolding negligible_def 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3336
proof safe case goal1 note assm = assms[unfolded negligible_def,rule_format,of a b]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3337
  thus ?case apply(subst has_integral_spike_eq[OF assms(2)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3338
    defer apply assumption unfolding indicator_def by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3339
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3340
lemma negligible_union_eq[simp]: "negligible (s \<union> t) \<longleftrightarrow> (negligible s \<and> negligible t)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3341
  using negligible_union by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3342
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3343
lemma negligible_sing[intro]: "negligible {a::_::ordered_euclidean_space}" 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3344
  using negligible_standard_hyperplane[OF SOME_Basis, of "a \<bullet> (SOME i. i \<in> Basis)"] by auto 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3345
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3346
lemma negligible_insert[simp]: "negligible(insert a s) \<longleftrightarrow> negligible s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3347
  apply(subst insert_is_Un) unfolding negligible_union_eq by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3348
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3349
lemma negligible_empty[intro]: "negligible {}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3350
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3351
lemma negligible_finite[intro]: assumes "finite s" shows "negligible s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3352
  using assms apply(induct s) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3353
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3354
lemma negligible_unions[intro]: assumes "finite s" "\<forall>t\<in>s. negligible t" shows "negligible(\<Union>s)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3355
  using assms by(induct,auto) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3356
37665
579258a77fec Add theory for indicator function.
hoelzl
parents: 37489
diff changeset
  3357
lemma negligible:  "negligible s \<longleftrightarrow> (\<forall>t::('a::ordered_euclidean_space) set. ((indicator s::'a\<Rightarrow>real) has_integral 0) t)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3358
  apply safe defer apply(subst negligible_def)
46905
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3359
proof -
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3360
  fix t::"'a set" assume as:"negligible s"
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3361
  have *:"(\<lambda>x. if x \<in> s \<inter> t then 1 else 0) = (\<lambda>x. if x\<in>t then if x\<in>s then 1 else 0 else 0)"
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3362
    by auto
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3363
  show "((indicator s::'a\<Rightarrow>real) has_integral 0) t"
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3364
    apply(subst has_integral_alt)
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3365
    apply(cases,subst if_P,assumption)
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3366
    unfolding if_not_P
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3367
    apply(safe,rule as[unfolded negligible_def,rule_format])
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3368
    apply(rule_tac x=1 in exI)
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3369
    apply(safe,rule zero_less_one)
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3370
    apply(rule_tac x=0 in exI)
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3371
    using negligible_subset[OF as,of "s \<inter> t"]
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3372
    unfolding negligible_def indicator_def [abs_def]
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3373
    unfolding *
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3374
    apply auto
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3375
    done
6b1c0a80a57a prefer abs_def over def_raw;
wenzelm
parents: 45994
diff changeset
  3376
qed auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3377
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3378
subsection {* Finite case of the spike theorem is quite commonly needed. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3379
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3380
lemma has_integral_spike_finite: assumes "finite s" "\<forall>x\<in>t-s. g x = f x" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3381
  "(f has_integral y) t" shows "(g has_integral y) t"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3382
  apply(rule has_integral_spike) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3383
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3384
lemma has_integral_spike_finite_eq: assumes "finite s" "\<forall>x\<in>t-s. g x = f x"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3385
  shows "((f has_integral y) t \<longleftrightarrow> (g has_integral y) t)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3386
  apply rule apply(rule_tac[!] has_integral_spike_finite) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3387
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3388
lemma integrable_spike_finite:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3389
  assumes "finite s" "\<forall>x\<in>t-s. g x = f x" "f integrable_on t" shows "g integrable_on  t"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3390
  using assms unfolding integrable_on_def apply safe apply(rule_tac x=y in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3391
  apply(rule has_integral_spike_finite) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3392
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3393
subsection {* In particular, the boundary of an interval is negligible. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3394
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3395
lemma negligible_frontier_interval: "negligible({a::'a::ordered_euclidean_space..b} - {a<..<b})"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3396
proof-
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3397
  let ?A = "\<Union>((\<lambda>k. {x. x\<bullet>k = a\<bullet>k} \<union> {x::'a. x\<bullet>k = b\<bullet>k}) ` Basis)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3398
  have "{a..b} - {a<..<b} \<subseteq> ?A"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3399
    apply rule unfolding Diff_iff mem_interval
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3400
    apply simp
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3401
    apply(erule conjE bexE)+
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3402
    apply(rule_tac x=i in bexI)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3403
    by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3404
  thus ?thesis
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3405
    apply-
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3406
    apply(rule negligible_subset[of ?A])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3407
    apply(rule negligible_unions[OF finite_imageI])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3408
    by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3409
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3410
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3411
lemma has_integral_spike_interior:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3412
  assumes "\<forall>x\<in>{a<..<b}. g x = f x" "(f has_integral y) ({a..b})" shows "(g has_integral y) ({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3413
  apply(rule has_integral_spike[OF negligible_frontier_interval _ assms(2)]) using assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3414
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3415
lemma has_integral_spike_interior_eq:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3416
  assumes "\<forall>x\<in>{a<..<b}. g x = f x" shows "((f has_integral y) ({a..b}) \<longleftrightarrow> (g has_integral y) ({a..b}))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3417
  apply rule apply(rule_tac[!] has_integral_spike_interior) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3418
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3419
lemma integrable_spike_interior: assumes "\<forall>x\<in>{a<..<b}. g x = f x" "f integrable_on {a..b}" shows "g integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3420
  using  assms unfolding integrable_on_def using has_integral_spike_interior[OF assms(1)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3421
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3422
subsection {* Integrability of continuous functions. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3423
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3424
lemma neutral_and[simp]: "neutral op \<and> = True"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3425
  unfolding neutral_def apply(rule some_equality) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3426
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3427
lemma monoidal_and[intro]: "monoidal op \<and>" unfolding monoidal_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3428
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3429
lemma iterate_and[simp]: assumes "finite s" shows "(iterate op \<and>) s p \<longleftrightarrow> (\<forall>x\<in>s. p x)" using assms
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3430
apply induct unfolding iterate_insert[OF monoidal_and] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3431
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3432
lemma operative_division_and: assumes "operative op \<and> P" "d division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3433
  shows "(\<forall>i\<in>d. P i) \<longleftrightarrow> P {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3434
  using operative_division[OF monoidal_and assms] division_of_finite[OF assms(2)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3435
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3436
lemma operative_approximable: assumes "0 \<le> e" fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3437
  shows "operative op \<and> (\<lambda>i. \<exists>g. (\<forall>x\<in>i. norm (f x - g (x::'b)) \<le> e) \<and> g integrable_on i)" unfolding operative_def neutral_and
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3438
proof safe
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3439
  fix a b::"'b"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3440
  { assume "content {a..b} = 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3441
    thus "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3442
      apply(rule_tac x=f in exI) using assms by(auto intro!:integrable_on_null) }
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3443
  { fix c g and k :: 'b
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3444
    assume as:"\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e" "g integrable_on {a..b}" and k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3445
    show "\<exists>g. (\<forall>x\<in>{a..b} \<inter> {x. x \<bullet> k \<le> c}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3446
      "\<exists>g. (\<forall>x\<in>{a..b} \<inter> {x. c \<le> x \<bullet> k}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3447
      apply(rule_tac[!] x=g in exI) using as(1) integrable_split[OF as(2) k] by auto }
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3448
  fix c k g1 g2 assume as:"\<forall>x\<in>{a..b} \<inter> {x. x \<bullet> k \<le> c}. norm (f x - g1 x) \<le> e" "g1 integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3449
                          "\<forall>x\<in>{a..b} \<inter> {x. c \<le> x \<bullet> k}. norm (f x - g2 x) \<le> e" "g2 integrable_on {a..b} \<inter> {x. c \<le> x \<bullet> k}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3450
  assume k:"k\<in>Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3451
  let ?g = "\<lambda>x. if x\<bullet>k = c then f x else if x\<bullet>k \<le> c then g1 x else g2 x"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3452
  show "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}" apply(rule_tac x="?g" in exI)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3453
  proof safe case goal1 thus ?case apply- apply(cases "x\<bullet>k=c", case_tac "x\<bullet>k < c") using as assms by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3454
  next case goal2 presume "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}" "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<ge> c}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3455
    then guess h1 h2 unfolding integrable_on_def by auto from has_integral_split[OF this k] 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3456
    show ?case unfolding integrable_on_def by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3457
  next show "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<le> c}" "?g integrable_on {a..b} \<inter> {x. x \<bullet> k \<ge> c}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3458
      apply(rule_tac[!] integrable_spike[OF negligible_standard_hyperplane[of k c]]) using k as(2,4) by auto qed qed
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3459
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3460
lemma approximable_on_division: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3461
  assumes "0 \<le> e" "d division_of {a..b}" "\<forall>i\<in>d. \<exists>g. (\<forall>x\<in>i. norm (f x - g x) \<le> e) \<and> g integrable_on i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3462
  obtains g where "\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e" "g integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3463
proof- note * = operative_division[OF monoidal_and operative_approximable[OF assms(1)] assms(2)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3464
  note this[unfolded iterate_and[OF division_of_finite[OF assms(2)]]] from assms(3)[unfolded this[of f]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3465
  guess g .. thus thesis apply-apply(rule that[of g]) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3466
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3467
lemma integrable_continuous: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3468
  assumes "continuous_on {a..b} f" shows "f integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3469
proof(rule integrable_uniform_limit,safe) fix e::real assume e:"0 < e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3470
  from compact_uniformly_continuous[OF assms compact_interval,unfolded uniformly_continuous_on_def,rule_format,OF e] guess d ..
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3471
  note d=conjunctD2[OF this,rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3472
  from fine_division_exists[OF gauge_ball[OF d(1)], of a b] guess p . note p=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3473
  note p' = tagged_division_ofD[OF p(1)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3474
  have *:"\<forall>i\<in>snd ` p. \<exists>g. (\<forall>x\<in>i. norm (f x - g x) \<le> e) \<and> g integrable_on i"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3475
  proof(safe,unfold snd_conv) fix x l assume as:"(x,l) \<in> p" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3476
    from p'(4)[OF this] guess a b apply-by(erule exE)+ note l=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3477
    show "\<exists>g. (\<forall>x\<in>l. norm (f x - g x) \<le> e) \<and> g integrable_on l" apply(rule_tac x="\<lambda>y. f x" in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3478
    proof safe show "(\<lambda>y. f x) integrable_on l" unfolding integrable_on_def l by(rule,rule has_integral_const)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3479
      fix y assume y:"y\<in>l" note fineD[OF p(2) as,unfolded subset_eq,rule_format,OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3480
      note d(2)[OF _ _ this[unfolded mem_ball]]
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  3481
      thus "norm (f y - f x) \<le> e" using y p'(2-3)[OF as] unfolding dist_norm l norm_minus_commute by fastforce qed qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3482
  from e have "0 \<le> e" by auto from approximable_on_division[OF this division_of_tagged_division[OF p(1)] *] guess g .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3483
  thus "\<exists>g. (\<forall>x\<in>{a..b}. norm (f x - g x) \<le> e) \<and> g integrable_on {a..b}" by auto qed 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3484
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3485
subsection {* Specialization of additivity to one dimension. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3486
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3487
lemma 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3488
  shows real_inner_1_left: "inner 1 x = x"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3489
  and real_inner_1_right: "inner x 1 = x"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3490
  by simp_all
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3491
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3492
lemma operative_1_lt: assumes "monoidal opp"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3493
  shows "operative opp f \<longleftrightarrow> ((\<forall>a b. b \<le> a \<longrightarrow> f {a..b::real} = neutral opp) \<and>
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3494
                (\<forall>a b c. a < c \<and> c < b \<longrightarrow> opp (f{a..c})(f{c..b}) = f {a..b}))"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3495
  apply (simp add: operative_def content_eq_0 less_one)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3496
proof safe fix a b c::"real" assume as:"\<forall>a b c. f {a..b} = opp (f ({a..b} \<inter> {x. x \<le> c}))
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3497
    (f ({a..b} \<inter> {x. c \<le> x}))" "a < c" "c < b"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3498
    from this(2-) have "{a..b} \<inter> {x. x \<le> c} = {a..c}" "{a..b} \<inter> {x. x \<ge> c} = {c..b}" by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3499
    thus "opp (f {a..c}) (f {c..b}) = f {a..b}" unfolding as(1)[rule_format,of a b "c"] by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3500
next fix a b c::real
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3501
  assume as:"\<forall>a b. b \<le> a \<longrightarrow> f {a..b} = neutral opp" "\<forall>a b c. a < c \<and> c < b \<longrightarrow> opp (f {a..c}) (f {c..b}) = f {a..b}"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3502
  show "f {a..b} = opp (f ({a..b} \<inter> {x. x \<le> c})) (f ({a..b} \<inter> {x. c \<le> x}))"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3503
  proof(cases "c \<in> {a .. b}")
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3504
    case False hence "c<a \<or> c>b" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3505
    thus ?thesis apply-apply(erule disjE)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3506
    proof- assume "c<a" hence *:"{a..b} \<inter> {x. x \<le> c} = {1..0}"  "{a..b} \<inter> {x. c \<le> x} = {a..b}" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3507
      show ?thesis unfolding * apply(subst as(1)[rule_format,of 0 1]) using assms by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3508
    next   assume "b<c" hence *:"{a..b} \<inter> {x. x \<le> c} = {a..b}"  "{a..b} \<inter> {x. c \<le> x} = {1..0}" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3509
      show ?thesis unfolding * apply(subst as(1)[rule_format,of 0 1]) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3510
    qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3511
  next case True hence *:"min (b) c = c" "max a c = c" by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3512
    have **: "(1::real) \<in> Basis" by simp
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3513
    have ***:"\<And>P Q. (\<Sum>i\<in>Basis. (if i = 1 then P i else Q i) *\<^sub>R i) = (P 1::real)" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3514
      by simp
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3515
    show ?thesis 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3516
      unfolding interval_split[OF **, unfolded real_inner_1_right] unfolding *** *
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3517
    proof(cases "c = a \<or> c = b")
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3518
      case False thus "f {a..b} = opp (f {a..c}) (f {c..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3519
        apply-apply(subst as(2)[rule_format]) using True by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3520
    next case True thus "f {a..b} = opp (f {a..c}) (f {c..b})" apply-
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3521
      proof(erule disjE) assume *:"c=a"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3522
        hence "f {a..c} = neutral opp" apply-apply(rule as(1)[rule_format]) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3523
        thus ?thesis using assms unfolding * by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3524
      next assume *:"c=b" hence "f {c..b} = neutral opp" apply-apply(rule as(1)[rule_format]) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3525
        thus ?thesis using assms unfolding * by auto qed qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3526
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3527
lemma operative_1_le: assumes "monoidal opp"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3528
  shows "operative opp f \<longleftrightarrow> ((\<forall>a b. b \<le> a \<longrightarrow> f {a..b::real} = neutral opp) \<and>
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3529
                (\<forall>a b c. a \<le> c \<and> c \<le> b \<longrightarrow> opp (f{a..c})(f{c..b}) = f {a..b}))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3530
unfolding operative_1_lt[OF assms]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3531
proof safe fix a b c::"real" assume as:"\<forall>a b c. a \<le> c \<and> c \<le> b \<longrightarrow> opp (f {a..c}) (f {c..b}) = f {a..b}" "a < c" "c < b"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3532
  show "opp (f {a..c}) (f {c..b}) = f {a..b}" apply(rule as(1)[rule_format]) using as(2-) by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3533
next fix a b c ::"real" assume "\<forall>a b. b \<le> a \<longrightarrow> f {a..b} = neutral opp"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3534
    "\<forall>a b c. a < c \<and> c < b \<longrightarrow> opp (f {a..c}) (f {c..b}) = f {a..b}" "a \<le> c" "c \<le> b"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3535
  note as = this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3536
  show "opp (f {a..c}) (f {c..b}) = f {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3537
  proof(cases "c = a \<or> c = b")
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3538
    case False thus ?thesis apply-apply(subst as(2)) using as(3-) by(auto)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3539
    next case True thus ?thesis apply-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3540
      proof(erule disjE) assume *:"c=a" hence "f {a..c} = neutral opp" apply-apply(rule as(1)[rule_format]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3541
        thus ?thesis using assms unfolding * by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3542
      next               assume *:"c=b" hence "f {c..b} = neutral opp" apply-apply(rule as(1)[rule_format]) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3543
        thus ?thesis using assms unfolding * by auto qed qed qed 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3544
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3545
subsection {* Special case of additivity we need for the FCT. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3546
35540
3d073a3e1c61 the ordering on real^1 is linear
himmelma
parents: 35292
diff changeset
  3547
lemma interval_bound_sing[simp]: "interval_upperbound {a} = a"  "interval_lowerbound {a} = a"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3548
  unfolding interval_upperbound_def interval_lowerbound_def by (auto simp: euclidean_representation)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3549
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3550
lemma additive_tagged_division_1: fixes f::"real \<Rightarrow> 'a::real_normed_vector"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3551
  assumes "a \<le> b" "p tagged_division_of {a..b}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3552
  shows "setsum (\<lambda>(x,k). f(interval_upperbound k) - f(interval_lowerbound k)) p = f b - f a"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3553
proof- let ?f = "(\<lambda>k::(real) set. if k = {} then 0 else f(interval_upperbound k) - f(interval_lowerbound k))"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3554
  have ***:"\<forall>i\<in>Basis. a \<bullet> i \<le> b \<bullet> i" using assms by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3555
  have *:"operative op + ?f" unfolding operative_1_lt[OF monoidal_monoid] interval_eq_empty by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3556
  have **:"{a..b} \<noteq> {}" using assms(1) by auto note operative_tagged_division[OF monoidal_monoid * assms(2)]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3557
  note * = this[unfolded if_not_P[OF **] interval_bounds[OF ***],THEN sym]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3558
  show ?thesis unfolding * apply(subst setsum_iterate[THEN sym]) defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3559
    apply(rule setsum_cong2) unfolding split_paired_all split_conv using assms(2) by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3560
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3561
subsection {* A useful lemma allowing us to factor out the content size. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3562
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3563
lemma has_integral_factor_content:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3564
  "(f has_integral i) {a..b} \<longleftrightarrow> (\<forall>e>0. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3565
    \<longrightarrow> norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - i) \<le> e * content {a..b}))"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3566
proof(cases "content {a..b} = 0")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3567
  case True show ?thesis unfolding has_integral_null_eq[OF True] apply safe
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3568
    apply(rule,rule,rule gauge_trivial,safe) unfolding setsum_content_null[OF True] True defer 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3569
    apply(erule_tac x=1 in allE,safe) defer apply(rule fine_division_exists[of _ a b],assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3570
    apply(erule_tac x=p in allE) unfolding setsum_content_null[OF True] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3571
next case False note F = this[unfolded content_lt_nz[THEN sym]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3572
  let ?P = "\<lambda>e opp. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> opp (norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - i)) e)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3573
  show ?thesis apply(subst has_integral)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3574
  proof safe fix e::real assume e:"e>0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3575
    { assume "\<forall>e>0. ?P e op <" thus "?P (e * content {a..b}) op \<le>" apply(erule_tac x="e * content {a..b}" in allE)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3576
        apply(erule impE) defer apply(erule exE,rule_tac x=d in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3577
        using F e by(auto simp add:field_simps intro:mult_pos_pos) }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3578
    {  assume "\<forall>e>0. ?P (e * content {a..b}) op \<le>" thus "?P e op <" apply(erule_tac x="e / 2 / content {a..b}" in allE)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3579
        apply(erule impE) defer apply(erule exE,rule_tac x=d in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3580
        using F e by(auto simp add:field_simps intro:mult_pos_pos) } qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3581
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3582
subsection {* Fundamental theorem of calculus. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3583
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3584
lemma interval_bounds_real: assumes "a\<le>(b::real)"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3585
  shows "interval_upperbound {a..b} = b" "interval_lowerbound {a..b} = a"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3586
  apply(rule_tac[!] interval_bounds) using assms by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3587
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3588
lemma fundamental_theorem_of_calculus: fixes f::"real \<Rightarrow> 'a::banach"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3589
  assumes "a \<le> b"  "\<forall>x\<in>{a..b}. (f has_vector_derivative f' x) (at x within {a..b})"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3590
  shows "(f' has_integral (f b - f a)) ({a..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3591
unfolding has_integral_factor_content
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3592
proof safe fix e::real assume e:"e>0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3593
  note assm = assms(2)[unfolded has_vector_derivative_def has_derivative_within_alt]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3594
  have *:"\<And>P Q. \<forall>x\<in>{a..b}. P x \<and> (\<forall>e>0. \<exists>d>0. Q x e d) \<Longrightarrow> \<forall>x. \<exists>(d::real)>0. x\<in>{a..b} \<longrightarrow> Q x e d" using e by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3595
  note this[OF assm,unfolded gauge_existence_lemma] from choice[OF this,unfolded Ball_def[symmetric]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3596
  guess d .. note d=conjunctD2[OF this[rule_format],rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3597
  show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3598
                 norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b})"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3599
    apply(rule_tac x="\<lambda>x. ball x (d x)" in exI,safe)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3600
    apply(rule gauge_ball_dependent,rule,rule d(1))
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3601
  proof- fix p assume as:"p tagged_division_of {a..b}" "(\<lambda>x. ball x (d x)) fine p"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3602
    show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b}" 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3603
      unfolding content_real[OF assms(1)] additive_tagged_division_1[OF assms(1) as(1),of f,THEN sym]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3604
      unfolding additive_tagged_division_1[OF assms(1) as(1),of "\<lambda>x. x",THEN sym]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3605
      unfolding setsum_right_distrib defer unfolding setsum_subtractf[THEN sym] 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3606
    proof(rule setsum_norm_le,safe) fix x k assume "(x,k)\<in>p"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3607
      note xk = tagged_division_ofD(2-4)[OF as(1) this] from this(3) guess u v apply-by(erule exE)+ note k=this
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3608
      have *:"u \<le> v" using xk unfolding k by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3609
      have ball:"\<forall>xa\<in>k. xa \<in> ball x (d x)" using as(2)[unfolded fine_def,rule_format,OF `(x,k)\<in>p`,
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3610
        unfolded split_conv subset_eq] .
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3611
      have "norm ((v - u) *\<^sub>R f' x - (f v - f u)) \<le>
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3612
        norm (f u - f x - (u - x) *\<^sub>R f' x) + norm (f v - f x - (v - x) *\<^sub>R f' x)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3613
        apply(rule order_trans[OF _ norm_triangle_ineq4]) apply(rule eq_refl) apply(rule arg_cong[where f=norm])
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  3614
        unfolding scaleR_diff_left by(auto simp add:algebra_simps)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3615
      also have "... \<le> e * norm (u - x) + e * norm (v - x)"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3616
        apply(rule add_mono) apply(rule d(2)[of "x" "u",unfolded o_def]) prefer 4
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3617
        apply(rule d(2)[of "x" "v",unfolded o_def])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3618
        using ball[rule_format,of u] ball[rule_format,of v] 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3619
        using xk(1-2) unfolding k subset_eq by(auto simp add:dist_real_def) 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3620
      also have "... \<le> e * (interval_upperbound k - interval_lowerbound k)"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3621
        unfolding k interval_bounds_real[OF *] using xk(1) unfolding k by(auto simp add:dist_real_def field_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3622
      finally show "norm (content k *\<^sub>R f' x - (f (interval_upperbound k) - f (interval_lowerbound k))) \<le>
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3623
        e * (interval_upperbound k - interval_lowerbound k)" unfolding k interval_bounds_real[OF *] content_real[OF *] .
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
  3624
    qed qed qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3625
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3626
subsection {* Attempt a systematic general set of "offset" results for components. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3627
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3628
lemma gauge_modify:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3629
  assumes "(\<forall>s. open s \<longrightarrow> open {x. f(x) \<in> s})" "gauge d"
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44167
diff changeset
  3630
  shows "gauge (\<lambda>x. {y. f y \<in> d (f x)})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3631
  using assms unfolding gauge_def apply safe defer apply(erule_tac x="f x" in allE)
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44167
diff changeset
  3632
  apply(erule_tac x="d (f x)" in allE) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3633
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3634
subsection {* Only need trivial subintervals if the interval itself is trivial. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3635
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3636
lemma division_of_nontrivial: fixes s::"('a::ordered_euclidean_space) set set"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3637
  assumes "s division_of {a..b}" "content({a..b}) \<noteq> 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3638
  shows "{k. k \<in> s \<and> content k \<noteq> 0} division_of {a..b}" using assms(1) apply-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3639
proof(induct "card s" arbitrary:s rule:nat_less_induct)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3640
  fix s::"'a set set" assume assm:"s division_of {a..b}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3641
    "\<forall>m<card s. \<forall>x. m = card x \<longrightarrow> x division_of {a..b} \<longrightarrow> {k \<in> x. content k \<noteq> 0} division_of {a..b}" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3642
  note s = division_ofD[OF assm(1)] let ?thesis = "{k \<in> s. content k \<noteq> 0} division_of {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3643
  { presume *:"{k \<in> s. content k \<noteq> 0} \<noteq> s \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3644
    show ?thesis apply cases defer apply(rule *,assumption) using assm(1) by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3645
  assume noteq:"{k \<in> s. content k \<noteq> 0} \<noteq> s"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3646
  then obtain k where k:"k\<in>s" "content k = 0" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3647
  from s(4)[OF k(1)] guess c d apply-by(erule exE)+ note k=k this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3648
  from k have "card s > 0" unfolding card_gt_0_iff using assm(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3649
  hence card:"card (s - {k}) < card s" using assm(1) k(1) apply(subst card_Diff_singleton_if) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3650
  have *:"closed (\<Union>(s - {k}))" apply(rule closed_Union) defer apply rule apply(drule DiffD1,drule s(4))
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3651
    apply safe apply(rule closed_interval) using assm(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3652
  have "k \<subseteq> \<Union>(s - {k})" apply safe apply(rule *[unfolded closed_limpt,rule_format]) unfolding islimpt_approachable
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3653
  proof safe fix x and e::real assume as:"x\<in>k" "e>0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3654
    from k(2)[unfolded k content_eq_0] guess i .. 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3655
    hence i:"c\<bullet>i = d\<bullet>i" "i\<in>Basis" using s(3)[OF k(1),unfolded k] unfolding interval_ne_empty by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3656
    hence xi:"x\<bullet>i = d\<bullet>i" using as unfolding k mem_interval by (metis antisym)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3657
    def y \<equiv> "(\<Sum>j\<in>Basis. (if j = i then if c\<bullet>i \<le> (a\<bullet>i + b\<bullet>i) / 2 then c\<bullet>i +
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3658
      min e (b\<bullet>i - c\<bullet>i) / 2 else c\<bullet>i - min e (c\<bullet>i - a\<bullet>i) / 2 else x\<bullet>j) *\<^sub>R j)::'a"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3659
    show "\<exists>x'\<in>\<Union>(s - {k}). x' \<noteq> x \<and> dist x' x < e" apply(rule_tac x=y in bexI) 
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  3660
    proof have "d \<in> {c..d}" using s(3)[OF k(1)] unfolding k interval_eq_empty mem_interval by(fastforce simp add: not_less)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3661
      hence "d \<in> {a..b}" using s(2)[OF k(1)] unfolding k by auto note di = this[unfolded mem_interval,THEN bspec[where x=i]]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3662
      hence xyi:"y\<bullet>i \<noteq> x\<bullet>i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3663
        unfolding y_def i xi using as(2) assms(2)[unfolded content_eq_0] i(2)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3664
        by (auto elim!: ballE[of _ _ i])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3665
      thus "y \<noteq> x" unfolding euclidean_eq_iff[where 'a='a] using i by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3666
      have *:"Basis = insert i (Basis - {i})" using i by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3667
      have "norm (y - x) < e + setsum (\<lambda>i. 0) Basis" apply(rule le_less_trans[OF norm_le_l1])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3668
        apply(subst *,subst setsum_insert) prefer 3 apply(rule add_less_le_mono)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3669
      proof-
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3670
        show "\<bar>(y - x) \<bullet> i\<bar> < e"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3671
          using di as(2) y_def i xi by (auto simp: inner_simps)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3672
        show "(\<Sum>i\<in>Basis - {i}. \<bar>(y - x) \<bullet> i\<bar>) \<le> (\<Sum>i\<in>Basis. 0)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3673
          unfolding y_def by (auto simp: inner_simps)
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  3674
      qed auto thus "dist y x < e" unfolding dist_norm by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3675
      have "y\<notin>k" unfolding k mem_interval apply rule apply(erule_tac x=i in ballE) using xyi k i xi by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3676
      moreover have "y \<in> \<Union>s"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3677
        using set_rev_mp[OF as(1) s(2)[OF k(1)]] as(2) di i unfolding s mem_interval y_def
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3678
        by (auto simp: field_simps elim!: ballE[of _ _ i])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3679
      ultimately show "y \<in> \<Union>(s - {k})" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3680
    qed qed hence "\<Union>(s - {k}) = {a..b}" unfolding s(6)[THEN sym] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3681
  hence  "{ka \<in> s - {k}. content ka \<noteq> 0} division_of {a..b}" apply-apply(rule assm(2)[rule_format,OF card refl])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3682
    apply(rule division_ofI) defer apply(rule_tac[1-4] s) using assm(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3683
  moreover have "{ka \<in> s - {k}. content ka \<noteq> 0} = {k \<in> s. content k \<noteq> 0}" using k by auto ultimately show ?thesis by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3684
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  3685
subsection {* Integrability on subintervals. *}
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3686
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3687
lemma operative_integrable: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3688
  "operative op \<and> (\<lambda>i. f integrable_on i)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3689
  unfolding operative_def neutral_and apply safe apply(subst integrable_on_def)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3690
  unfolding has_integral_null_eq apply(rule,rule refl) apply(rule,assumption,assumption)+
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3691
  unfolding integrable_on_def by(auto intro!: has_integral_split)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3692
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3693
lemma integrable_subinterval: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3694
  assumes "f integrable_on {a..b}" "{c..d} \<subseteq> {a..b}" shows "f integrable_on {c..d}" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3695
  apply(cases "{c..d} = {}") defer apply(rule partial_division_extend_1[OF assms(2)],assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3696
  using operative_division_and[OF operative_integrable,THEN sym,of _ _ _ f] assms(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3697
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3698
subsection {* Combining adjacent intervals in 1 dimension. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3699
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3700
lemma has_integral_combine: assumes "(a::real) \<le> c" "c \<le> b"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3701
  "(f has_integral i) {a..c}" "(f has_integral (j::'a::banach)) {c..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3702
  shows "(f has_integral (i + j)) {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3703
proof- note operative_integral[of f, unfolded operative_1_le[OF monoidal_lifted[OF monoidal_monoid]]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3704
  note conjunctD2[OF this,rule_format] note * = this(2)[OF conjI[OF assms(1-2)],unfolded if_P[OF assms(3)]]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3705
  hence "f integrable_on {a..b}" apply- apply(rule ccontr) apply(subst(asm) if_P) defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3706
    apply(subst(asm) if_P) using assms(3-) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3707
  with * show ?thesis apply-apply(subst(asm) if_P) defer apply(subst(asm) if_P) defer apply(subst(asm) if_P)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3708
    unfolding lifted.simps using assms(3-) by(auto simp add: integrable_on_def integral_unique) qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3709
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3710
lemma integral_combine: fixes f::"real \<Rightarrow> 'a::banach"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3711
  assumes "a \<le> c" "c \<le> b" "f integrable_on ({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3712
  shows "integral {a..c} f + integral {c..b} f = integral({a..b}) f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3713
  apply(rule integral_unique[THEN sym]) apply(rule has_integral_combine[OF assms(1-2)])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3714
  apply(rule_tac[!] integrable_integral integrable_subinterval[OF assms(3)])+ using assms(1-2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3715
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3716
lemma integrable_combine: fixes f::"real \<Rightarrow> 'a::banach"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3717
  assumes "a \<le> c" "c \<le> b" "f integrable_on {a..c}" "f integrable_on {c..b}"
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  3718
  shows "f integrable_on {a..b}" using assms unfolding integrable_on_def by(fastforce intro!:has_integral_combine)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3719
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3720
subsection {* Reduce integrability to "local" integrability. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3721
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3722
lemma integrable_on_little_subintervals: fixes f::"'b::ordered_euclidean_space \<Rightarrow> 'a::banach"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3723
  assumes "\<forall>x\<in>{a..b}. \<exists>d>0. \<forall>u v. x \<in> {u..v} \<and> {u..v} \<subseteq> ball x d \<and> {u..v} \<subseteq> {a..b} \<longrightarrow> f integrable_on {u..v}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3724
  shows "f integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3725
proof- have "\<forall>x. \<exists>d. x\<in>{a..b} \<longrightarrow> d>0 \<and> (\<forall>u v. x \<in> {u..v} \<and> {u..v} \<subseteq> ball x d \<and> {u..v} \<subseteq> {a..b} \<longrightarrow> f integrable_on {u..v})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3726
    using assms by auto note this[unfolded gauge_existence_lemma] from choice[OF this] guess d .. note d=this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3727
  guess p apply(rule fine_division_exists[OF gauge_ball_dependent,of d a b]) using d by auto note p=this(1-2)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3728
  note division_of_tagged_division[OF this(1)] note * = operative_division_and[OF operative_integrable,OF this,THEN sym,of f]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3729
  show ?thesis unfolding * apply safe unfolding snd_conv
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3730
  proof- fix x k assume "(x,k) \<in> p" note tagged_division_ofD(2-4)[OF p(1) this] fineD[OF p(2) this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3731
    thus "f integrable_on k" apply safe apply(rule d[THEN conjunct2,rule_format,of x]) by auto qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3732
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3733
subsection {* Second FCT or existence of antiderivative. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3734
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3735
lemma integrable_const[intro]:"(\<lambda>x. c) integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3736
  unfolding integrable_on_def by(rule,rule has_integral_const)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3737
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3738
lemma integral_has_vector_derivative: fixes f::"real \<Rightarrow> 'a::banach"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3739
  assumes "continuous_on {a..b} f" "x \<in> {a..b}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3740
  shows "((\<lambda>u. integral {a..u} f) has_vector_derivative f(x)) (at x within {a..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3741
  unfolding has_vector_derivative_def has_derivative_within_alt
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  3742
apply safe apply(rule bounded_linear_scaleR_left)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3743
proof- fix e::real assume e:"e>0"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3744
  note compact_uniformly_continuous[OF assms(1) compact_interval,unfolded uniformly_continuous_on_def]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3745
  from this[rule_format,OF e] guess d apply-by(erule conjE exE)+ note d=this[rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3746
  let ?I = "\<lambda>a b. integral {a..b} f"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3747
  show "\<exists>d>0. \<forall>y\<in>{a..b}. norm (y - x) < d \<longrightarrow> norm (?I a y - ?I a x - (y - x) *\<^sub>R f x) \<le> e * norm (y - x)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3748
  proof(rule,rule,rule d,safe) case goal1 show ?case proof(cases "y < x")
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3749
      case False have "f integrable_on {a..y}" apply(rule integrable_subinterval,rule integrable_continuous)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3750
        apply(rule assms)  unfolding not_less using assms(2) goal1 by auto
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  3751
      hence *:"?I a y - ?I a x = ?I x y" unfolding algebra_simps apply(subst eq_commute) apply(rule integral_combine)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3752
        using False unfolding not_less using assms(2) goal1 by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3753
      have **:"norm (y - x) = content {x..y}" apply(subst content_real) using False unfolding not_less by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3754
      show ?thesis unfolding ** apply(rule has_integral_bound[where f="(\<lambda>u. f u - f x)"]) unfolding * unfolding o_def
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3755
        defer apply(rule has_integral_sub) apply(rule integrable_integral)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3756
        apply(rule integrable_subinterval,rule integrable_continuous) apply(rule assms)+
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3757
      proof- show "{x..y} \<subseteq> {a..b}" using goal1 assms(2) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3758
        have *:"y - x = norm(y - x)" using False by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3759
        show "((\<lambda>xa. f x) has_integral (y - x) *\<^sub>R f x) {x.. y}" apply(subst *) unfolding ** by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3760
        show "\<forall>xa\<in>{x..y}. norm (f xa - f x) \<le> e" apply safe apply(rule less_imp_le)
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  3761
          apply(rule d(2)[unfolded dist_norm]) using assms(2) using goal1 by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3762
      qed(insert e,auto)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3763
    next case True have "f integrable_on {a..x}" apply(rule integrable_subinterval,rule integrable_continuous)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3764
        apply(rule assms)+  unfolding not_less using assms(2) goal1 by auto
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  3765
      hence *:"?I a x - ?I a y = ?I y x" unfolding algebra_simps apply(subst eq_commute) apply(rule integral_combine)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3766
        using True using assms(2) goal1 by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3767
      have **:"norm (y - x) = content {y..x}" apply(subst content_real) using True unfolding not_less by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3768
      have ***:"\<And>fy fx c::'a. fx - fy - (y - x) *\<^sub>R c = -(fy - fx - (x - y) *\<^sub>R c)" unfolding scaleR_left.diff by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3769
      show ?thesis apply(subst ***) unfolding norm_minus_cancel **
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3770
        apply(rule has_integral_bound[where f="(\<lambda>u. f u - f x)"]) unfolding * unfolding o_def
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3771
        defer apply(rule has_integral_sub) apply(subst minus_minus[THEN sym]) unfolding minus_minus
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3772
        apply(rule integrable_integral) apply(rule integrable_subinterval,rule integrable_continuous) apply(rule assms)+
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3773
      proof- show "{y..x} \<subseteq> {a..b}" using goal1 assms(2) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3774
        have *:"x - y = norm(y - x)" using True by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3775
        show "((\<lambda>xa. f x) has_integral (x - y) *\<^sub>R f x) {y..x}" apply(subst *) unfolding ** by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3776
        show "\<forall>xa\<in>{y..x}. norm (f xa - f x) \<le> e" apply safe apply(rule less_imp_le)
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  3777
          apply(rule d(2)[unfolded dist_norm]) using assms(2) using goal1 by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3778
      qed(insert e,auto) qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3779
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3780
lemma antiderivative_continuous: assumes "continuous_on {a..b::real} f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3781
  obtains g where "\<forall>x\<in> {a..b}. (g has_vector_derivative (f(x)::_::banach)) (at x within {a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3782
  apply(rule that,rule) using integral_has_vector_derivative[OF assms] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3783
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3784
subsection {* Combined fundamental theorem of calculus. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3785
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3786
lemma antiderivative_integral_continuous: fixes f::"real \<Rightarrow> 'a::banach" assumes "continuous_on {a..b} f"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3787
  obtains g where "\<forall>u\<in>{a..b}. \<forall>v \<in> {a..b}. u \<le> v \<longrightarrow> (f has_integral (g v - g u)) {u..v}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3788
proof- from antiderivative_continuous[OF assms] guess g . note g=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3789
  show ?thesis apply(rule that[of g])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3790
  proof safe case goal1 have "\<forall>x\<in>{u..v}. (g has_vector_derivative f x) (at x within {u..v})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3791
      apply(rule,rule has_vector_derivative_within_subset) apply(rule g[rule_format]) using goal1(1-2) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3792
    thus ?case using fundamental_theorem_of_calculus[OF goal1(3),of "g" "f"] by auto qed qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3793
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3794
subsection {* General "twiddling" for interval-to-interval function image. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3795
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3796
lemma has_integral_twiddle:
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3797
  assumes "0 < r" "\<forall>x. h(g x) = x" "\<forall>x. g(h x) = x" "\<forall>x. continuous (at x) g"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3798
  "\<forall>u v. \<exists>w z. g ` {u..v} = {w..z}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3799
  "\<forall>u v. \<exists>w z. h ` {u..v} = {w..z}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3800
  "\<forall>u v. content(g ` {u..v}) = r * content {u..v}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3801
  "(f has_integral i) {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3802
  shows "((\<lambda>x. f(g x)) has_integral (1 / r) *\<^sub>R i) (h ` {a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3803
proof- { presume *:"{a..b} \<noteq> {} \<Longrightarrow> ?thesis"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3804
    show ?thesis apply cases defer apply(rule *,assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3805
    proof- case goal1 thus ?thesis unfolding goal1 assms(8)[unfolded goal1 has_integral_empty_eq] by auto qed }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3806
  assume "{a..b} \<noteq> {}" from assms(6)[rule_format,of a b] guess w z apply-by(erule exE)+ note wz=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3807
  have inj:"inj g" "inj h" unfolding inj_on_def apply safe apply(rule_tac[!] ccontr)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3808
    using assms(2) apply(erule_tac x=x in allE) using assms(2) apply(erule_tac x=y in allE) defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3809
    using assms(3) apply(erule_tac x=x in allE) using assms(3) apply(erule_tac x=y in allE) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3810
  show ?thesis unfolding has_integral_def has_integral_compact_interval_def apply(subst if_P) apply(rule,rule,rule wz)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3811
  proof safe fix e::real assume e:"e>0" hence "e * r > 0" using assms(1) by(rule mult_pos_pos)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3812
    from assms(8)[unfolded has_integral,rule_format,OF this] guess d apply-by(erule exE conjE)+ note d=this[rule_format]
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 44167
diff changeset
  3813
    def d' \<equiv> "\<lambda>x. {y. g y \<in> d (g x)}" have d':"\<And>x. d' x = {y. g y \<in> (d (g x))}" unfolding d'_def ..
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3814
    show "\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of h ` {a..b} \<and> d fine p \<longrightarrow> norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f (g x)) - (1 / r) *\<^sub>R i) < e)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3815
    proof(rule_tac x=d' in exI,safe) show "gauge d'" using d(1) unfolding gauge_def d' using continuous_open_preimage_univ[OF assms(4)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3816
      fix p assume as:"p tagged_division_of h ` {a..b}" "d' fine p" note p = tagged_division_ofD[OF as(1)] 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3817
      have "(\<lambda>(x, k). (g x, g ` k)) ` p tagged_division_of {a..b} \<and> d fine (\<lambda>(x, k). (g x, g ` k)) ` p" unfolding tagged_division_of 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3818
      proof safe show "finite ((\<lambda>(x, k). (g x, g ` k)) ` p)" using as by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3819
        show "d fine (\<lambda>(x, k). (g x, g ` k)) ` p" using as(2) unfolding fine_def d' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3820
        fix x k assume xk[intro]:"(x,k) \<in> p" show "g x \<in> g ` k" using p(2)[OF xk] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3821
        show "\<exists>u v. g ` k = {u..v}" using p(4)[OF xk] using assms(5-6) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3822
        { fix y assume "y \<in> k" thus "g y \<in> {a..b}" "g y \<in> {a..b}" using p(3)[OF xk,unfolded subset_eq,rule_format,of "h (g y)"]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3823
            using assms(2)[rule_format,of y] unfolding inj_image_mem_iff[OF inj(2)] by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3824
        fix x' k' assume xk':"(x',k') \<in> p" fix z assume "z \<in> interior (g ` k)" "z \<in> interior (g ` k')"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3825
        hence *:"interior (g ` k) \<inter> interior (g ` k') \<noteq> {}" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3826
        have same:"(x, k) = (x', k')" apply-apply(rule ccontr,drule p(5)[OF xk xk'])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3827
        proof- assume as:"interior k \<inter> interior k' = {}" from nonempty_witness[OF *] guess z .
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3828
          hence "z \<in> g ` (interior k \<inter> interior k')" using interior_image_subset[OF assms(4) inj(1)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3829
            unfolding image_Int[OF inj(1)] by auto thus False using as by blast
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3830
        qed thus "g x = g x'" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3831
        { fix z assume "z \<in> k"  thus  "g z \<in> g ` k'" using same by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3832
        { fix z assume "z \<in> k'" thus  "g z \<in> g ` k"  using same by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3833
      next fix x assume "x \<in> {a..b}" hence "h x \<in>  \<Union>{k. \<exists>x. (x, k) \<in> p}" using p(6) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3834
        then guess X unfolding Union_iff .. note X=this from this(1) guess y unfolding mem_Collect_eq ..
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3835
        thus "x \<in> \<Union>{k. \<exists>x. (x, k) \<in> (\<lambda>(x, k). (g x, g ` k)) ` p}" apply-
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3836
          apply(rule_tac X="g ` X" in UnionI) defer apply(rule_tac x="h x" in image_eqI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3837
          using X(2) assms(3)[rule_format,of x] by auto
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  3838
      qed note ** = d(2)[OF this] have *:"inj_on (\<lambda>(x, k). (g x, g ` k)) p" using inj(1) unfolding inj_on_def by fastforce
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  3839
       have "(\<Sum>(x, k)\<in>(\<lambda>(x, k). (g x, g ` k)) ` p. content k *\<^sub>R f x) - i = r *\<^sub>R (\<Sum>(x, k)\<in>p. content k *\<^sub>R f (g x)) - i" (is "?l = _") unfolding algebra_simps add_left_cancel
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3840
        unfolding setsum_reindex[OF *] apply(subst scaleR_right.setsum) defer apply(rule setsum_cong2) unfolding o_def split_paired_all split_conv
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3841
        apply(drule p(4)) apply safe unfolding assms(7)[rule_format] using p by auto
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  3842
      also have "... = r *\<^sub>R ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f (g x)) - (1 / r) *\<^sub>R i)" (is "_ = ?r") unfolding scaleR_diff_right scaleR_scaleR
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  3843
        using assms(1) by auto finally have *:"?l = ?r" .
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3844
      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f (g x)) - (1 / r) *\<^sub>R i) < e" using ** unfolding * unfolding norm_scaleR
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3845
        using assms(1) by(auto simp add:field_simps) qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3846
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3847
subsection {* Special case of a basic affine transformation. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3848
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3849
lemma interval_image_affinity_interval: shows "\<exists>u v. (\<lambda>x. m *\<^sub>R (x::'a::ordered_euclidean_space) + c) ` {a..b} = {u..v}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3850
  unfolding image_affinity_interval by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3851
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3852
lemma setprod_cong2: assumes "\<And>x. x \<in> A \<Longrightarrow> f x = g x" shows "setprod f A = setprod g A"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3853
  apply(rule setprod_cong) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3854
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3855
lemma content_image_affinity_interval: 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3856
 "content((\<lambda>x::'a::ordered_euclidean_space. m *\<^sub>R x + c) ` {a..b}) = (abs m) ^ DIM('a) * content {a..b}" (is "?l = ?r")
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3857
proof- { presume *:"{a..b}\<noteq>{} \<Longrightarrow> ?thesis" show ?thesis apply(cases,rule *,assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3858
      unfolding not_not using content_empty by auto }
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3859
  assume as: "{a..b}\<noteq>{}" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3860
  show ?thesis 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3861
  proof (cases "m \<ge> 0")
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3862
    case True
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3863
    with as have "{m *\<^sub>R a + c..m *\<^sub>R b + c} \<noteq> {}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3864
      unfolding interval_ne_empty
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3865
      apply (intro ballI)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3866
      apply (erule_tac x=i in ballE)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3867
      apply (auto simp: inner_simps intro!: mult_left_mono)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3868
      done
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3869
    moreover from True have *: "\<And>i. (m *\<^sub>R b + c) \<bullet> i - (m *\<^sub>R a + c) \<bullet> i = m *\<^sub>R (b - a) \<bullet> i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3870
      by (simp add: inner_simps field_simps)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3871
    ultimately show ?thesis
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3872
      by (simp add: image_affinity_interval True content_closed_interval'
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3873
                    setprod_timesf setprod_constant inner_diff_left)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3874
  next
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3875
    case False
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3876
    with as have "{m *\<^sub>R b + c..m *\<^sub>R a + c} \<noteq> {}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3877
      unfolding interval_ne_empty
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3878
      apply (intro ballI)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3879
      apply (erule_tac x=i in ballE)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3880
      apply (auto simp: inner_simps intro!: mult_left_mono)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3881
      done
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3882
    moreover from False have *: "\<And>i. (m *\<^sub>R a + c) \<bullet> i - (m *\<^sub>R b + c) \<bullet> i = (-m) *\<^sub>R (b - a) \<bullet> i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3883
      by (simp add: inner_simps field_simps)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3884
    ultimately show ?thesis using False
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3885
      by (simp add: image_affinity_interval content_closed_interval'
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3886
                    setprod_timesf[symmetric] setprod_constant[symmetric] inner_diff_left)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3887
  qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3888
qed
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3889
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3890
lemma has_integral_affinity: fixes a::"'a::ordered_euclidean_space" assumes "(f has_integral i) {a..b}" "m \<noteq> 0"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3891
  shows "((\<lambda>x. f(m *\<^sub>R x + c)) has_integral ((1 / (abs(m) ^ DIM('a))) *\<^sub>R i)) ((\<lambda>x. (1 / m) *\<^sub>R x + -((1 / m) *\<^sub>R c)) ` {a..b})"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3892
  apply(rule has_integral_twiddle,safe) apply(rule zero_less_power) unfolding euclidean_eq_iff[where 'a='a]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3893
  unfolding scaleR_right_distrib inner_simps scaleR_scaleR
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3894
  defer apply(insert assms(2), simp add:field_simps) apply(insert assms(2), simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3895
  apply(rule continuous_intros)+ apply(rule interval_image_affinity_interval)+ apply(rule content_image_affinity_interval) using assms by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3896
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3897
lemma integrable_affinity: assumes "f integrable_on {a..b}" "m \<noteq> 0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3898
  shows "(\<lambda>x. f(m *\<^sub>R x + c)) integrable_on ((\<lambda>x. (1 / m) *\<^sub>R x + -((1/m) *\<^sub>R c)) ` {a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3899
  using assms unfolding integrable_on_def apply safe apply(drule has_integral_affinity) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3900
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3901
subsection {* Special case of stretching coordinate axes separately. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3902
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3903
lemma image_stretch_interval:
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3904
  "(\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k)) *\<^sub>R k) ` {a..b::'a::ordered_euclidean_space} =
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3905
  (if {a..b} = {} then {} else
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3906
    {(\<Sum>k\<in>Basis. (min (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)::'a .. 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3907
     (\<Sum>k\<in>Basis. (max (m k * (a\<bullet>k)) (m k * (b\<bullet>k))) *\<^sub>R k)})"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3908
proof cases
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3909
  assume *: "{a..b} \<noteq> {}" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3910
  show ?thesis
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3911
    unfolding interval_ne_empty if_not_P[OF *]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3912
    apply (simp add: interval image_Collect set_eq_iff euclidean_eq_iff[where 'a='a] ball_conj_distrib[symmetric])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3913
    apply (subst choice_Basis_iff[symmetric])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3914
  proof (intro allI ball_cong refl)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3915
    fix x i :: 'a assume "i \<in> Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3916
    with * have a_le_b: "a \<bullet> i \<le> b \<bullet> i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3917
      unfolding interval_ne_empty by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3918
    show "(\<exists>xa. x \<bullet> i = m i * xa \<and> a \<bullet> i \<le> xa \<and> xa \<le> b \<bullet> i) \<longleftrightarrow>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3919
        min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) \<le> x \<bullet> i \<and> x \<bullet> i \<le> max (m i * (a \<bullet> i)) (m i * (b \<bullet> i))"
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3920
    proof (cases "m i = 0")
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3921
      case True
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3922
      with a_le_b show ?thesis by auto
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3923
    next
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3924
      case False
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3925
      then have *: "\<And>a b. a = m i * b \<longleftrightarrow> b = a / m i"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3926
        by (auto simp add: field_simps)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3927
      from False have
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3928
          "min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) = (if 0 < m i then m i * (a \<bullet> i) else m i * (b \<bullet> i))"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3929
          "max (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) = (if 0 < m i then m i * (b \<bullet> i) else m i * (a \<bullet> i))"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3930
        using a_le_b by (auto simp: min_def max_def mult_le_cancel_left)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3931
      with False show ?thesis using a_le_b
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3932
        unfolding * by (auto simp add: le_divide_eq divide_le_eq ac_simps) 
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 53015
diff changeset
  3933
    qed
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3934
  qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3935
qed simp
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3936
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3937
lemma interval_image_stretch_interval: 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3938
    "\<exists>u v. (\<lambda>x. \<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k) ` {a..b::'a::ordered_euclidean_space} = {u..v::'a}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3939
  unfolding image_stretch_interval by auto 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3940
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3941
lemma content_image_stretch_interval:
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3942
  "content((\<lambda>x::'a::ordered_euclidean_space. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)::'a) ` {a..b}) = abs(setprod m Basis) * content({a..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3943
proof(cases "{a..b} = {}") case True thus ?thesis
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3944
    unfolding content_def image_is_empty image_stretch_interval if_P[OF True] by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3945
next case False hence "(\<lambda>x. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)::'a) ` {a..b} \<noteq> {}" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3946
  thus ?thesis using False unfolding content_def image_stretch_interval apply- unfolding interval_bounds' if_not_P
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3947
    unfolding abs_setprod setprod_timesf[THEN sym] apply(rule setprod_cong2) unfolding lessThan_iff
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3948
  proof (simp only: inner_setsum_left_Basis)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3949
    fix i :: 'a assume i:"i\<in>Basis" have "(m i < 0 \<or> m i > 0) \<or> m i = 0" by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3950
    thus "max (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) - min (m i * (a \<bullet> i)) (m i * (b \<bullet> i)) = 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3951
        \<bar>m i\<bar> * (b \<bullet> i - a \<bullet> i)"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3952
      apply-apply(erule disjE)+ unfolding min_def max_def using False[unfolded interval_ne_empty,rule_format,of i] i 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3953
      by(auto simp add:field_simps not_le mult_le_cancel_left_neg mult_le_cancel_left_pos) qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3954
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3955
lemma has_integral_stretch: fixes f::"'a::ordered_euclidean_space => 'b::real_normed_vector"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3956
  assumes "(f has_integral i) {a..b}" "\<forall>k\<in>Basis. ~(m k = 0)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3957
  shows "((\<lambda>x. f (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) has_integral
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3958
             ((1/(abs(setprod m Basis))) *\<^sub>R i)) ((\<lambda>x. (\<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k)) ` {a..b})"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3959
  apply(rule has_integral_twiddle[where f=f]) unfolding zero_less_abs_iff content_image_stretch_interval
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3960
  unfolding image_stretch_interval empty_as_interval euclidean_eq_iff[where 'a='a] using assms
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3961
proof- show "\<forall>y::'a. continuous (at y) (\<lambda>x. (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3962
   apply(rule,rule linear_continuous_at) unfolding linear_linear
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3963
   unfolding linear_def inner_simps euclidean_eq_iff[where 'a='a] by(auto simp add:field_simps)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3964
qed auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3965
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3966
lemma integrable_stretch:  fixes f::"'a::ordered_euclidean_space => 'b::real_normed_vector"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3967
  assumes "f integrable_on {a..b}" "\<forall>k\<in>Basis. ~(m k = 0)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  3968
  shows "(\<lambda>x::'a. f (\<Sum>k\<in>Basis. (m k * (x\<bullet>k))*\<^sub>R k)) integrable_on ((\<lambda>x. \<Sum>k\<in>Basis. (1 / m k * (x\<bullet>k))*\<^sub>R k) ` {a..b})"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3969
  using assms unfolding integrable_on_def apply-apply(erule exE) 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3970
  apply(drule has_integral_stretch,assumption) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3971
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3972
subsection {* even more special cases. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3973
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3974
lemma uminus_interval_vector[simp]:"uminus ` {a..b} = {-b .. -a::'a::ordered_euclidean_space}"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 38656
diff changeset
  3975
  apply(rule set_eqI,rule) defer unfolding image_iff
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3976
  apply(rule_tac x="-x" in bexI) by(auto simp add:minus_le_iff le_minus_iff eucl_le[where 'a='a])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3977
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3978
lemma has_integral_reflect_lemma[intro]: assumes "(f has_integral i) {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3979
  shows "((\<lambda>x. f(-x)) has_integral i) {-b .. -a}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3980
  using has_integral_affinity[OF assms, of "-1" 0] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3981
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3982
lemma has_integral_reflect[simp]: "((\<lambda>x. f(-x)) has_integral i) {-b..-a} \<longleftrightarrow> (f has_integral i) ({a..b})"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3983
  apply rule apply(drule_tac[!] has_integral_reflect_lemma) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3984
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3985
lemma integrable_reflect[simp]: "(\<lambda>x. f(-x)) integrable_on {-b..-a} \<longleftrightarrow> f integrable_on {a..b}"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3986
  unfolding integrable_on_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3987
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3988
lemma integral_reflect[simp]: "integral {-b..-a} (\<lambda>x. f(-x)) = integral ({a..b}) f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3989
  unfolding integral_def by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3990
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3991
subsection {* Stronger form of FCT; quite a tedious proof. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3992
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3993
lemma bgauge_existence_lemma: "(\<forall>x\<in>s. \<exists>d::real. 0 < d \<and> q d x) \<longleftrightarrow> (\<forall>x. \<exists>d>0. x\<in>s \<longrightarrow> q d x)" by(meson zero_less_one)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3994
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3995
lemma additive_tagged_division_1': fixes f::"real \<Rightarrow> 'a::real_normed_vector"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3996
  assumes "a \<le> b" "p tagged_division_of {a..b}"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3997
  shows "setsum (\<lambda>(x,k). f (interval_upperbound k) - f(interval_lowerbound k)) p = f b - f a"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  3998
  using additive_tagged_division_1[OF _ assms(2), of f] using assms(1) by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  3999
36318
3567d0571932 eliminated spurious schematic statements;
wenzelm
parents: 36244
diff changeset
  4000
lemma split_minus[simp]:"(\<lambda>(x, k). f x k) x - (\<lambda>(x, k). g x k) x = (\<lambda>(x, k). f x k - g x k) x"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4001
  unfolding split_def by(rule refl)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4002
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4003
lemma norm_triangle_le_sub: "norm x + norm y \<le> e \<Longrightarrow> norm (x - y) \<le> e"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4004
  apply(subst(asm)(2) norm_minus_cancel[THEN sym])
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  4005
  apply(drule norm_triangle_le) by(auto simp add:algebra_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4006
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4007
lemma fundamental_theorem_of_calculus_interior: fixes f::"real => 'a::real_normed_vector"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4008
  assumes"a \<le> b" "continuous_on {a..b} f" "\<forall>x\<in>{a<..<b}. (f has_vector_derivative f'(x)) (at x)"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4009
  shows "(f' has_integral (f b - f a)) {a..b}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4010
proof- { presume *:"a < b \<Longrightarrow> ?thesis" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4011
    show ?thesis proof(cases,rule *,assumption)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4012
      assume "\<not> a < b" hence "a = b" using assms(1) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4013
      hence *:"{a .. b} = {b}" "f b - f a = 0" by(auto simp add:  order_antisym)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4014
      show ?thesis unfolding *(2) apply(rule has_integral_null) unfolding content_eq_0 using * `a=b`
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4015
        by (auto simp: ex_in_conv)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4016
    qed } assume ab:"a < b"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4017
  let ?P = "\<lambda>e. \<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4018
                   norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f' x) - (f b - f a)) \<le> e * content {a..b})"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4019
  { presume "\<And>e. e>0 \<Longrightarrow> ?P e" thus ?thesis unfolding has_integral_factor_content by auto }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4020
  fix e::real assume e:"e>0"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4021
  note assms(3)[unfolded has_vector_derivative_def has_derivative_at_alt ball_conj_distrib]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4022
  note conjunctD2[OF this] note bounded=this(1) and this(2)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4023
  from this(2) have "\<forall>x\<in>{a<..<b}. \<exists>d>0. \<forall>y. norm (y - x) < d \<longrightarrow> norm (f y - f x - (y - x) *\<^sub>R f' x) \<le> e/2 * norm (y - x)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4024
    apply-apply safe apply(erule_tac x=x in ballE,erule_tac x="e/2" in allE) using e by auto note this[unfolded bgauge_existence_lemma]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4025
  from choice[OF this] guess d .. note conjunctD2[OF this[rule_format]] note d = this[rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4026
  have "bounded (f ` {a..b})" apply(rule compact_imp_bounded compact_continuous_image)+ using compact_interval assms by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4027
  from this[unfolded bounded_pos] guess B .. note B = this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4028
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4029
  have "\<exists>da. 0 < da \<and> (\<forall>c. a \<le> c \<and> {a..c} \<subseteq> {a..b} \<and> {a..c} \<subseteq> ball a da
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4030
    \<longrightarrow> norm(content {a..c} *\<^sub>R f' a - (f c - f a)) \<le> (e * (b - a)) / 4)"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4031
  proof- have "a\<in>{a..b}" using ab by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4032
    note assms(2)[unfolded continuous_on_eq_continuous_within,rule_format,OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4033
    note * = this[unfolded continuous_within Lim_within,rule_format] have "(e * (b - a)) / 8 > 0" using e ab by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4034
    from *[OF this] guess k .. note k = conjunctD2[OF this,rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4035
    have "\<exists>l. 0 < l \<and> norm(l *\<^sub>R f' a) \<le> (e * (b - a)) / 8"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4036
    proof(cases "f' a = 0") case True
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4037
      thus ?thesis apply(rule_tac x=1 in exI) using ab e by(auto intro!:mult_nonneg_nonneg) 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4038
    next case False thus ?thesis
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4039
        apply(rule_tac x="(e * (b - a)) / 8 / norm (f' a)" in exI) using ab e by(auto simp add:field_simps) 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4040
    qed then guess l .. note l = conjunctD2[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4041
    show ?thesis apply(rule_tac x="min k l" in exI) apply safe unfolding min_less_iff_conj apply(rule,(rule l k)+)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4042
    proof- fix c assume as:"a \<le> c" "{a..c} \<subseteq> {a..b}" "{a..c} \<subseteq> ball a (min k l)" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4043
      note as' = this[unfolded subset_eq Ball_def mem_ball dist_real_def mem_interval]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4044
      have "norm ((c - a) *\<^sub>R f' a - (f c - f a)) \<le> norm ((c - a) *\<^sub>R f' a) + norm (f c - f a)" by(rule norm_triangle_ineq4)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4045
      also have "... \<le> e * (b - a) / 8 + e * (b - a) / 8" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4046
      proof(rule add_mono) case goal1 have "\<bar>c - a\<bar> \<le> \<bar>l\<bar>" using as' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4047
        thus ?case apply-apply(rule order_trans[OF _ l(2)]) unfolding norm_scaleR apply(rule mult_right_mono) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4048
      next case goal2 show ?case apply(rule less_imp_le) apply(cases "a = c") defer
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4049
          apply(rule k(2)[unfolded dist_norm]) using as' e ab by(auto simp add:field_simps)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4050
      qed finally show "norm (content {a..c} *\<^sub>R f' a - (f c - f a)) \<le> e * (b - a) / 4"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4051
        unfolding content_real[OF as(1)] by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4052
    qed qed then guess da .. note da=conjunctD2[OF this,rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4053
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4054
  have "\<exists>db>0. \<forall>c\<le>b. {c..b} \<subseteq> {a..b} \<and> {c..b} \<subseteq> ball b db \<longrightarrow>
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4055
    norm(content {c..b} *\<^sub>R f' b - (f b - f c)) \<le> (e * (b - a)) / 4"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4056
  proof- have "b\<in>{a..b}" using ab by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4057
    note assms(2)[unfolded continuous_on_eq_continuous_within,rule_format,OF this]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4058
    note * = this[unfolded continuous_within Lim_within,rule_format] have "(e * (b - a)) / 8 > 0"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4059
      using e ab by(auto simp add:field_simps)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4060
    from *[OF this] guess k .. note k = conjunctD2[OF this,rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4061
    have "\<exists>l. 0 < l \<and> norm(l *\<^sub>R f' b) \<le> (e * (b - a)) / 8"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4062
    proof(cases "f' b = 0") case True
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4063
      thus ?thesis apply(rule_tac x=1 in exI) using ab e by(auto intro!:mult_nonneg_nonneg) 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4064
    next case False thus ?thesis 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4065
        apply(rule_tac x="(e * (b - a)) / 8 / norm (f' b)" in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4066
        using ab e by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4067
    qed then guess l .. note l = conjunctD2[OF this]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4068
    show ?thesis apply(rule_tac x="min k l" in exI) apply safe unfolding min_less_iff_conj apply(rule,(rule l k)+)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4069
    proof- fix c assume as:"c \<le> b" "{c..b} \<subseteq> {a..b}" "{c..b} \<subseteq> ball b (min k l)" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4070
      note as' = this[unfolded subset_eq Ball_def mem_ball dist_real_def mem_interval]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4071
      have "norm ((b - c) *\<^sub>R f' b - (f b - f c)) \<le> norm ((b - c) *\<^sub>R f' b) + norm (f b - f c)" by(rule norm_triangle_ineq4)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4072
      also have "... \<le> e * (b - a) / 8 + e * (b - a) / 8" 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4073
      proof(rule add_mono) case goal1 have "\<bar>c - b\<bar> \<le> \<bar>l\<bar>" using as' by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4074
        thus ?case apply-apply(rule order_trans[OF _ l(2)]) unfolding norm_scaleR apply(rule mult_right_mono) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4075
      next case goal2 show ?case apply(rule less_imp_le) apply(cases "b = c") defer apply(subst norm_minus_commute)
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4076
          apply(rule k(2)[unfolded dist_norm]) using as' e ab by(auto simp add:field_simps)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4077
      qed finally show "norm (content {c..b} *\<^sub>R f' b - (f b - f c)) \<le> e * (b - a) / 4"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4078
        unfolding content_real[OF as(1)] by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4079
    qed qed then guess db .. note db=conjunctD2[OF this,rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4080
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4081
  let ?d = "(\<lambda>x. ball x (if x=a then da else if x=b then db else d x))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4082
  show "?P e" apply(rule_tac x="?d" in exI)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4083
  proof safe case goal1 show ?case apply(rule gauge_ball_dependent) using ab db(1) da(1) d(1) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4084
  next case goal2 note as=this let ?A = "{t. fst t \<in> {a, b}}" note p = tagged_division_ofD[OF goal2(1)]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4085
    have pA:"p = (p \<inter> ?A) \<union> (p - ?A)" "finite (p \<inter> ?A)" "finite (p - ?A)" "(p \<inter> ?A) \<inter> (p - ?A) = {}"  using goal2 by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4086
    note * = additive_tagged_division_1'[OF assms(1) goal2(1), THEN sym]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4087
    have **:"\<And>n1 s1 n2 s2::real. n2 \<le> s2 / 2 \<Longrightarrow> n1 - s1 \<le> s2 / 2 \<Longrightarrow> n1 + n2 \<le> s1 + s2" by arith
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4088
    show ?case unfolding content_real[OF assms(1)] and *[of "\<lambda>x. x"] *[of f] setsum_subtractf[THEN sym] split_minus
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4089
      unfolding setsum_right_distrib apply(subst(2) pA,subst pA) unfolding setsum_Un_disjoint[OF pA(2-)]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4090
    proof(rule norm_triangle_le,rule **) 
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  4091
      case goal1 show ?case apply(rule order_trans,rule setsum_norm_le) defer apply(subst setsum_divide_distrib)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4092
      proof(rule order_refl,safe,unfold not_le o_def split_conv fst_conv,rule ccontr) fix x k assume as:"(x,k) \<in> p"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4093
          "e * (interval_upperbound k -  interval_lowerbound k) / 2
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4094
          < norm (content k *\<^sub>R f' x - (f (interval_upperbound k) - f (interval_lowerbound k)))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4095
        from p(4)[OF this(1)] guess u v apply-by(erule exE)+ note k=this
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4096
        hence "u \<le> v" and uv:"{u,v}\<subseteq>{u..v}" using p(2)[OF as(1)] by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4097
        note result = as(2)[unfolded k interval_bounds_real[OF this(1)] content_real[OF this(1)]]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4098
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4099
        assume as':"x \<noteq> a" "x \<noteq> b" hence "x \<in> {a<..<b}" using p(2-3)[OF as(1)] by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4100
        note  * = d(2)[OF this]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4101
        have "norm ((v - u) *\<^sub>R f' (x) - (f (v) - f (u))) =
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4102
          norm ((f (u) - f (x) - (u - x) *\<^sub>R f' (x)) - (f (v) - f (x) - (v - x) *\<^sub>R f' (x)))" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4103
          apply(rule arg_cong[of _ _ norm]) unfolding scaleR_left.diff by auto 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4104
        also have "... \<le> e / 2 * norm (u - x) + e / 2 * norm (v - x)" apply(rule norm_triangle_le_sub)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4105
          apply(rule add_mono) apply(rule_tac[!] *) using fineD[OF goal2(2) as(1)] as' unfolding k subset_eq
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4106
          apply- apply(erule_tac x=u in ballE,erule_tac[3] x=v in ballE) using uv by(auto simp:dist_real_def)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4107
        also have "... \<le> e / 2 * norm (v - u)" using p(2)[OF as(1)] unfolding k by(auto simp add:field_simps)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4108
        finally have "e * (v - u) / 2 < e * (v - u) / 2"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4109
          apply- apply(rule less_le_trans[OF result]) using uv by auto thus False by auto qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4110
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4111
    next have *:"\<And>x s1 s2::real. 0 \<le> s1 \<Longrightarrow> x \<le> (s1 + s2) / 2 \<Longrightarrow> x - s1 \<le> s2 / 2" by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4112
      case goal2 show ?case apply(rule *) apply(rule setsum_nonneg) apply(rule,unfold split_paired_all split_conv)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4113
        defer unfolding setsum_Un_disjoint[OF pA(2-),THEN sym] pA(1)[THEN sym] unfolding setsum_right_distrib[THEN sym] 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4114
        apply(subst additive_tagged_division_1[OF _ as(1)]) apply(rule assms)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4115
      proof- fix x k assume "(x,k) \<in> p \<inter> {t. fst t \<in> {a, b}}" note xk=IntD1[OF this]
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4116
        from p(4)[OF this] guess u v apply-by(erule exE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4117
        with p(2)[OF xk] have "{u..v} \<noteq> {}" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4118
        thus "0 \<le> e * ((interval_upperbound k) - (interval_lowerbound k))"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4119
          unfolding uv using e by(auto simp add:field_simps)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4120
      next have *:"\<And>s f t e. setsum f s = setsum f t \<Longrightarrow> norm(setsum f t) \<le> e \<Longrightarrow> norm(setsum f s) \<le> e" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4121
        show "norm (\<Sum>(x, k)\<in>p \<inter> ?A. content k *\<^sub>R f' x -
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4122
          (f ((interval_upperbound k)) - f ((interval_lowerbound k)))) \<le> e * (b - a) / 2" 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4123
          apply(rule *[where t="p \<inter> {t. fst t \<in> {a, b} \<and> content(snd t) \<noteq> 0}"])
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4124
          apply(rule setsum_mono_zero_right[OF pA(2)]) defer apply(rule) unfolding split_paired_all split_conv o_def
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4125
        proof- fix x k assume "(x,k) \<in> p \<inter> {t. fst t \<in> {a, b}} - p \<inter> {t. fst t \<in> {a, b} \<and> content (snd t) \<noteq> 0}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4126
          hence xk:"(x,k)\<in>p" "content k = 0" by auto from p(4)[OF xk(1)] guess u v apply-by(erule exE)+ note uv=this
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4127
          have "k\<noteq>{}" using p(2)[OF xk(1)] by auto hence *:"u = v" using xk
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4128
            unfolding uv content_eq_0 interval_eq_empty by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4129
          thus "content k *\<^sub>R (f' (x)) - (f ((interval_upperbound k)) - f ((interval_lowerbound k))) = 0" using xk unfolding uv by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4130
        next have *:"p \<inter> {t. fst t \<in> {a, b} \<and> content(snd t) \<noteq> 0} = 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4131
            {t. t\<in>p \<and> fst t = a \<and> content(snd t) \<noteq> 0} \<union> {t. t\<in>p \<and> fst t = b \<and> content(snd t) \<noteq> 0}" by blast
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4132
          have **:"\<And>s f. \<And>e::real. (\<forall>x y. x \<in> s \<and> y \<in> s \<longrightarrow> x = y) \<Longrightarrow> (\<forall>x. x \<in> s \<longrightarrow> norm(f x) \<le> e)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4133
            \<Longrightarrow> e>0 \<Longrightarrow> norm(setsum f s) \<le> e"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4134
          proof(case_tac "s={}") case goal2 then obtain x where "x\<in>s" by auto hence *:"s = {x}" using goal2(1) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4135
            thus ?case using `x\<in>s` goal2(2) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4136
          qed auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4137
          case goal2 show ?case apply(subst *, subst setsum_Un_disjoint) prefer 4
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4138
            apply(rule order_trans[of _ "e * (b - a)/4 + e * (b - a)/4"]) 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4139
            apply(rule norm_triangle_le,rule add_mono) apply(rule_tac[1-2] **)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4140
          proof- let ?B = "\<lambda>x. {t \<in> p. fst t = x \<and> content (snd t) \<noteq> 0}"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4141
            have pa:"\<And>k. (a, k) \<in> p \<Longrightarrow> \<exists>v. k = {a .. v} \<and> a \<le> v" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4142
            proof- case goal1 guess u v using p(4)[OF goal1] apply-by(erule exE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4143
              have *:"u \<le> v" using p(2)[OF goal1] unfolding uv by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4144
              have u:"u = a" proof(rule ccontr)  have "u \<in> {u..v}" using p(2-3)[OF goal1(1)] unfolding uv by auto 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4145
                have "u \<ge> a" using p(2-3)[OF goal1(1)] unfolding uv subset_eq by auto moreover assume "u\<noteq>a" ultimately
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4146
                have "u > a" by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4147
                thus False using p(2)[OF goal1(1)] unfolding uv by(auto simp add:)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4148
              qed thus ?case apply(rule_tac x=v in exI) unfolding uv using * by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4149
            qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4150
            have pb:"\<And>k. (b, k) \<in> p \<Longrightarrow> \<exists>v. k = {v .. b} \<and> b \<ge> v" 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4151
            proof- case goal1 guess u v using p(4)[OF goal1] apply-by(erule exE)+ note uv=this
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4152
              have *:"u \<le> v" using p(2)[OF goal1] unfolding uv by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4153
              have u:"v =  b" proof(rule ccontr)  have "u \<in> {u..v}" using p(2-3)[OF goal1(1)] unfolding uv by auto 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4154
                have "v \<le>  b" using p(2-3)[OF goal1(1)] unfolding uv subset_eq by auto moreover assume "v\<noteq> b" ultimately
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4155
                have "v <  b" by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4156
                thus False using p(2)[OF goal1(1)] unfolding uv by(auto simp add:)
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4157
              qed thus ?case apply(rule_tac x=u in exI) unfolding uv using * by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4158
            qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4159
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4160
            show "\<forall>x y. x \<in> ?B a \<and> y \<in> ?B a \<longrightarrow> x = y" apply(rule,rule,rule,unfold split_paired_all)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4161
              unfolding mem_Collect_eq fst_conv snd_conv apply safe
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4162
            proof- fix x k k' assume k:"( a, k) \<in> p" "( a, k') \<in> p" "content k \<noteq> 0" "content k' \<noteq> 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4163
              guess v using pa[OF k(1)] .. note v = conjunctD2[OF this]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4164
              guess v' using pa[OF k(2)] .. note v' = conjunctD2[OF this] let ?v = " (min (v) (v'))"
44522
2f7e9d890efe rename subset_{interior,closure} to {interior,closure}_mono;
huffman
parents: 44514
diff changeset
  4165
              have "{ a <..< ?v} \<subseteq> k \<inter> k'" unfolding v v' by(auto simp add:) note interior_mono[OF this,unfolded interior_inter]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4166
              moreover have " ((a + ?v)/2) \<in> { a <..< ?v}" using k(3-)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4167
                unfolding v v' content_eq_0 not_le by(auto simp add:not_le)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4168
              ultimately have " ((a + ?v)/2) \<in> interior k \<inter> interior k'" unfolding interior_open[OF open_interval] by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4169
              hence *:"k = k'" apply- apply(rule ccontr) using p(5)[OF k(1-2)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4170
              { assume "x\<in>k" thus "x\<in>k'" unfolding * . } { assume "x\<in>k'" thus "x\<in>k" unfolding * . }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4171
            qed 
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4172
            show "\<forall>x y. x \<in> ?B b \<and> y \<in> ?B b \<longrightarrow> x = y" apply(rule,rule,rule,unfold split_paired_all)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4173
              unfolding mem_Collect_eq fst_conv snd_conv apply safe
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4174
            proof- fix x k k' assume k:"( b, k) \<in> p" "( b, k') \<in> p" "content k \<noteq> 0" "content k' \<noteq> 0"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4175
              guess v using pb[OF k(1)] .. note v = conjunctD2[OF this]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4176
              guess v' using pb[OF k(2)] .. note v' = conjunctD2[OF this] let ?v = " (max (v) (v'))"
44522
2f7e9d890efe rename subset_{interior,closure} to {interior,closure}_mono;
huffman
parents: 44514
diff changeset
  4177
              have "{?v <..<  b} \<subseteq> k \<inter> k'" unfolding v v' by(auto simp add:) note interior_mono[OF this,unfolded interior_inter]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4178
              moreover have " ((b + ?v)/2) \<in> {?v <..<  b}" using k(3-) unfolding v v' content_eq_0 not_le by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4179
              ultimately have " ((b + ?v)/2) \<in> interior k \<inter> interior k'" unfolding interior_open[OF open_interval] by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4180
              hence *:"k = k'" apply- apply(rule ccontr) using p(5)[OF k(1-2)] by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4181
              { assume "x\<in>k" thus "x\<in>k'" unfolding * . } { assume "x\<in>k'" thus "x\<in>k" unfolding * . }
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4182
            qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4183
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4184
            let ?a = a and ?b = b (* a is something else while proofing the next theorem. *)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4185
            show "\<forall>x. x \<in> ?B a \<longrightarrow> norm ((\<lambda>(x, k). content k *\<^sub>R f' (x) - (f ((interval_upperbound k)) -
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4186
              f ((interval_lowerbound k)))) x) \<le> e * (b - a) / 4" apply(rule,rule) unfolding mem_Collect_eq
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4187
              unfolding split_paired_all fst_conv snd_conv 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4188
            proof safe case goal1 guess v using pa[OF goal1(1)] .. note v = conjunctD2[OF this]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4189
              have " ?a\<in>{ ?a..v}" using v(2) by auto hence "v \<le> ?b" using p(3)[OF goal1(1)] unfolding subset_eq v by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4190
              moreover have "{?a..v} \<subseteq> ball ?a da" using fineD[OF as(2) goal1(1)]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4191
                apply-apply(subst(asm) if_P,rule refl) unfolding subset_eq apply safe apply(erule_tac x=" x" in ballE)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4192
                by(auto simp add:subset_eq dist_real_def v) ultimately
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4193
              show ?case unfolding v interval_bounds_real[OF v(2)] apply- apply(rule da(2)[of "v"])
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4194
                using goal1 fineD[OF as(2) goal1(1)] unfolding v content_eq_0 by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4195
            qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4196
            show "\<forall>x. x \<in> ?B b \<longrightarrow> norm ((\<lambda>(x, k). content k *\<^sub>R f' (x) -
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4197
              (f ((interval_upperbound k)) - f ((interval_lowerbound k)))) x) \<le> e * (b - a) / 4"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4198
              apply(rule,rule) unfolding mem_Collect_eq unfolding split_paired_all fst_conv snd_conv 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4199
            proof safe case goal1 guess v using pb[OF goal1(1)] .. note v = conjunctD2[OF this]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4200
              have " ?b\<in>{v.. ?b}" using v(2) by auto hence "v \<ge> ?a" using p(3)[OF goal1(1)]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4201
                unfolding subset_eq v by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4202
              moreover have "{v..?b} \<subseteq> ball ?b db" using fineD[OF as(2) goal1(1)]
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4203
                apply-apply(subst(asm) if_P,rule refl) unfolding subset_eq apply safe
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4204
                apply(erule_tac x=" x" in ballE) using ab
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4205
                by(auto simp add:subset_eq v dist_real_def) ultimately
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4206
              show ?case unfolding v unfolding interval_bounds_real[OF v(2)] apply- apply(rule db(2)[of "v"])
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4207
                using goal1 fineD[OF as(2) goal1(1)] unfolding v content_eq_0 by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4208
            qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4209
          qed(insert p(1) ab e, auto simp add:field_simps) qed auto qed qed qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4210
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4211
subsection {* Stronger form with finite number of exceptional points. *}
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4212
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4213
lemma fundamental_theorem_of_calculus_interior_strong: fixes f::"real \<Rightarrow> 'a::banach"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4214
  assumes"finite s" "a \<le> b" "continuous_on {a..b} f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4215
  "\<forall>x\<in>{a<..<b} - s. (f has_vector_derivative f'(x)) (at x)"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4216
  shows "(f' has_integral (f b - f a)) {a..b}" using assms apply- 
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4217
proof(induct "card s" arbitrary:s a b)
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4218
  case 0 show ?case apply(rule fundamental_theorem_of_calculus_interior) using 0 by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4219
next case (Suc n) from this(2) guess c s' apply-apply(subst(asm) eq_commute) unfolding card_Suc_eq
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4220
    apply(subst(asm)(2) eq_commute) by(erule exE conjE)+ note cs = this[rule_format]
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4221
  show ?case proof(cases "c\<in>{a<..<b}")
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4222
    case False thus ?thesis apply- apply(rule Suc(1)[OF cs(3) _ Suc(4,5)]) apply safe defer
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4223
      apply(rule Suc(6)[rule_format]) using Suc(3) unfolding cs by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4224
  next have *:"f b - f a = (f c - f a) + (f b - f c)" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4225
    case True hence "a \<le> c" "c \<le> b" by auto
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4226
    thus ?thesis apply(subst *) apply(rule has_integral_combine) apply assumption+
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4227
      apply(rule_tac[!] Suc(1)[OF cs(3)]) using Suc(3) unfolding cs
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4228
    proof- show "continuous_on {a..c} f" "continuous_on {c..b} f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4229
        apply(rule_tac[!] continuous_on_subset[OF Suc(5)]) using True by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4230
      let ?P = "\<lambda>i j. \<forall>x\<in>{i<..<j} - s'. (f has_vector_derivative f' x) (at x)"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4231
      show "?P a c" "?P c b" apply safe apply(rule_tac[!] Suc(6)[rule_format]) using True unfolding cs by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4232
    qed auto qed qed
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4233
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4234
lemma fundamental_theorem_of_calculus_strong: fixes f::"real \<Rightarrow> 'a::banach"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4235
  assumes "finite s" "a \<le> b" "continuous_on {a..b} f"
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4236
  "\<forall>x\<in>{a..b} - s. (f has_vector_derivative f'(x)) (at x)"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4237
  shows "(f' has_integral (f(b) - f(a))) {a..b}"
35172
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4238
  apply(rule fundamental_theorem_of_calculus_interior_strong[OF assms(1-3), of f'])
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4239
  using assms(4) by auto
579dd5570f96 Added integration to Multivariate-Analysis (upto FTC)
himmelma
parents:
diff changeset
  4240
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4241
lemma indefinite_integral_continuous_left: fixes f::"real \<Rightarrow> 'a::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4242
  assumes "f integrable_on {a..b}" "a < c" "c \<le> b" "0 < e"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4243
  obtains d where "0 < d" "\<forall>t. c - d < t \<and> t \<le> c \<longrightarrow> norm(integral {a..c} f - integral {a..t} f) < e"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4244
proof- have "\<exists>w>0. \<forall>t. c - w < t \<and> t < c \<longrightarrow> norm(f c) * norm(c - t) < e / 3"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4245
  proof(cases "f c = 0") case False hence "0 < e / 3 / norm (f c)"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4246
      apply-apply(rule divide_pos_pos) using `e>0` by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4247
    thus ?thesis apply-apply(rule,rule,assumption,safe)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4248
    proof- fix t assume as:"t < c" and "c - e / 3 / norm (f c) < t"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4249
      hence "c - t < e / 3 / norm (f c)" by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4250
      hence "norm (c - t) < e / 3 / norm (f c)" using as by auto
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4251
      thus "norm (f c) * norm (c - t) < e / 3" using False apply-
36778
739a9379e29b avoid using real-specific versions of generic lemmas
huffman
parents: 36725
diff changeset
  4252
        apply(subst mult_commute) apply(subst pos_less_divide_eq[THEN sym]) by auto
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4253
    qed next case True show ?thesis apply(rule_tac x=1 in exI) unfolding True using `e>0` by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4254
  qed then guess w .. note w = conjunctD2[OF this,rule_format]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4255
  
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4256
  have *:"e / 3 > 0" using assms by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4257
  have "f integrable_on {a..c}" apply(rule integrable_subinterval[OF assms(1)]) using assms(2-3) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4258
  from integrable_integral[OF this,unfolded has_integral,rule_format,OF *] guess d1 ..
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4259
  note d1 = conjunctD2[OF this,rule_format] def d \<equiv> "\<lambda>x. ball x w \<inter> d1 x"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4260
  have "gauge d" unfolding d_def using w(1) d1 by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4261
  note this[unfolded gauge_def,rule_format,of c] note conjunctD2[OF this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4262
  from this(2)[unfolded open_contains_ball,rule_format,OF this(1)] guess k .. note k=conjunctD2[OF this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4263
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4264
  let ?d = "min k (c - a)/2" show ?thesis apply(rule that[of ?d])
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4265
  proof safe
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4266
    show "?d > 0" using k(1) using assms(2) by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4267
    fix t assume as:"c - ?d < t" "t \<le> c"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4268
    let ?thesis = "norm (integral {a..c} f - integral {a..t} f) < e"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4269
    { presume *:"t < c \<Longrightarrow> ?thesis"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4270
      show ?thesis apply(cases "t = c") defer apply(rule *)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4271
        apply(subst less_le) using `e>0` as(2) by auto }
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4272
    assume "t < c"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4273
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4274
    have "f integrable_on {a..t}" apply(rule integrable_subinterval[OF assms(1)]) using assms(2-3) as(2) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4275
    from integrable_integral[OF this,unfolded has_integral,rule_format,OF *] guess d2 ..
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4276
    note d2 = conjunctD2[OF this,rule_format]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4277
    def d3 \<equiv> "\<lambda>x. if x \<le> t then d1 x \<inter> d2 x else d1 x"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4278
    have "gauge d3" using d2(1) d1(1) unfolding d3_def gauge_def by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4279
    from fine_division_exists[OF this, of a t] guess p . note p=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4280
    note p'=tagged_division_ofD[OF this(1)]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4281
    have pt:"\<forall>(x,k)\<in>p. x \<le> t" proof safe case goal1 from p'(2,3)[OF this] show ?case by auto qed
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4282
    with p(2) have "d2 fine p" unfolding fine_def d3_def apply safe apply(erule_tac x="(a,b)" in ballE)+ by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4283
    note d2_fin = d2(2)[OF conjI[OF p(1) this]]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4284
    
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4285
    have *:"{a..c} \<inter> {x. x \<bullet> 1 \<le> t} = {a..t}" "{a..c} \<inter> {x. x \<bullet> 1 \<ge> t} = {t..c}"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4286
      using assms(2-3) as by(auto simp add:field_simps)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4287
    have "p \<union> {(c, {t..c})} tagged_division_of {a..c} \<and> d1 fine p \<union> {(c, {t..c})}" apply rule
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4288
      apply(rule tagged_division_union_interval[of _ _ _ 1 "t"]) unfolding * apply(rule p)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4289
      apply(rule tagged_division_of_self) unfolding fine_def
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4290
    proof safe fix x k y assume "(x,k)\<in>p" "y\<in>k" thus "y\<in>d1 x"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4291
        using p(2) pt unfolding fine_def d3_def apply- apply(erule_tac x="(x,k)" in ballE)+ by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4292
    next fix x assume "x\<in>{t..c}" hence "dist c x < k" unfolding dist_real_def
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4293
        using as(1) by(auto simp add:field_simps) 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4294
      thus "x \<in> d1 c" using k(2) unfolding d_def by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4295
    qed(insert as(2), auto) note d1_fin = d1(2)[OF this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4296
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4297
    have *:"integral{a..c} f - integral {a..t} f = -(((c - t) *\<^sub>R f c + (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)) -
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4298
        integral {a..c} f) + ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - integral {a..t} f) + (c - t) *\<^sub>R f c" 
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4299
      "e = (e/3 + e/3) + e/3" by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4300
    have **:"(\<Sum>(x, k)\<in>p \<union> {(c, {t..c})}. content k *\<^sub>R f x) = (c - t) *\<^sub>R f c + (\<Sum>(x, k)\<in>p. content k *\<^sub>R f x)"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4301
    proof- have **:"\<And>x F. F \<union> {x} = insert x F" by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4302
      have "(c, {t..c}) \<notin> p" proof safe case goal1 from p'(2-3)[OF this]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4303
        have "c \<in> {a..t}" by auto thus False using `t<c` by auto
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4304
      qed thus ?thesis unfolding ** apply- apply(subst setsum_insert) apply(rule p')
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4305
        unfolding split_conv defer apply(subst content_real) using as(2) by auto qed 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4306
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4307
    have ***:"c - w < t \<and> t < c"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4308
    proof- have "c - k < t" using `k>0` as(1) by(auto simp add:field_simps)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4309
      moreover have "k \<le> w" apply(rule ccontr) using k(2) 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4310
        unfolding subset_eq apply(erule_tac x="c + ((k + w)/2)" in ballE)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4311
        unfolding d_def using `k>0` `w>0` by(auto simp add:field_simps not_le not_less dist_real_def)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4312
      ultimately show  ?thesis using `t<c` by(auto simp add:field_simps) qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4313
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4314
    show ?thesis unfolding *(1) apply(subst *(2)) apply(rule norm_triangle_lt add_strict_mono)+
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4315
      unfolding norm_minus_cancel apply(rule d1_fin[unfolded **]) apply(rule d2_fin)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4316
      using w(2)[OF ***] unfolding norm_scaleR by(auto simp add:field_simps) qed qed 
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4317
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4318
lemma indefinite_integral_continuous_right: fixes f::"real \<Rightarrow> 'a::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4319
  assumes "f integrable_on {a..b}" "a \<le> c" "c < b" "0 < e"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4320
  obtains d where "0 < d" "\<forall>t. c \<le> t \<and> t < c + d \<longrightarrow> norm(integral{a..c} f - integral{a..t} f) < e"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4321
proof- have *:"(\<lambda>x. f (- x)) integrable_on {- b..- a}" "- b < - c" "- c \<le> - a" using assms by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4322
  from indefinite_integral_continuous_left[OF * `e>0`] guess d . note d = this let ?d = "min d (b - c)"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4323
  show ?thesis apply(rule that[of "?d"])
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4324
  proof safe show "0 < ?d" using d(1) assms(3) by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4325
    fix t::"real" assume as:"c \<le> t" "t < c + ?d"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4326
    have *:"integral{a..c} f = integral{a..b} f - integral{c..b} f"
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  4327
      "integral{a..t} f = integral{a..b} f - integral{t..b} f" unfolding algebra_simps
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4328
      apply(rule_tac[!] integral_combine) using assms as by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4329
    have "(- c) - d < (- t) \<and> - t \<le> - c" using as by auto note d(2)[rule_format,OF this]
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4330
    thus "norm (integral {a..c} f - integral {a..t} f) < e" unfolding * 
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  4331
      unfolding integral_reflect apply-apply(subst norm_minus_commute) by(auto simp add:algebra_simps) qed qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4332
   
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4333
lemma indefinite_integral_continuous: fixes f::"real \<Rightarrow> 'a::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4334
  assumes "f integrable_on {a..b}" shows  "continuous_on {a..b} (\<lambda>x. integral {a..x} f)"
36359
e5c785c166b2 generalize type of continuous_on
huffman
parents: 36334
diff changeset
  4335
proof(unfold continuous_on_iff, safe)  fix x e assume as:"x\<in>{a..b}" "0<(e::real)"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4336
  let ?thesis = "\<exists>d>0. \<forall>x'\<in>{a..b}. dist x' x < d \<longrightarrow> dist (integral {a..x'} f) (integral {a..x} f) < e"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4337
  { presume *:"a<b \<Longrightarrow> ?thesis"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4338
    show ?thesis apply(cases,rule *,assumption)
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 38656
diff changeset
  4339
    proof- case goal1 hence "{a..b} = {x}" using as(1) apply-apply(rule set_eqI)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4340
        unfolding atLeastAtMost_iff by(auto simp only:field_simps not_less)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4341
      thus ?case using `e>0` by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4342
    qed } assume "a<b"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4343
  have "(x=a \<or> x=b) \<or> (a<x \<and> x<b)" using as(1) by (auto simp add:)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4344
  thus ?thesis apply-apply(erule disjE)+
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4345
  proof- assume "x=a" have "a \<le> a" by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4346
    from indefinite_integral_continuous_right[OF assms(1) this `a<b` `e>0`] guess d . note d=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4347
    show ?thesis apply(rule,rule,rule d,safe) apply(subst dist_commute)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4348
      unfolding `x=a` dist_norm apply(rule d(2)[rule_format]) by auto
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4349
  next   assume "x=b" have "b \<le> b" by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4350
    from indefinite_integral_continuous_left[OF assms(1) `a<b` this `e>0`] guess d . note d=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4351
    show ?thesis apply(rule,rule,rule d,safe) apply(subst dist_commute)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4352
      unfolding `x=b` dist_norm apply(rule d(2)[rule_format])  by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4353
  next assume "a<x \<and> x<b" hence xl:"a<x" "x\<le>b" and xr:"a\<le>x" "x<b" by(auto simp add: )
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4354
    from indefinite_integral_continuous_left [OF assms(1) xl `e>0`] guess d1 . note d1=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4355
    from indefinite_integral_continuous_right[OF assms(1) xr `e>0`] guess d2 . note d2=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4356
    show ?thesis apply(rule_tac x="min d1 d2" in exI)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4357
    proof safe show "0 < min d1 d2" using d1 d2 by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4358
      fix y assume "y\<in>{a..b}" "dist y x < min d1 d2"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4359
      thus "dist (integral {a..y} f) (integral {a..x} f) < e" apply-apply(subst dist_commute)
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4360
        apply(cases "y < x") unfolding dist_norm apply(rule d1(2)[rule_format]) defer
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4361
        apply(rule d2(2)[rule_format]) unfolding not_less by(auto simp add:field_simps)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4362
    qed qed qed 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4363
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4364
subsection {* This doesn't directly involve integration, but that gives an easy proof. *}
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4365
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4366
lemma has_derivative_zero_unique_strong_interval: fixes f::"real \<Rightarrow> 'a::banach"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4367
  assumes "finite k" "continuous_on {a..b} f" "f a = y"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4368
  "\<forall>x\<in>({a..b} - k). (f has_derivative (\<lambda>h. 0)) (at x within {a..b})" "x \<in> {a..b}"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4369
  shows "f x = y"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4370
proof- have ab:"a\<le>b" using assms by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4371
  have *:"a\<le>x" using assms(5) by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4372
  have "((\<lambda>x. 0\<Colon>'a) has_integral f x - f a) {a..x}"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4373
    apply(rule fundamental_theorem_of_calculus_interior_strong[OF assms(1) *])
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4374
    apply(rule continuous_on_subset[OF assms(2)]) defer
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4375
    apply safe unfolding has_vector_derivative_def apply(subst has_derivative_within_open[THEN sym])
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4376
    apply assumption apply(rule open_interval) apply(rule has_derivative_within_subset[where s="{a..b}"])
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4377
    using assms(4) assms(5) by auto note this[unfolded *]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4378
  note has_integral_unique[OF has_integral_0 this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4379
  thus ?thesis unfolding assms by auto qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4380
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4381
subsection {* Generalize a bit to any convex set. *}
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4382
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4383
lemma has_derivative_zero_unique_strong_convex: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4384
  assumes "convex s" "finite k" "continuous_on s f" "c \<in> s" "f c = y"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4385
  "\<forall>x\<in>(s - k). (f has_derivative (\<lambda>h. 0)) (at x within s)" "x \<in> s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4386
  shows "f x = y"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4387
proof- { presume *:"x \<noteq> c \<Longrightarrow> ?thesis" show ?thesis apply(cases,rule *,assumption)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4388
      unfolding assms(5)[THEN sym] by auto } assume "x\<noteq>c"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4389
  note conv = assms(1)[unfolded convex_alt,rule_format]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4390
  have as1:"continuous_on {0..1} (f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x))"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4391
    apply(rule continuous_on_intros)+ apply(rule continuous_on_subset[OF assms(3)])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4392
    apply safe apply(rule conv) using assms(4,7) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4393
  have *:"\<And>t xa. (1 - t) *\<^sub>R c + t *\<^sub>R x = (1 - xa) *\<^sub>R c + xa *\<^sub>R x \<Longrightarrow> t = xa"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4394
  proof- case goal1 hence "(t - xa) *\<^sub>R x = (t - xa) *\<^sub>R c" 
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  4395
      unfolding scaleR_simps by(auto simp add:algebra_simps)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4396
    thus ?case using `x\<noteq>c` by auto qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4397
  have as2:"finite {t. ((1 - t) *\<^sub>R c + t *\<^sub>R x) \<in> k}" using assms(2) 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4398
    apply(rule finite_surj[where f="\<lambda>z. SOME t. (1-t) *\<^sub>R c + t *\<^sub>R x = z"])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4399
    apply safe unfolding image_iff apply rule defer apply assumption
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4400
    apply(rule sym) apply(rule some_equality) defer apply(drule *) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4401
  have "(f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x)) 1 = y"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4402
    apply(rule has_derivative_zero_unique_strong_interval[OF as2 as1, of ])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4403
    unfolding o_def using assms(5) defer apply-apply(rule)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4404
  proof- fix t assume as:"t\<in>{0..1} - {t. (1 - t) *\<^sub>R c + t *\<^sub>R x \<in> k}"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4405
    have *:"c - t *\<^sub>R c + t *\<^sub>R x \<in> s - k" apply safe apply(rule conv[unfolded scaleR_simps]) 
36362
06475a1547cb fix lots of looping simp calls and other warnings
huffman
parents: 36359
diff changeset
  4406
      using `x\<in>s` `c\<in>s` as by(auto simp add: algebra_simps)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4407
    have "(f \<circ> (\<lambda>t. (1 - t) *\<^sub>R c + t *\<^sub>R x) has_derivative (\<lambda>x. 0) \<circ> (\<lambda>z. (0 - z *\<^sub>R c) + z *\<^sub>R x)) (at t within {0..1})"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4408
      apply(rule diff_chain_within) apply(rule has_derivative_add)
44140
2c10c35dd4be remove several redundant and unused theorems about derivatives
huffman
parents: 44125
diff changeset
  4409
      unfolding scaleR_simps
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: 51518
diff changeset
  4410
      apply(intro FDERIV_intros)
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: 51518
diff changeset
  4411
      apply(intro FDERIV_intros)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4412
      apply(rule has_derivative_within_subset,rule assms(6)[rule_format])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4413
      apply(rule *) apply safe apply(rule conv[unfolded scaleR_simps]) using `x\<in>s` `c\<in>s` by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4414
    thus "((\<lambda>xa. f ((1 - xa) *\<^sub>R c + xa *\<^sub>R x)) has_derivative (\<lambda>h. 0)) (at t within {0..1})" unfolding o_def .
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4415
  qed auto thus ?thesis by auto qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4416
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4417
subsection {* Also to any open connected set with finite set of exceptions. Could 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4418
 generalize to locally convex set with limpt-free set of exceptions. *}
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4419
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4420
lemma has_derivative_zero_unique_strong_connected: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4421
  assumes "connected s" "open s" "finite k" "continuous_on s f" "c \<in> s" "f c = y"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4422
  "\<forall>x\<in>(s - k). (f has_derivative (\<lambda>h. 0)) (at x within s)" "x\<in>s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4423
  shows "f x = y"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4424
proof- have "{x \<in> s. f x \<in> {y}} = {} \<or> {x \<in> s. f x \<in> {y}} = s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4425
    apply(rule assms(1)[unfolded connected_clopen,rule_format]) apply rule defer
41969
1cf3e4107a2a moved t2_spaces to HOL image
hoelzl
parents: 41958
diff changeset
  4426
    apply(rule continuous_closed_in_preimage[OF assms(4) closed_singleton])
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4427
    apply(rule open_openin_trans[OF assms(2)]) unfolding open_contains_ball
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4428
  proof safe fix x assume "x\<in>s" 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4429
    from assms(2)[unfolded open_contains_ball,rule_format,OF this] guess e .. note e=conjunctD2[OF this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4430
    show "\<exists>e>0. ball x e \<subseteq> {xa \<in> s. f xa \<in> {f x}}" apply(rule,rule,rule e)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4431
    proof safe fix y assume y:"y \<in> ball x e" thus "y\<in>s" using e by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4432
      show "f y = f x" apply(rule has_derivative_zero_unique_strong_convex[OF convex_ball])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4433
        apply(rule assms) apply(rule continuous_on_subset,rule assms) apply(rule e)+
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4434
        apply(subst centre_in_ball,rule e,rule) apply safe
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4435
        apply(rule has_derivative_within_subset) apply(rule assms(7)[rule_format])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4436
        using y e by auto qed qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4437
  thus ?thesis using `x\<in>s` `f c = y` `c\<in>s` by auto qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4438
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4439
subsection {* Integrating characteristic function of an interval. *}
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4440
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4441
lemma has_integral_restrict_open_subinterval: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4442
  assumes "(f has_integral i) {c..d}" "{c..d} \<subseteq> {a..b}"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4443
  shows "((\<lambda>x. if x \<in> {c<..<d} then f x else 0) has_integral i) {a..b}"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4444
proof- def g \<equiv> "\<lambda>x. if x \<in>{c<..<d} then f x else 0"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4445
  { presume *:"{c..d}\<noteq>{} \<Longrightarrow> ?thesis"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4446
    show ?thesis apply(cases,rule *,assumption)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4447
    proof- case goal1 hence *:"{c<..<d} = {}" using interval_open_subset_closed by auto 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4448
      show ?thesis using assms(1) unfolding * using goal1 by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4449
    qed } assume "{c..d}\<noteq>{}"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4450
  from partial_division_extend_1[OF assms(2) this] guess p . note p=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4451
  note mon = monoidal_lifted[OF monoidal_monoid] 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4452
  note operat = operative_division[OF this operative_integral p(1), THEN sym]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4453
  let ?P = "(if g integrable_on {a..b} then Some (integral {a..b} g) else None) = Some i"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4454
  { presume "?P" hence "g integrable_on {a..b} \<and> integral {a..b} g = i"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4455
      apply- apply(cases,subst(asm) if_P,assumption) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4456
    thus ?thesis using integrable_integral unfolding g_def by auto }
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4457
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4458
  note iterate_eq_neutral[OF mon,unfolded neutral_lifted[OF monoidal_monoid]]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4459
  note * = this[unfolded neutral_monoid]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4460
  have iterate:"iterate (lifted op +) (p - {{c..d}})
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4461
      (\<lambda>i. if g integrable_on i then Some (integral i g) else None) = Some 0"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4462
  proof(rule *,rule) case goal1 hence "x\<in>p" by auto note div = division_ofD(2-5)[OF p(1) this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4463
    from div(3) guess u v apply-by(erule exE)+ note uv=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4464
    have "interior x \<inter> interior {c..d} = {}" using div(4)[OF p(2)] goal1 by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4465
    hence "(g has_integral 0) x" unfolding uv apply-apply(rule has_integral_spike_interior[where f="\<lambda>x. 0"])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4466
      unfolding g_def interior_closed_interval by auto thus ?case by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4467
  qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4468
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4469
  have *:"p = insert {c..d} (p - {{c..d}})" using p by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4470
  have **:"g integrable_on {c..d}" apply(rule integrable_spike_interior[where f=f])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4471
    unfolding g_def defer apply(rule has_integral_integrable) using assms(1) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4472
  moreover have "integral {c..d} g = i" apply(rule has_integral_unique[OF _ assms(1)])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4473
    apply(rule has_integral_spike_interior[where f=g]) defer
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4474
    apply(rule integrable_integral[OF **]) unfolding g_def by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4475
  ultimately show ?P unfolding operat apply- apply(subst *) apply(subst iterate_insert) apply rule+
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4476
    unfolding iterate defer apply(subst if_not_P) defer using p by auto qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4477
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4478
lemma has_integral_restrict_closed_subinterval: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4479
  assumes "(f has_integral i) ({c..d})" "{c..d} \<subseteq> {a..b}" 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4480
  shows "((\<lambda>x. if x \<in> {c..d} then f x else 0) has_integral i) {a..b}"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4481
proof- note has_integral_restrict_open_subinterval[OF assms]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4482
  note * = has_integral_spike[OF negligible_frontier_interval _ this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4483
  show ?thesis apply(rule *[of c d]) using interval_open_subset_closed[of c d] by auto qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4484
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4485
lemma has_integral_restrict_closed_subintervals_eq: fixes f::"'a::ordered_euclidean_space \<Rightarrow> 'b::banach" assumes "{c..d} \<subseteq> {a..b}" 
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4486
  shows "((\<lambda>x. if x \<in> {c..d} then f x else 0) has_integral i) {a..b} \<longleftrightarrow> (f has_integral i) {c..d}" (is "?l = ?r")
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4487
proof(cases "{c..d} = {}") case False let ?g = "\<lambda>x. if x \<in> {c..d} then f x else 0"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4488
  show ?thesis apply rule defer apply(rule has_integral_restrict_closed_subinterval[OF _ assms])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4489
  proof assumption assume ?l hence "?g integrable_on {c..d}"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4490
      apply-apply(rule integrable_subinterval[OF _ assms]) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4491
    hence *:"f integrable_on {c..d}"apply-apply(rule integrable_eq) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4492
    hence "i = integral {c..d} f" apply-apply(rule has_integral_unique)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4493
      apply(rule `?l`) apply(rule has_integral_restrict_closed_subinterval[OF _ assms]) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4494
    thus ?r using * by auto qed qed auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4495
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4496
subsection {* Hence we can apply the limit process uniformly to all integrals. *}
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4497
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4498
lemma has_integral': fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4499
 "(f has_integral i) s \<longleftrightarrow> (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b}
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4500
  \<longrightarrow> (\<exists>z. ((\<lambda>x. if x \<in> s then f(x) else 0) has_integral z) {a..b} \<and> norm(z - i) < e))" (is "?l \<longleftrightarrow> (\<forall>e>0. ?r e)")
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4501
proof- { presume *:"\<exists>a b. s = {a..b} \<Longrightarrow> ?thesis"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4502
    show ?thesis apply(cases,rule *,assumption)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4503
      apply(subst has_integral_alt) by auto }
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4504
  assume "\<exists>a b. s = {a..b}" then guess a b apply-by(erule exE)+ note s=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4505
  from bounded_interval[of a b, THEN conjunct1, unfolded bounded_pos] guess B ..
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4506
  note B = conjunctD2[OF this,rule_format] show ?thesis apply safe
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4507
  proof- fix e assume ?l "e>(0::real)"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4508
    show "?r e" apply(rule_tac x="B+1" in exI) apply safe defer apply(rule_tac x=i in exI)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4509
    proof fix c d assume as:"ball 0 (B+1) \<subseteq> {c..d::'n::ordered_euclidean_space}"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4510
      thus "((\<lambda>x. if x \<in> s then f x else 0) has_integral i) {c..d}" unfolding s
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4511
        apply-apply(rule has_integral_restrict_closed_subinterval) apply(rule `?l`[unfolded s])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4512
        apply safe apply(drule B(2)[rule_format]) unfolding subset_eq apply(erule_tac x=x in ballE)
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4513
        by(auto simp add:dist_norm)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4514
    qed(insert B `e>0`, auto)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4515
  next assume as:"\<forall>e>0. ?r e" 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4516
    from this[rule_format,OF zero_less_one] guess C .. note C=conjunctD2[OF this,rule_format]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4517
    def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n::ordered_euclidean_space" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4518
    def d \<equiv> "(\<Sum>i\<in>Basis. max B C *\<^sub>R i)::'n::ordered_euclidean_space"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4519
    have c_d:"{a..b} \<subseteq> {c..d}" apply safe apply(drule B(2)) unfolding mem_interval
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4520
    proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4521
      case goal1 thus ?case using Basis_le_norm[OF `i\<in>Basis`, of x] unfolding c_def d_def
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4522
        by(auto simp add:field_simps setsum_negf)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4523
    qed
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4524
    have "ball 0 C \<subseteq> {c..d}" apply safe unfolding mem_interval mem_ball dist_norm 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4525
    proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4526
      case goal1 thus ?case
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4527
        using Basis_le_norm[OF `i\<in>Basis`, of x] unfolding c_def d_def by (auto simp: setsum_negf)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4528
    qed
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4529
    from C(2)[OF this] have "\<exists>y. (f has_integral y) {a..b}"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4530
      unfolding has_integral_restrict_closed_subintervals_eq[OF c_d,THEN sym] unfolding s by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4531
    then guess y .. note y=this
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4532
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4533
    have "y = i" proof(rule ccontr) assume "y\<noteq>i" hence "0 < norm (y - i)" by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4534
      from as[rule_format,OF this] guess C ..  note C=conjunctD2[OF this,rule_format]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4535
      def c \<equiv> "(\<Sum>i\<in>Basis. (- max B C) *\<^sub>R i)::'n::ordered_euclidean_space" 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4536
      def d \<equiv> "(\<Sum>i\<in>Basis. max B C *\<^sub>R i)::'n::ordered_euclidean_space"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4537
      have c_d:"{a..b} \<subseteq> {c..d}" apply safe apply(drule B(2)) unfolding mem_interval
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4538
      proof case goal1 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4539
          by(auto simp add:field_simps setsum_negf) qed
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4540
      have "ball 0 C \<subseteq> {c..d}" apply safe unfolding mem_interval mem_ball dist_norm 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4541
      proof case goal1 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def by (auto simp: setsum_negf) qed
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4542
      note C(2)[OF this] then guess z .. note z = conjunctD2[OF this, unfolded s]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4543
      note this[unfolded has_integral_restrict_closed_subintervals_eq[OF c_d]]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4544
      hence "z = y" "norm (z - i) < norm (y - i)" apply- apply(rule has_integral_unique[OF _ y(1)]) .
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4545
      thus False by auto qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4546
    thus ?l using y unfolding s by auto qed qed 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4547
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4548
lemma has_integral_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4549
  assumes "(f has_integral i) s" "(g has_integral j) s"  "\<forall>x\<in>s. (f x) \<le> (g x)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4550
  shows "i \<le> j"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4551
  using has_integral_component_le[OF _ assms(1-2), of 1] using assms(3) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4552
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4553
lemma integral_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4554
  assumes "f integrable_on s" "g integrable_on s" "\<forall>x\<in>s. f x \<le> g x"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4555
  shows "integral s f \<le> integral s g"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4556
  using has_integral_le[OF assms(1,2)[unfolded has_integral_integral] assms(3)] .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4557
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4558
lemma has_integral_nonneg: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4559
  assumes "(f has_integral i) s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> i" 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4560
  using has_integral_component_nonneg[of 1 f i s]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4561
  unfolding o_def using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4562
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4563
lemma integral_nonneg: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4564
  assumes "f integrable_on s" "\<forall>x\<in>s. 0 \<le> f x" shows "0 \<le> integral s f" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4565
  using has_integral_nonneg[OF assms(1)[unfolded has_integral_integral] assms(2)] .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4566
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4567
subsection {* Hence a general restriction property. *}
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4568
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4569
lemma has_integral_restrict[simp]: assumes "s \<subseteq> t" shows
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4570
  "((\<lambda>x. if x \<in> s then f x else (0::'a::banach)) has_integral i) t \<longleftrightarrow> (f has_integral i) s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4571
proof- have *:"\<And>x. (if x \<in> t then if x \<in> s then f x else 0 else 0) =  (if x\<in>s then f x else 0)" using assms by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4572
  show ?thesis apply(subst(2) has_integral') apply(subst has_integral') unfolding * by rule qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4573
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4574
lemma has_integral_restrict_univ: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4575
  "((\<lambda>x. if x \<in> s then f x else 0) has_integral i) UNIV \<longleftrightarrow> (f has_integral i) s" by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4576
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4577
lemma has_integral_on_superset: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" 
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4578
  assumes "\<forall>x. ~(x \<in> s) \<longrightarrow> f x = 0" "s \<subseteq> t" "(f has_integral i) s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4579
  shows "(f has_integral i) t"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4580
proof- have "(\<lambda>x. if x \<in> s then f x else 0) = (\<lambda>x. if x \<in> t then f x else 0)"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4581
    apply(rule) using assms(1-2) by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4582
  thus ?thesis apply- using assms(3) apply(subst has_integral_restrict_univ[THEN sym])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4583
  apply- apply(subst(asm) has_integral_restrict_univ[THEN sym]) by auto qed
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4584
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4585
lemma integrable_on_superset: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" 
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4586
  assumes "\<forall>x. ~(x \<in> s) \<longrightarrow> f x = 0" "s \<subseteq> t" "f integrable_on s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4587
  shows "f integrable_on t"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4588
  using assms unfolding integrable_on_def by(auto intro:has_integral_on_superset)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4589
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4590
lemma integral_restrict_univ[intro]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" 
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4591
  shows "f integrable_on s \<Longrightarrow> integral UNIV (\<lambda>x. if x \<in> s then f x else 0) = integral s f"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4592
  apply(rule integral_unique) unfolding has_integral_restrict_univ by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4593
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4594
lemma integrable_restrict_univ: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4595
 "(\<lambda>x. if x \<in> s then f x else 0) integrable_on UNIV \<longleftrightarrow> f integrable_on s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4596
  unfolding integrable_on_def by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4597
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4598
lemma negligible_on_intervals: "negligible s \<longleftrightarrow> (\<forall>a b. negligible(s \<inter> {a..b}))" (is "?l = ?r")
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4599
proof assume ?r show ?l unfolding negligible_def
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4600
  proof safe case goal1 show ?case apply(rule has_integral_negligible[OF `?r`[rule_format,of a b]])
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4601
      unfolding indicator_def by auto qed qed auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4602
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4603
lemma has_integral_spike_set_eq: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" 
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4604
  assumes "negligible((s - t) \<union> (t - s))" shows "((f has_integral y) s \<longleftrightarrow> (f has_integral y) t)"
49194
85116a86d99f tuned proofs;
wenzelm
parents: 48069
diff changeset
  4605
  unfolding has_integral_restrict_univ[THEN sym,of f] apply(rule has_integral_spike_eq[OF assms]) by (auto split: split_if_asm)
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4606
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4607
lemma has_integral_spike_set[dest]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4608
  assumes "negligible((s - t) \<union> (t - s))" "(f has_integral y) s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4609
  shows "(f has_integral y) t"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4610
  using assms has_integral_spike_set_eq by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4611
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4612
lemma integrable_spike_set[dest]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4613
  assumes "negligible((s - t) \<union> (t - s))" "f integrable_on s"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4614
  shows "f integrable_on t" using assms(2) unfolding integrable_on_def 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4615
  unfolding has_integral_spike_set_eq[OF assms(1)] .
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4616
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4617
lemma integrable_spike_set_eq: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4618
  assumes "negligible((s - t) \<union> (t - s))"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4619
  shows "(f integrable_on s \<longleftrightarrow> f integrable_on t)"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4620
  apply(rule,rule_tac[!] integrable_spike_set) using assms by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4621
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4622
(*lemma integral_spike_set:
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4623
 "\<forall>f:real^M->real^N g s t.
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4624
        negligible(s DIFF t \<union> t DIFF s)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4625
        \<longrightarrow> integral s f = integral t f"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4626
qed  REPEAT STRIP_TAC THEN REWRITE_TAC[integral] THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4627
  AP_TERM_TAC THEN ABS_TAC THEN MATCH_MP_TAC HAS_INTEGRAL_SPIKE_SET_EQ THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4628
  ASM_MESON_TAC[]);;
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4629
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4630
lemma has_integral_interior:
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4631
 "\<forall>f:real^M->real^N y s.
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4632
        negligible(frontier s)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4633
        \<longrightarrow> ((f has_integral y) (interior s) \<longleftrightarrow> (f has_integral y) s)"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4634
qed  REPEAT STRIP_TAC THEN MATCH_MP_TAC HAS_INTEGRAL_SPIKE_SET_EQ THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4635
  FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (REWRITE_RULE[IMP_CONJ]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4636
    NEGLIGIBLE_SUBSET)) THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4637
  REWRITE_TAC[frontier] THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4638
  MP_TAC(ISPEC `s:real^M->bool` INTERIOR_SUBSET) THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4639
  MP_TAC(ISPEC `s:real^M->bool` CLOSURE_SUBSET) THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4640
  SET_TAC[]);;
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4641
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4642
lemma has_integral_closure:
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4643
 "\<forall>f:real^M->real^N y s.
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4644
        negligible(frontier s)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4645
        \<longrightarrow> ((f has_integral y) (closure s) \<longleftrightarrow> (f has_integral y) s)"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4646
qed  REPEAT STRIP_TAC THEN MATCH_MP_TAC HAS_INTEGRAL_SPIKE_SET_EQ THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4647
  FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (REWRITE_RULE[IMP_CONJ]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4648
    NEGLIGIBLE_SUBSET)) THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4649
  REWRITE_TAC[frontier] THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4650
  MP_TAC(ISPEC `s:real^M->bool` INTERIOR_SUBSET) THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4651
  MP_TAC(ISPEC `s:real^M->bool` CLOSURE_SUBSET) THEN
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4652
  SET_TAC[]);;*)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4653
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4654
subsection {* More lemmas that are useful later. *}
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4655
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4656
lemma has_integral_subset_component_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4657
  assumes k: "k\<in>Basis" and as: "s \<subseteq> t" "(f has_integral i) s" "(f has_integral j) t" "\<forall>x\<in>t. 0 \<le> f(x)\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4658
  shows "i\<bullet>k \<le> j\<bullet>k"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4659
proof- note has_integral_restrict_univ[THEN sym, of f]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4660
  note as(2-3)[unfolded this] note * = has_integral_component_le[OF k this]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4661
  show ?thesis apply(rule *) using as(1,4) by auto qed
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4662
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4663
lemma has_integral_subset_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4664
  assumes as: "s \<subseteq> t" "(f has_integral i) s" "(f has_integral j) t" "\<forall>x\<in>t. 0 \<le> f(x)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4665
  shows "i \<le> j"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4666
  using has_integral_subset_component_le[OF _ assms(1), of 1 f i j] using assms by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4667
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4668
lemma integral_subset_component_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4669
  assumes "k\<in>Basis" "s \<subseteq> t" "f integrable_on s" "f integrable_on t" "\<forall>x \<in> t. 0 \<le> f(x)\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4670
  shows "(integral s f)\<bullet>k \<le> (integral t f)\<bullet>k"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4671
  apply(rule has_integral_subset_component_le) using assms by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4672
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4673
lemma integral_subset_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4674
  assumes "s \<subseteq> t" "f integrable_on s" "f integrable_on t" "\<forall>x \<in> t. 0 \<le> f(x)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4675
  shows "(integral s f) \<le> (integral t f)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4676
  apply(rule has_integral_subset_le) using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4677
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4678
lemma has_integral_alt': fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4679
  shows "(f has_integral i) s \<longleftrightarrow> (\<forall>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}) \<and>
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4680
  (\<forall>e>0. \<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow> norm(integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - i) < e)" (is "?l = ?r")
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4681
proof assume ?r
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4682
  show ?l apply- apply(subst has_integral')
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4683
  proof safe case goal1 from `?r`[THEN conjunct2,rule_format,OF this] guess B .. note B=conjunctD2[OF this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4684
    show ?case apply(rule,rule,rule B,safe)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4685
      apply(rule_tac x="integral {a..b} (\<lambda>x. if x \<in> s then f x else 0)" in exI)
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4686
      apply(drule B(2)[rule_format]) using integrable_integral[OF `?r`[THEN conjunct1,rule_format]] by auto
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4687
  qed next
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4688
  assume ?l note as = this[unfolded has_integral'[of f],rule_format]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4689
  let ?f = "\<lambda>x. if x \<in> s then f x else 0"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4690
  show ?r proof safe fix a b::"'n::ordered_euclidean_space"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4691
    from as[OF zero_less_one] guess B .. note B=conjunctD2[OF this,rule_format]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4692
    let ?a = "\<Sum>i\<in>Basis. min (a\<bullet>i) (-B) *\<^sub>R i::'n" and ?b = "\<Sum>i\<in>Basis. max (b\<bullet>i) B *\<^sub>R i::'n"
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4693
    show "?f integrable_on {a..b}" apply(rule integrable_subinterval[of _ ?a ?b])
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4694
    proof- have "ball 0 B \<subseteq> {?a..?b}" apply safe unfolding mem_ball mem_interval dist_norm
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4695
      proof case goal1 thus ?case using Basis_le_norm[of i x] by(auto simp add:field_simps) qed
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4696
      from B(2)[OF this] guess z .. note conjunct1[OF this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4697
      thus "?f integrable_on {?a..?b}" unfolding integrable_on_def by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4698
      show "{a..b} \<subseteq> {?a..?b}" apply safe unfolding mem_interval apply(rule,erule_tac x=i in ballE) by auto qed
35751
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4699
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4700
    fix e::real assume "e>0" from as[OF this] guess B .. note B=conjunctD2[OF this,rule_format]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4701
    show "\<exists>B>0. \<forall>a b. ball 0 B \<subseteq> {a..b} \<longrightarrow>
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4702
                    norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - i) < e"
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4703
    proof(rule,rule,rule B,safe) case goal1 from B(2)[OF this] guess z .. note z=conjunctD2[OF this]
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4704
      from integral_unique[OF this(1)] show ?case using z(2) by auto qed qed qed 
f7f8d59b60b9 added lemmas
himmelma
parents: 35540
diff changeset
  4705
35752
c8a8df426666 reset smt_certificates
himmelma
parents: 35751
diff changeset
  4706
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4707
subsection {* Continuity of the integral (for a 1-dimensional interval). *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4708
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4709
lemma integrable_alt: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows 
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4710
  "f integrable_on s \<longleftrightarrow>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4711
          (\<forall>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}) \<and>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4712
          (\<forall>e>0. \<exists>B>0. \<forall>a b c d. ball 0 B \<subseteq> {a..b} \<and> ball 0 B \<subseteq> {c..d}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4713
  \<longrightarrow> norm(integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) -
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4714
          integral {c..d}  (\<lambda>x. if x \<in> s then f x else 0)) < e)" (is "?l = ?r")
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4715
proof assume ?l then guess y unfolding integrable_on_def .. note this[unfolded has_integral_alt'[of f]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4716
  note y=conjunctD2[OF this,rule_format] show ?r apply safe apply(rule y)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4717
  proof- case goal1 hence "e/2 > 0" by auto from y(2)[OF this] guess B .. note B=conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4718
    show ?case apply(rule,rule,rule B)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4719
    proof safe case goal1 show ?case apply(rule norm_triangle_half_l)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4720
        using B(2)[OF goal1(1)] B(2)[OF goal1(2)] by auto qed qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4721
        
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4722
next assume ?r note as = conjunctD2[OF this,rule_format]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4723
  let ?cube = "\<lambda>n. {(\<Sum>i\<in>Basis. - real n *\<^sub>R i)::'n .. (\<Sum>i\<in>Basis. real n *\<^sub>R i)} :: 'n set"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4724
  have "Cauchy (\<lambda>n. integral (?cube n) (\<lambda>x. if x \<in> s then f x else 0))"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4725
  proof(unfold Cauchy_def,safe) case goal1
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4726
    from as(2)[OF this] guess B .. note B = conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4727
    from real_arch_simple[of B] guess N .. note N = this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4728
    { fix n assume n:"n \<ge> N" have "ball 0 B \<subseteq> ?cube n" apply safe
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4729
        unfolding mem_ball mem_interval dist_norm
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4730
      proof case goal1 thus ?case using Basis_le_norm[of i x] `i\<in>Basis`
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4731
          using n N by(auto simp add:field_simps setsum_negf) qed }
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36365
diff changeset
  4732
    thus ?case apply-apply(rule_tac x=N in exI) apply safe unfolding dist_norm apply(rule B(2)) by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4733
  qed from this[unfolded convergent_eq_cauchy[THEN sym]] guess i ..
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  4734
  note i = this[THEN LIMSEQ_D]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4735
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4736
  show ?l unfolding integrable_on_def has_integral_alt'[of f] apply(rule_tac x=i in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4737
    apply safe apply(rule as(1)[unfolded integrable_on_def])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4738
  proof- case goal1 hence *:"e/2 > 0" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4739
    from i[OF this] guess N .. note N =this[rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4740
    from as(2)[OF *] guess B .. note B=conjunctD2[OF this,rule_format] let ?B = "max (real N) B"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4741
    show ?case apply(rule_tac x="?B" in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4742
    proof safe show "0 < ?B" using B(1) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4743
      fix a b assume ab:"ball 0 ?B \<subseteq> {a..b::'n::ordered_euclidean_space}"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4744
      from real_arch_simple[of ?B] guess n .. note n=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4745
      show "norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - i) < e"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4746
        apply(rule norm_triangle_half_l) apply(rule B(2)) defer apply(subst norm_minus_commute)
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  4747
        apply(rule N[of n])
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4748
      proof safe show "N \<le> n" using n by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4749
        fix x::"'n::ordered_euclidean_space" assume x:"x \<in> ball 0 B" hence "x\<in> ball 0 ?B" by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4750
        thus "x\<in>{a..b}" using ab by blast 
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4751
        show "x\<in>?cube n" using x unfolding mem_interval mem_ball dist_norm apply-
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4752
        proof case goal1 thus ?case using Basis_le_norm[of i x] `i\<in>Basis`
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4753
            using n by(auto simp add:field_simps setsum_negf) qed qed qed qed qed
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4754
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4755
lemma integrable_altD: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4756
  assumes "f integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4757
  shows "\<And>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4758
  "\<And>e. e>0 \<Longrightarrow> \<exists>B>0. \<forall>a b c d. ball 0 B \<subseteq> {a..b} \<and> ball 0 B \<subseteq> {c..d}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4759
  \<longrightarrow> norm(integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - integral {c..d}  (\<lambda>x. if x \<in> s then f x else 0)) < e"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4760
  using assms[unfolded integrable_alt[of f]] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4761
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4762
lemma integrable_on_subinterval: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4763
  assumes "f integrable_on s" "{a..b} \<subseteq> s" shows "f integrable_on {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4764
  apply(rule integrable_eq) defer apply(rule integrable_altD(1)[OF assms(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4765
  using assms(2) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4766
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4767
subsection {* A straddling criterion for integrability. *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4768
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4769
lemma integrable_straddle_interval: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4770
  assumes "\<forall>e>0. \<exists>g  h i j. (g has_integral i) ({a..b}) \<and> (h has_integral j) ({a..b}) \<and>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4771
  norm(i - j) < e \<and> (\<forall>x\<in>{a..b}. (g x) \<le> (f x) \<and> (f x) \<le>(h x))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4772
  shows "f integrable_on {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4773
proof(subst integrable_cauchy,safe)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4774
  case goal1 hence e:"e/3 > 0" by auto note assms[rule_format,OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4775
  then guess g h i j apply- by(erule exE conjE)+ note obt = this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4776
  from obt(1)[unfolded has_integral[of g], rule_format, OF e] guess d1 .. note d1=conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4777
  from obt(2)[unfolded has_integral[of h], rule_format, OF e] guess d2 .. note d2=conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4778
  show ?case apply(rule_tac x="\<lambda>x. d1 x \<inter> d2 x" in exI) apply(rule conjI gauge_inter d1 d2)+ unfolding fine_inter
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4779
  proof safe have **:"\<And>i j g1 g2 h1 h2 f1 f2. g1 - h2 \<le> f1 - f2 \<Longrightarrow> f1 - f2 \<le> h1 - g2 \<Longrightarrow>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4780
      abs(i - j) < e / 3 \<Longrightarrow> abs(g2 - i) < e / 3 \<Longrightarrow>  abs(g1 - i) < e / 3 \<Longrightarrow> 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4781
      abs(h2 - j) < e / 3 \<Longrightarrow> abs(h1 - j) < e / 3 \<Longrightarrow> abs(f1 - f2) < e" using `e>0` by arith
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4782
    case goal1 note tagged_division_ofD(2-4) note * = this[OF goal1(1)] this[OF goal1(4)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4783
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4784
    have "(\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p1. content k *\<^sub>R g x) \<ge> 0"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4785
      "0 \<le> (\<Sum>(x, k)\<in>p2. content k *\<^sub>R h x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x)" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4786
      "(\<Sum>(x, k)\<in>p2. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p2. content k *\<^sub>R g x) \<ge> 0"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4787
      "0 \<le> (\<Sum>(x, k)\<in>p1. content k *\<^sub>R h x) - (\<Sum>(x, k)\<in>p1. content k *\<^sub>R f x)" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4788
      unfolding setsum_subtractf[THEN sym] apply- apply(rule_tac[!] setsum_nonneg)
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  4789
      apply safe unfolding real_scaleR_def right_diff_distrib[THEN sym]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4790
      apply(rule_tac[!] mult_nonneg_nonneg)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4791
    proof- fix a b assume ab:"(a,b) \<in> p1"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4792
      show "0 \<le> content b" using *(3)[OF ab] apply safe using content_pos_le . thus "0 \<le> content b" .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4793
      show "0 \<le> f a - g a" "0 \<le> h a - f a" using *(1-2)[OF ab] using obt(4)[rule_format,of a] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4794
    next fix a b assume ab:"(a,b) \<in> p2"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4795
      show "0 \<le> content b" using *(6)[OF ab] apply safe using content_pos_le . thus "0 \<le> content b" .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4796
      show "0 \<le> f a - g a" "0 \<le> h a - f a" using *(4-5)[OF ab] using obt(4)[rule_format,of a] by auto qed 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4797
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4798
    thus ?case apply- unfolding real_norm_def apply(rule **) defer defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4799
      unfolding real_norm_def[THEN sym] apply(rule obt(3))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4800
      apply(rule d1(2)[OF conjI[OF goal1(4,5)]])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4801
      apply(rule d1(2)[OF conjI[OF goal1(1,2)]])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4802
      apply(rule d2(2)[OF conjI[OF goal1(4,6)]])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4803
      apply(rule d2(2)[OF conjI[OF goal1(1,3)]]) by auto qed qed 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4804
     
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4805
lemma integrable_straddle: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4806
  assumes "\<forall>e>0. \<exists>g h i j. (g has_integral i) s \<and> (h has_integral j) s \<and>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4807
  norm(i - j) < e \<and> (\<forall>x\<in>s. (g x) \<le>(f x) \<and>(f x) \<le>(h x))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4808
  shows "f integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4809
proof- have "\<And>a b. (\<lambda>x. if x \<in> s then f x else 0) integrable_on {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4810
  proof(rule integrable_straddle_interval,safe) case goal1 hence *:"e/4 > 0" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4811
    from assms[rule_format,OF this] guess g h i j apply-by(erule exE conjE)+ note obt=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4812
    note obt(1)[unfolded has_integral_alt'[of g]] note conjunctD2[OF this, rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4813
    note g = this(1) and this(2)[OF *] from this(2) guess B1 .. note B1 = conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4814
    note obt(2)[unfolded has_integral_alt'[of h]] note conjunctD2[OF this, rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4815
    note h = this(1) and this(2)[OF *] from this(2) guess B2 .. note B2 = conjunctD2[OF this,rule_format]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4816
    def c \<equiv> "\<Sum>i\<in>Basis. min (a\<bullet>i) (- (max B1 B2)) *\<^sub>R i::'n"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4817
    def d \<equiv> "\<Sum>i\<in>Basis. max (b\<bullet>i) (max B1 B2) *\<^sub>R i::'n"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4818
    have *:"ball 0 B1 \<subseteq> {c..d}" "ball 0 B2 \<subseteq> {c..d}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4819
      apply safe unfolding mem_ball mem_interval dist_norm
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4820
    proof(rule_tac[!] ballI)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4821
      case goal1 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def by auto next
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4822
      case goal2 thus ?case using Basis_le_norm[of i x] unfolding c_def d_def by auto qed
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4823
    have **:"\<And>ch cg ag ah::real. norm(ah - ag) \<le> norm(ch - cg) \<Longrightarrow> norm(cg - i) < e / 4 \<Longrightarrow>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4824
      norm(ch - j) < e / 4 \<Longrightarrow> norm(ag - ah) < e"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4825
      using obt(3) unfolding real_norm_def by arith 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4826
    show ?case apply(rule_tac x="\<lambda>x. if x \<in> s then g x else 0" in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4827
               apply(rule_tac x="\<lambda>x. if x \<in> s then h x else 0" in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4828
      apply(rule_tac x="integral {a..b} (\<lambda>x. if x \<in> s then g x else 0)" in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4829
      apply(rule_tac x="integral {a..b} (\<lambda>x. if x \<in> s then h x else 0)" in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4830
      apply safe apply(rule_tac[1-2] integrable_integral,rule g,rule h)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4831
      apply(rule **[OF _ B1(2)[OF *(1)] B2(2)[OF *(2)]])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4832
    proof- have *:"\<And>x f g. (if x \<in> s then f x else 0) - (if x \<in> s then g x else 0) =
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4833
        (if x \<in> s then f x - g x else (0::real))" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4834
      note ** = abs_of_nonneg[OF integral_nonneg[OF integrable_sub, OF h g]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4835
      show " norm (integral {a..b} (\<lambda>x. if x \<in> s then h x else 0) -
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4836
                   integral {a..b} (\<lambda>x. if x \<in> s then g x else 0))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4837
           \<le> norm (integral {c..d} (\<lambda>x. if x \<in> s then h x else 0) -
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4838
                   integral {c..d} (\<lambda>x. if x \<in> s then g x else 0))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4839
        unfolding integral_sub[OF h g,THEN sym] real_norm_def apply(subst **) defer apply(subst **) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4840
        apply(rule has_integral_subset_le) defer apply(rule integrable_integral integrable_sub h g)+
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4841
      proof safe fix x assume "x\<in>{a..b}" thus "x\<in>{c..d}" unfolding mem_interval c_def d_def
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  4842
          apply - apply rule apply(erule_tac x=i in ballE) by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4843
      qed(insert obt(4), auto) qed(insert obt(4), auto) qed note interv = this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4844
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4845
  show ?thesis unfolding integrable_alt[of f] apply safe apply(rule interv)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4846
  proof- case goal1 hence *:"e/3 > 0" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4847
    from assms[rule_format,OF this] guess g h i j apply-by(erule exE conjE)+ note obt=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4848
    note obt(1)[unfolded has_integral_alt'[of g]] note conjunctD2[OF this, rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4849
    note g = this(1) and this(2)[OF *] from this(2) guess B1 .. note B1 = conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4850
    note obt(2)[unfolded has_integral_alt'[of h]] note conjunctD2[OF this, rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4851
    note h = this(1) and this(2)[OF *] from this(2) guess B2 .. note B2 = conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4852
    show ?case apply(rule_tac x="max B1 B2" in exI) apply safe apply(rule min_max.less_supI1,rule B1)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4853
    proof- fix a b c d::"'n::ordered_euclidean_space" assume as:"ball 0 (max B1 B2) \<subseteq> {a..b}" "ball 0 (max B1 B2) \<subseteq> {c..d}"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4854
      have **:"ball 0 B1 \<subseteq> ball (0::'n::ordered_euclidean_space) (max B1 B2)" "ball 0 B2 \<subseteq> ball (0::'n::ordered_euclidean_space) (max B1 B2)" by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4855
      have *:"\<And>ga gc ha hc fa fc::real. abs(ga - i) < e / 3 \<and> abs(gc - i) < e / 3 \<and> abs(ha - j) < e / 3 \<and>
50348
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  4856
        abs(hc - j) < e / 3 \<and> abs(i - j) < e / 3 \<and> ga \<le> fa \<and> fa \<le> ha \<and> gc \<le> fc \<and> fc \<le> hc\<Longrightarrow> abs(fa - fc) < e"
4b4fe0d5ee22 remove SMT proofs in Multivariate_Analysis
hoelzl
parents: 50252
diff changeset
  4857
        by (simp add: abs_real_def split: split_if_asm)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4858
      show "norm (integral {a..b} (\<lambda>x. if x \<in> s then f x else 0) - integral {c..d} (\<lambda>x. if x \<in> s then f x else 0)) < e"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4859
        unfolding real_norm_def apply(rule *, safe) unfolding real_norm_def[THEN sym]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4860
        apply(rule B1(2),rule order_trans,rule **,rule as(1)) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4861
        apply(rule B1(2),rule order_trans,rule **,rule as(2)) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4862
        apply(rule B2(2),rule order_trans,rule **,rule as(1)) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4863
        apply(rule B2(2),rule order_trans,rule **,rule as(2)) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4864
        apply(rule obt) apply(rule_tac[!] integral_le) using obt
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4865
        by(auto intro!: h g interv) qed qed qed 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4866
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4867
subsection {* Adding integrals over several sets. *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4868
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4869
lemma has_integral_union: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4870
  assumes "(f has_integral i) s" "(f has_integral j) t" "negligible(s \<inter> t)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4871
  shows "(f has_integral (i + j)) (s \<union> t)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4872
proof- note * = has_integral_restrict_univ[THEN sym, of f]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4873
  show ?thesis unfolding * apply(rule has_integral_spike[OF assms(3)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4874
    defer apply(rule has_integral_add[OF assms(1-2)[unfolded *]]) by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4875
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4876
lemma has_integral_unions: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4877
  assumes "finite t" "\<forall>s\<in>t. (f has_integral (i s)) s"  "\<forall>s\<in>t. \<forall>s'\<in>t. ~(s = s') \<longrightarrow> negligible(s \<inter> s')"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4878
  shows "(f has_integral (setsum i t)) (\<Union>t)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4879
proof- note * = has_integral_restrict_univ[THEN sym, of f]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4880
  have **:"negligible (\<Union>((\<lambda>(a,b). a \<inter> b) ` {(a,b). a \<in> t \<and> b \<in> {y. y \<in> t \<and> ~(a = y)}}))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4881
    apply(rule negligible_unions) apply(rule finite_imageI) apply(rule finite_subset[of _ "t \<times> t"]) defer 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4882
    apply(rule finite_cartesian_product[OF assms(1,1)]) using assms(3) by auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4883
  note assms(2)[unfolded *] note has_integral_setsum[OF assms(1) this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4884
  thus ?thesis unfolding * apply-apply(rule has_integral_spike[OF **]) defer apply assumption
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4885
  proof safe case goal1 thus ?case
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4886
    proof(cases "x\<in>\<Union>t") case True then guess s unfolding Union_iff .. note s=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4887
      hence *:"\<forall>b\<in>t. x \<in> b \<longleftrightarrow> b = s" using goal1(3) by blast
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4888
      show ?thesis unfolding if_P[OF True] apply(rule trans) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4889
        apply(rule setsum_cong2) apply(subst *, assumption) apply(rule refl)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4890
        unfolding setsum_delta[OF assms(1)] using s by auto qed auto qed qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4891
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4892
subsection {* In particular adding integrals over a division, maybe not of an interval. *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4893
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4894
lemma has_integral_combine_division: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4895
  assumes "d division_of s" "\<forall>k\<in>d. (f has_integral (i k)) k"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4896
  shows "(f has_integral (setsum i d)) s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4897
proof- note d = division_ofD[OF assms(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4898
  show ?thesis unfolding d(6)[THEN sym] apply(rule has_integral_unions)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4899
    apply(rule d assms)+ apply(rule,rule,rule)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4900
  proof- case goal1 from d(4)[OF this(1)] d(4)[OF this(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4901
    guess a c b d apply-by(erule exE)+ note obt=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4902
    from d(5)[OF goal1] show ?case unfolding obt interior_closed_interval
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4903
      apply-apply(rule negligible_subset[of "({a..b}-{a<..<b}) \<union> ({c..d}-{c<..<d})"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4904
      apply(rule negligible_union negligible_frontier_interval)+ by auto qed qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4905
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4906
lemma integral_combine_division_bottomup: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4907
  assumes "d division_of s" "\<forall>k\<in>d. f integrable_on k"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4908
  shows "integral s f = setsum (\<lambda>i. integral i f) d"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4909
  apply(rule integral_unique) apply(rule has_integral_combine_division[OF assms(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4910
  using assms(2) unfolding has_integral_integral .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4911
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4912
lemma has_integral_combine_division_topdown: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4913
  assumes "f integrable_on s" "d division_of k" "k \<subseteq> s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4914
  shows "(f has_integral (setsum (\<lambda>i. integral i f) d)) k"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4915
  apply(rule has_integral_combine_division[OF assms(2)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4916
  apply safe unfolding has_integral_integral[THEN sym]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4917
proof- case goal1 from division_ofD(2,4)[OF assms(2) this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4918
  show ?case apply safe apply(rule integrable_on_subinterval)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4919
    apply(rule assms) using assms(3) by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4920
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4921
lemma integral_combine_division_topdown: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4922
  assumes "f integrable_on s" "d division_of s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4923
  shows "integral s f = setsum (\<lambda>i. integral i f) d"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4924
  apply(rule integral_unique,rule has_integral_combine_division_topdown) using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4925
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4926
lemma integrable_combine_division: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4927
  assumes "d division_of s" "\<forall>i\<in>d. f integrable_on i"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4928
  shows "f integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4929
  using assms(2) unfolding integrable_on_def
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4930
  by(metis has_integral_combine_division[OF assms(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4931
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4932
lemma integrable_on_subdivision: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4933
  assumes "d division_of i" "f integrable_on s" "i \<subseteq> s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4934
  shows "f integrable_on i"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4935
  apply(rule integrable_combine_division assms)+
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4936
proof safe case goal1 note division_ofD(2,4)[OF assms(1) this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4937
  thus ?case apply safe apply(rule integrable_on_subinterval[OF assms(2)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4938
    using assms(3) by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4939
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4940
subsection {* Also tagged divisions. *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4941
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4942
lemma has_integral_combine_tagged_division: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4943
  assumes "p tagged_division_of s" "\<forall>(x,k) \<in> p. (f has_integral (i k)) k"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4944
  shows "(f has_integral (setsum (\<lambda>(x,k). i k) p)) s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4945
proof- have *:"(f has_integral (setsum (\<lambda>k. integral k f) (snd ` p))) s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4946
    apply(rule has_integral_combine_division) apply(rule division_of_tagged_division[OF assms(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4947
    using assms(2) unfolding has_integral_integral[THEN sym] by(safe,auto)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4948
  thus ?thesis apply- apply(rule subst[where P="\<lambda>i. (f has_integral i) s"]) defer apply assumption
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4949
    apply(rule trans[of _ "setsum (\<lambda>(x,k). integral k f) p"]) apply(subst eq_commute)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4950
    apply(rule setsum_over_tagged_division_lemma[OF assms(1)]) apply(rule integral_null,assumption)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4951
    apply(rule setsum_cong2) using assms(2) by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4952
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4953
lemma integral_combine_tagged_division_bottomup: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4954
  assumes "p tagged_division_of {a..b}" "\<forall>(x,k)\<in>p. f integrable_on k"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4955
  shows "integral {a..b} f = setsum (\<lambda>(x,k). integral k f) p"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4956
  apply(rule integral_unique) apply(rule has_integral_combine_tagged_division[OF assms(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4957
  using assms(2) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4958
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4959
lemma has_integral_combine_tagged_division_topdown: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4960
  assumes "f integrable_on {a..b}" "p tagged_division_of {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4961
  shows "(f has_integral (setsum (\<lambda>(x,k). integral k f) p)) {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4962
  apply(rule has_integral_combine_tagged_division[OF assms(2)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4963
proof safe case goal1 note tagged_division_ofD(3-4)[OF assms(2) this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4964
  thus ?case using integrable_subinterval[OF assms(1)] by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4965
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4966
lemma integral_combine_tagged_division_topdown: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4967
  assumes "f integrable_on {a..b}" "p tagged_division_of {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4968
  shows "integral {a..b} f = setsum (\<lambda>(x,k). integral k f) p"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4969
  apply(rule integral_unique,rule has_integral_combine_tagged_division_topdown) using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4970
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4971
subsection {* Henstock's lemma. *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4972
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  4973
lemma henstock_lemma_part1: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4974
  assumes "f integrable_on {a..b}" "0 < e" "gauge d"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4975
  "(\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p - integral({a..b}) f) < e)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4976
  and p:"p tagged_partial_division_of {a..b}" "d fine p"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4977
  shows "norm(setsum (\<lambda>(x,k). content k *\<^sub>R f x - integral k f) p) \<le> e" (is "?x \<le> e")
41863
e5104b436ea1 removed dependency on Dense_Linear_Order
boehmes
parents: 41851
diff changeset
  4978
proof-  { presume "\<And>k. 0<k \<Longrightarrow> ?x \<le> e + k" thus ?thesis by (blast intro: field_le_epsilon) }
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4979
  fix k::real assume k:"k>0" note p' = tagged_partial_division_ofD[OF p(1)]
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  4980
  have "\<Union>(snd ` p) \<subseteq> {a..b}" using p'(3) by fastforce
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4981
  note partial_division_of_tagged_division[OF p(1)] this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4982
  from partial_division_extend_interval[OF this] guess q . note q=this and q' = division_ofD[OF this(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4983
  def r \<equiv> "q - snd ` p" have "snd ` p \<inter> r = {}" unfolding r_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4984
  have r:"finite r" using q' unfolding r_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4985
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4986
  have "\<forall>i\<in>r. \<exists>p. p tagged_division_of i \<and> d fine p \<and>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4987
    norm(setsum (\<lambda>(x,j). content j *\<^sub>R f x) p - integral i f) < k / (real (card r) + 1)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4988
  proof safe case goal1 hence i:"i \<in> q" unfolding r_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4989
    from q'(4)[OF this] guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4990
    have *:"k / (real (card r) + 1) > 0" apply(rule divide_pos_pos,rule k) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4991
    have "f integrable_on {u..v}" apply(rule integrable_subinterval[OF assms(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4992
      using q'(2)[OF i] unfolding uv by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4993
    note integrable_integral[OF this, unfolded has_integral[of f]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4994
    from this[rule_format,OF *] guess dd .. note dd=conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4995
    note gauge_inter[OF `gauge d` dd(1)] from fine_division_exists[OF this,of u v] guess qq .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4996
    thus ?case apply(rule_tac x=qq in exI) using dd(2)[of qq] unfolding fine_inter uv by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4997
  from bchoice[OF this] guess qq .. note qq=this[rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  4998
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  4999
  let ?p = "p \<union> \<Union>(qq ` r)" have "norm ((\<Sum>(x, k)\<in>?p. content k *\<^sub>R f x) - integral {a..b} f) < e"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5000
    apply(rule assms(4)[rule_format])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5001
  proof show "d fine ?p" apply(rule fine_union,rule p) apply(rule fine_unions) using qq by auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5002
    note * = tagged_partial_division_of_union_self[OF p(1)]
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  5003
    have "p \<union> \<Union>(qq ` r) tagged_division_of \<Union>(snd ` p) \<union> \<Union>r"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5004
    proof(rule tagged_division_union[OF * tagged_division_unions])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5005
      show "finite r" by fact case goal2 thus ?case using qq by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5006
    next case goal3 thus ?case apply(rule,rule,rule) apply(rule q'(5)) unfolding r_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5007
    next case goal4 thus ?case apply(rule inter_interior_unions_intervals) apply(fact,rule)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5008
        apply(rule,rule q') defer apply(rule,subst Int_commute) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5009
        apply(rule inter_interior_unions_intervals) apply(rule finite_imageI,rule p',rule) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5010
        apply(rule,rule q') using q(1) p' unfolding r_def by auto qed
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  5011
    moreover have "\<Union>(snd ` p) \<union> \<Union>r = {a..b}" "{qq i |i. i \<in> r} = qq ` r"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5012
      unfolding Union_Un_distrib[THEN sym] r_def using q by auto
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 44522
diff changeset
  5013
    ultimately show "?p tagged_division_of {a..b}" by fastforce qed
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5014
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 51642
diff changeset
  5015
  hence "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + (\<Sum>(x, k)\<in>\<Union>(qq ` r). content k *\<^sub>R f x) -
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5016
    integral {a..b} f) < e" apply(subst setsum_Un_zero[THEN sym]) apply(rule p') prefer 3 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5017
    apply assumption apply rule apply(rule finite_imageI,rule r) apply safe apply(drule qq)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5018
  proof- fix x l k assume as:"(x,l)\<in>p" "(x,l)\<in>qq k" "k\<in>r"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5019
    note qq[OF this(3)] note tagged_division_ofD(3,4)[OF conjunct1[OF this] as(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5020
    from this(2) guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5021
    have "l\<in>snd ` p" unfolding image_iff apply(rule_tac x="(x,l)" in bexI) using as by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5022
    hence "l\<in>q" "k\<in>q" "l\<noteq>k" using as(1,3) q(1) unfolding r_def by auto
44522
2f7e9d890efe rename subset_{interior,closure} to {interior,closure}_mono;
huffman
parents: 44514
diff changeset
  5023
    note q'(5)[OF this] hence "interior l = {}" using interior_mono[OF `l \<subseteq> k`] by blast
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5024
    thus "content l *\<^sub>R f x = 0" unfolding uv content_eq_0_interior[THEN sym] by auto qed auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5025
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5026
  hence "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + setsum (setsum (\<lambda>(x, k). content k *\<^sub>R f x))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5027
    (qq ` r) - integral {a..b} f) < e" apply(subst(asm) setsum_UNION_zero)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5028
    prefer 4 apply assumption apply(rule finite_imageI,fact)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5029
    unfolding split_paired_all split_conv image_iff defer apply(erule bexE)+
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5030
  proof- fix x m k l T1 T2 assume "(x,m)\<in>T1" "(x,m)\<in>T2" "T1\<noteq>T2" "k\<in>r" "l\<in>r" "T1 = qq k" "T2 = qq l"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5031
    note as = this(1-5)[unfolded this(6-)] note kl = tagged_division_ofD(3,4)[OF qq[THEN conjunct1]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5032
    from this(2)[OF as(4,1)] guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5033
    have *:"interior (k \<inter> l) = {}" unfolding interior_inter apply(rule q')
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5034
      using as unfolding r_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5035
    have "interior m = {}" unfolding subset_empty[THEN sym] unfolding *[THEN sym]
44522
2f7e9d890efe rename subset_{interior,closure} to {interior,closure}_mono;
huffman
parents: 44514
diff changeset
  5036
      apply(rule interior_mono) using kl(1)[OF as(4,1)] kl(1)[OF as(5,2)] by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5037
    thus "content m *\<^sub>R f x = 0" unfolding uv content_eq_0_interior[THEN sym] by auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5038
  qed(insert qq, auto)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5039
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5040
  hence **:"norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) + setsum (setsum (\<lambda>(x, k). content k *\<^sub>R f x) \<circ> qq) r -
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5041
    integral {a..b} f) < e" apply(subst(asm) setsum_reindex_nonzero) apply fact
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5042
    apply(rule setsum_0',rule) unfolding split_paired_all split_conv defer apply assumption
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5043
  proof- fix k l x m assume as:"k\<in>r" "l\<in>r" "k\<noteq>l" "qq k = qq l" "(x,m)\<in>qq k"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5044
    note tagged_division_ofD(6)[OF qq[THEN conjunct1]] from this[OF as(1)] this[OF as(2)] 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5045
    show "content m *\<^sub>R f x = 0"  using as(3) unfolding as by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5046
  
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5047
  have *:"\<And>ir ip i cr cp. norm((cp + cr) - i) < e \<Longrightarrow> norm(cr - ir) < k \<Longrightarrow> 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5048
    ip + ir = i \<Longrightarrow> norm(cp - ip) \<le> e + k" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5049
  proof- case goal1 thus ?case  using norm_triangle_le[of "cp + cr - i" "- (cr - ir)"]  
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  5050
      unfolding goal1(3)[THEN sym] norm_minus_cancel by(auto simp add:algebra_simps) qed
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5051
  
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5052
  have "?x =  norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - (\<Sum>(x, k)\<in>p. integral k f))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5053
    unfolding split_def setsum_subtractf ..
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5054
  also have "... \<le> e + k" apply(rule *[OF **, where ir="setsum (\<lambda>k. integral k f) r"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5055
  proof- case goal2 have *:"(\<Sum>(x, k)\<in>p. integral k f) = (\<Sum>k\<in>snd ` p. integral k f)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5056
      apply(subst setsum_reindex_nonzero) apply fact
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5057
      unfolding split_paired_all snd_conv split_def o_def
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5058
    proof- fix x l y m assume as:"(x,l)\<in>p" "(y,m)\<in>p" "(x,l)\<noteq>(y,m)" "l = m"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5059
      from p'(4)[OF as(1)] guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5060
      show "integral l f = 0" unfolding uv apply(rule integral_unique)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5061
        apply(rule has_integral_null) unfolding content_eq_0_interior
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5062
        using p'(5)[OF as(1-3)] unfolding uv as(4)[THEN sym] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5063
    qed auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5064
    show ?case unfolding integral_combine_division_topdown[OF assms(1) q(2)] * r_def
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5065
      apply(rule setsum_Un_disjoint'[THEN sym]) using q(1) q'(1) p'(1) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5066
  next  case goal1 have *:"k * real (card r) / (1 + real (card r)) < k" using k by(auto simp add:field_simps)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5067
    show ?case apply(rule le_less_trans[of _ "setsum (\<lambda>x. k / (real (card r) + 1)) r"])
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
  5068
      unfolding setsum_subtractf[THEN sym] apply(rule setsum_norm_le)
36778
739a9379e29b avoid using real-specific versions of generic lemmas
huffman
parents: 36725
diff changeset
  5069
      apply rule apply(drule qq) defer unfolding divide_inverse setsum_left_distrib[THEN sym]
739a9379e29b avoid using real-specific versions of generic lemmas
huffman
parents: 36725
diff changeset
  5070
      unfolding divide_inverse[THEN sym] using * by(auto simp add:field_simps real_eq_of_nat)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5071
  qed finally show "?x \<le> e + k" . qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5072
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5073
lemma henstock_lemma_part2: fixes f::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5074
  assumes "f integrable_on {a..b}" "0 < e" "gauge d"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5075
  "\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow> norm (setsum (\<lambda>(x,k). content k *\<^sub>R f x) p -
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5076
          integral({a..b}) f) < e"    "p tagged_partial_division_of {a..b}" "d fine p"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5077
  shows "setsum (\<lambda>(x,k). norm(content k *\<^sub>R f x - integral k f)) p \<le> 2 * real (DIM('n)) * e"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5078
  unfolding split_def apply(rule setsum_norm_allsubsets_bound) defer 
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5079
  apply(rule henstock_lemma_part1[unfolded split_def,OF assms(1-3)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5080
  apply safe apply(rule assms[rule_format,unfolded split_def]) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5081
  apply(rule tagged_partial_division_subset,rule assms,assumption)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5082
  apply(rule fine_subset,assumption,rule assms) using assms(5) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5083
  
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5084
lemma henstock_lemma: fixes f::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5085
  assumes "f integrable_on {a..b}" "e>0"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5086
  obtains d where "gauge d"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5087
  "\<forall>p. p tagged_partial_division_of {a..b} \<and> d fine p
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5088
  \<longrightarrow> setsum (\<lambda>(x,k). norm(content k *\<^sub>R f x - integral k f)) p < e"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5089
proof- have *:"e / (2 * (real DIM('n) + 1)) > 0" apply(rule divide_pos_pos) using assms(2) by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5090
  from integrable_integral[OF assms(1),unfolded has_integral[of f],rule_format,OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5091
  guess d .. note d = conjunctD2[OF this] show thesis apply(rule that,rule d)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5092
  proof safe case goal1 note * = henstock_lemma_part2[OF assms(1) * d this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5093
    show ?case apply(rule le_less_trans[OF *]) using `e>0` by(auto simp add:field_simps) qed qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5094
44514
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5095
subsection {* Geometric progression *}
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5096
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5097
text {* FIXME: Should one or more of these theorems be moved to @{file
47317
432b29a96f61 modernized obsolete old-style theory name with proper new-style underscore
huffman
parents: 47152
diff changeset
  5098
"~~/src/HOL/Set_Interval.thy"}, alongside @{text geometric_sum}? *}
44514
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5099
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5100
lemma sum_gp_basic:
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5101
  fixes x :: "'a::ring_1"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5102
  shows "(1 - x) * setsum (\<lambda>i. x^i) {0 .. n} = (1 - x^(Suc n))"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5103
proof-
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5104
  def y \<equiv> "1 - x"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5105
  have "y * (\<Sum>i=0..n. (1 - y) ^ i) = 1 - (1 - y) ^ Suc n"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5106
    by (induct n, simp, simp add: algebra_simps)
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5107
  thus ?thesis
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5108
    unfolding y_def by simp
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5109
qed
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5110
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5111
lemma sum_gp_multiplied: assumes mn: "m <= n"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5112
  shows "((1::'a::{field}) - x) * setsum (op ^ x) {m..n} = x^m - x^ Suc n"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5113
  (is "?lhs = ?rhs")
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5114
proof-
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5115
  let ?S = "{0..(n - m)}"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5116
  from mn have mn': "n - m \<ge> 0" by arith
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5117
  let ?f = "op + m"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5118
  have i: "inj_on ?f ?S" unfolding inj_on_def by auto
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5119
  have f: "?f ` ?S = {m..n}"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5120
    using mn apply (auto simp add: image_iff Bex_def) by arith
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5121
  have th: "op ^ x o op + m = (\<lambda>i. x^m * x^i)"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5122
    by (rule ext, simp add: power_add power_mult)
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5123
  from setsum_reindex[OF i, of "op ^ x", unfolded f th setsum_right_distrib[symmetric]]
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5124
  have "?lhs = x^m * ((1 - x) * setsum (op ^ x) {0..n - m})" by simp
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5125
  then show ?thesis unfolding sum_gp_basic using mn
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5126
    by (simp add: field_simps power_add[symmetric])
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5127
qed
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5128
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5129
lemma sum_gp: "setsum (op ^ (x::'a::{field})) {m .. n} =
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5130
   (if n < m then 0 else if x = 1 then of_nat ((n + 1) - m)
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5131
                    else (x^ m - x^ (Suc n)) / (1 - x))"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5132
proof-
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5133
  {assume nm: "n < m" hence ?thesis by simp}
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5134
  moreover
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5135
  {assume "\<not> n < m" hence nm: "m \<le> n" by arith
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5136
    {assume x: "x = 1"  hence ?thesis by simp}
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5137
    moreover
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5138
    {assume x: "x \<noteq> 1" hence nz: "1 - x \<noteq> 0" by simp
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5139
      from sum_gp_multiplied[OF nm, of x] nz have ?thesis by (simp add: field_simps)}
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5140
    ultimately have ?thesis by metis
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5141
  }
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5142
  ultimately show ?thesis by metis
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5143
qed
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5144
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5145
lemma sum_gp_offset: "setsum (op ^ (x::'a::{field})) {m .. m+n} =
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5146
  (if x = 1 then of_nat n + 1 else x^m * (1 - x^Suc n) / (1 - x))"
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5147
  unfolding sum_gp[of x m "m + n"] power_Suc
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5148
  by (simp add: field_simps power_add)
d02b01e5ab8f move geometric progression lemmas from Linear_Algebra.thy to Integration.thy where they are used
huffman
parents: 44457
diff changeset
  5149
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5150
subsection {* monotone convergence (bounded interval first). *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5151
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5152
lemma monotone_convergence_interval: fixes f::"nat \<Rightarrow> 'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5153
  assumes "\<forall>k. (f k) integrable_on {a..b}"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5154
  "\<forall>k. \<forall>x\<in>{a..b}.(f k x) \<le> (f (Suc k) x)"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5155
  "\<forall>x\<in>{a..b}. ((\<lambda>k. f k x) ---> g x) sequentially"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5156
  "bounded {integral {a..b} (f k) | k . k \<in> UNIV}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5157
  shows "g integrable_on {a..b} \<and> ((\<lambda>k. integral ({a..b}) (f k)) ---> integral ({a..b}) g) sequentially"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5158
proof(case_tac[!] "content {a..b} = 0") assume as:"content {a..b} = 0"
44125
230a8665c919 mark some redundant theorems as legacy
huffman
parents: 42871
diff changeset
  5159
  show ?thesis using integrable_on_null[OF as] unfolding integral_null[OF as] using tendsto_const by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5160
next assume ab:"content {a..b} \<noteq> 0"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5161
  have fg:"\<forall>x\<in>{a..b}. \<forall> k. (f k x) \<bullet> 1 \<le> (g x) \<bullet> 1"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5162
  proof safe case goal1 note assms(3)[rule_format,OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5163
    note * = Lim_component_ge[OF this trivial_limit_sequentially]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5164
    show ?case apply(rule *) unfolding eventually_sequentially
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5165
      apply(rule_tac x=k in exI) apply- apply(rule transitive_stepwise_le)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5166
      using assms(2)[rule_format,OF goal1] by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5167
  have "\<exists>i. ((\<lambda>k. integral ({a..b}) (f k)) ---> i) sequentially"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5168
    apply(rule bounded_increasing_convergent) defer
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5169
    apply rule apply(rule integral_le) apply safe
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5170
    apply(rule assms(1-2)[rule_format])+ using assms(4) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5171
  then guess i .. note i=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5172
  have i':"\<And>k. (integral({a..b}) (f k)) \<le> i\<bullet>1"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5173
    apply(rule Lim_component_ge,rule i) apply(rule trivial_limit_sequentially)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5174
    unfolding eventually_sequentially apply(rule_tac x=k in exI)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5175
    apply(rule transitive_stepwise_le) prefer 3 unfolding inner_simps real_inner_1_right apply(rule integral_le)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5176
    apply(rule assms(1-2)[rule_format])+ using assms(2) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5177
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5178
  have "(g has_integral i) {a..b}" unfolding has_integral
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5179
  proof safe case goal1 note e=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5180
    hence "\<forall>k. (\<exists>d. gauge d \<and> (\<forall>p. p tagged_division_of {a..b} \<and> d fine p \<longrightarrow>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5181
             norm ((\<Sum>(x, ka)\<in>p. content ka *\<^sub>R f k x) - integral {a..b} (f k)) < e / 2 ^ (k + 2)))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5182
      apply-apply(rule,rule assms(1)[unfolded has_integral_integral has_integral,rule_format])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5183
      apply(rule divide_pos_pos) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5184
    from choice[OF this] guess c .. note c=conjunctD2[OF this[rule_format],rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5185
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5186
    have "\<exists>r. \<forall>k\<ge>r. 0 \<le> i\<bullet>1 - (integral {a..b} (f k)) \<and> i\<bullet>1 - (integral {a..b} (f k)) < e / 4"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5187
    proof- case goal1 have "e/4 > 0" using e by auto
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  5188
      from LIMSEQ_D [OF i this] guess r ..
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5189
      thus ?case apply(rule_tac x=r in exI) apply rule
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5190
        apply(erule_tac x=k in allE)
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  5191
      proof- case goal1 thus ?case using i'[of k] by auto qed qed
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5192
    then guess r .. note r=conjunctD2[OF this[rule_format]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5193
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5194
    have "\<forall>x\<in>{a..b}. \<exists>n\<ge>r. \<forall>k\<ge>n. 0 \<le> (g x)\<bullet>1 - (f k x)\<bullet>1 \<and>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5195
           (g x)\<bullet>1 - (f k x)\<bullet>1 < e / (4 * content({a..b}))"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5196
    proof case goal1 have "e / (4 * content {a..b}) > 0" apply(rule divide_pos_pos,fact)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5197
        using ab content_pos_le[of a b] by auto
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  5198
      from assms(3)[rule_format, OF goal1, THEN LIMSEQ_D, OF this]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5199
      guess n .. note n=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5200
      thus ?case apply(rule_tac x="n + r" in exI) apply safe apply(erule_tac[2-3] x=k in allE)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5201
        unfolding dist_real_def using fg[rule_format,OF goal1]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5202
        by (auto simp add:field_simps) qed
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5203
    from bchoice[OF this] guess m .. note m=conjunctD2[OF this[rule_format],rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5204
    def d \<equiv> "\<lambda>x. c (m x) x" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5205
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5206
    show ?case apply(rule_tac x=d in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5207
    proof safe show "gauge d" using c(1) unfolding gauge_def d_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5208
    next fix p assume p:"p tagged_division_of {a..b}" "d fine p"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5209
      note p'=tagged_division_ofD[OF p(1)]
41851
96184364aa6f got rid of lemma upper_bound_finite_set
nipkow
parents: 41601
diff changeset
  5210
      have "\<exists>a. \<forall>x\<in>p. m (fst x) \<le> a"
96184364aa6f got rid of lemma upper_bound_finite_set
nipkow
parents: 41601
diff changeset
  5211
        by (metis finite_imageI finite_nat_set_iff_bounded_le p'(1) rev_image_eqI)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5212
      then guess s .. note s=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5213
      have *:"\<forall>a b c d. norm(a - b) \<le> e / 4 \<and> norm(b - c) < e / 2 \<and>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5214
            norm(c - d) < e / 4 \<longrightarrow> norm(a - d) < e" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5215
      proof safe case goal1 thus ?case using norm_triangle_lt[of "a - b" "b - c" "3* e/4"]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5216
          norm_triangle_lt[of "a - b + (b - c)" "c - d" e] unfolding norm_minus_cancel
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  5217
          by(auto simp add:algebra_simps) qed
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5218
      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R g x) - i) < e" apply(rule *[rule_format,where
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5219
          b="\<Sum>(x, k)\<in>p. content k *\<^sub>R f (m x) x" and c="\<Sum>(x, k)\<in>p. integral k (f (m x))"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5220
      proof safe case goal1
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5221
         show ?case apply(rule order_trans[of _ "\<Sum>(x, k)\<in>p. content k * (e / (4 * content {a..b}))"])
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
  5222
           unfolding setsum_subtractf[THEN sym] apply(rule order_trans,rule norm_setsum)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5223
           apply(rule setsum_mono) unfolding split_paired_all split_conv
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44176
diff changeset
  5224
           unfolding split_def setsum_left_distrib[THEN sym] scaleR_diff_right[THEN sym]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5225
           unfolding additive_content_tagged_division[OF p(1), unfolded split_def]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5226
         proof- fix x k assume xk:"(x,k) \<in> p" hence x:"x\<in>{a..b}" using p'(2-3)[OF xk] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5227
           from p'(4)[OF xk] guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5228
           show " norm (content k *\<^sub>R (g x - f (m x) x)) \<le> content k * (e / (4 * content {a..b}))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5229
             unfolding norm_scaleR uv unfolding abs_of_nonneg[OF content_pos_le] 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5230
             apply(rule mult_left_mono) using m(2)[OF x,of "m x"] by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5231
         qed(insert ab,auto)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5232
         
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5233
       next case goal2 show ?case apply(rule le_less_trans[of _ "norm (\<Sum>j = 0..s.
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5234
           \<Sum>(x, k)\<in>{xk\<in>p. m (fst xk) = j}. content k *\<^sub>R f (m x) x - integral k (f (m x)))"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5235
           apply(subst setsum_group) apply fact apply(rule finite_atLeastAtMost) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5236
           apply(subst split_def)+ unfolding setsum_subtractf apply rule
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5237
         proof- show "norm (\<Sum>j = 0..s. \<Sum>(x, k)\<in>{xk \<in> p.
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5238
             m (fst xk) = j}. content k *\<^sub>R f (m x) x - integral k (f (m x))) < e / 2"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5239
             apply(rule le_less_trans[of _ "setsum (\<lambda>i. e / 2^(i+2)) {0..s}"])
44176
eda112e9cdee remove redundant lemma setsum_norm in favor of norm_setsum;
huffman
parents: 44170
diff changeset
  5240
             apply(rule setsum_norm_le)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5241
           proof show "(\<Sum>i = 0..s. e / 2 ^ (i + 2)) < e / 2"
36778
739a9379e29b avoid using real-specific versions of generic lemmas
huffman
parents: 36725
diff changeset
  5242
               unfolding power_add divide_inverse inverse_mult_distrib
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5243
               unfolding setsum_right_distrib[THEN sym] setsum_left_distrib[THEN sym]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5244
               unfolding power_inverse sum_gp apply(rule mult_strict_left_mono[OF _ e])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5245
               unfolding power2_eq_square by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5246
             fix t assume "t\<in>{0..s}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5247
             show "norm (\<Sum>(x, k)\<in>{xk \<in> p. m (fst xk) = t}. content k *\<^sub>R f (m x) x -
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5248
               integral k (f (m x))) \<le> e / 2 ^ (t + 2)"apply(rule order_trans[of _
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5249
               "norm(setsum (\<lambda>(x,k). content k *\<^sub>R f t x - integral k (f t)) {xk \<in> p. m (fst xk) = t})"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5250
               apply(rule eq_refl) apply(rule arg_cong[where f=norm]) apply(rule setsum_cong2) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5251
               apply(rule henstock_lemma_part1) apply(rule assms(1)[rule_format])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5252
               apply(rule divide_pos_pos,rule e) defer  apply safe apply(rule c)+
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5253
               apply rule apply assumption+ apply(rule tagged_partial_division_subset[of p])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5254
               apply(rule p(1)[unfolded tagged_division_of_def,THEN conjunct1]) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5255
               unfolding fine_def apply safe apply(drule p(2)[unfolded fine_def,rule_format])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5256
               unfolding d_def by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5257
         qed(insert s, auto)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5258
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5259
       next case goal3
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5260
         note comb = integral_combine_tagged_division_topdown[OF assms(1)[rule_format] p(1)]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5261
         have *:"\<And>sr sx ss ks kr::real. kr = sr \<longrightarrow> ks = ss \<longrightarrow> ks \<le> i \<and> sr \<le> sx \<and> sx \<le> ss \<and> 0 \<le> i\<bullet>1 - kr\<bullet>1
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5262
           \<and> i\<bullet>1 - kr\<bullet>1 < e/4 \<longrightarrow> abs(sx - i) < e/4" by auto 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5263
         show ?case unfolding real_norm_def apply(rule *[rule_format],safe)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5264
           apply(rule comb[of r],rule comb[of s]) apply(rule i'[unfolded real_inner_1_right]) 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5265
           apply(rule_tac[1-2] setsum_mono) unfolding split_paired_all split_conv
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5266
           apply(rule_tac[1-2] integral_le[OF ])
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5267
         proof safe show "0 \<le> i\<bullet>1 - (integral {a..b} (f r))\<bullet>1" using r(1) by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5268
           show "i\<bullet>1 - (integral {a..b} (f r))\<bullet>1 < e / 4" using r(2) by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5269
           fix x k assume xk:"(x,k)\<in>p" from p'(4)[OF this] guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5270
           show "f r integrable_on k" "f s integrable_on k" "f (m x) integrable_on k" "f (m x) integrable_on k" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5271
             unfolding uv apply(rule_tac[!] integrable_on_subinterval[OF assms(1)[rule_format]])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5272
             using p'(3)[OF xk] unfolding uv by auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5273
           fix y assume "y\<in>k" hence "y\<in>{a..b}" using p'(3)[OF xk] by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5274
           hence *:"\<And>m. \<forall>n\<ge>m. (f m y) \<le> (f n y)" apply-apply(rule transitive_stepwise_le) using assms(2) by auto
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5275
           show "(f r y) \<le> (f (m x) y)" "(f (m x) y) \<le> (f s y)"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5276
             apply(rule_tac[!] *[rule_format]) using s[rule_format,OF xk] m(1)[of x] p'(2-3)[OF xk] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5277
         qed qed qed qed note * = this 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5278
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5279
   have "integral {a..b} g = i" apply(rule integral_unique) using * .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5280
   thus ?thesis using i * by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5281
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5282
lemma monotone_convergence_increasing: fixes f::"nat \<Rightarrow> 'n::ordered_euclidean_space \<Rightarrow> real"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5283
  assumes "\<forall>k. (f k) integrable_on s"  "\<forall>k. \<forall>x\<in>s. (f k x) \<le> (f (Suc k) x)"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5284
  "\<forall>x\<in>s. ((\<lambda>k. f k x) ---> g x) sequentially" "bounded {integral s (f k)| k. True}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5285
  shows "g integrable_on s \<and> ((\<lambda>k. integral s (f k)) ---> integral s g) sequentially"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5286
proof- have lem:"\<And>f::nat \<Rightarrow> 'n::ordered_euclidean_space \<Rightarrow> real. \<And> g s. \<forall>k.\<forall>x\<in>s. 0 \<le> (f k x) \<Longrightarrow> \<forall>k. (f k) integrable_on s \<Longrightarrow>
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5287
    \<forall>k. \<forall>x\<in>s. (f k x) \<le> (f (Suc k) x) \<Longrightarrow> \<forall>x\<in>s. ((\<lambda>k. f k x) ---> g x) sequentially  \<Longrightarrow>
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5288
    bounded {integral s (f k)| k. True} \<Longrightarrow> g integrable_on s \<and> ((\<lambda>k. integral s (f k)) ---> integral s g) sequentially"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5289
  proof- case goal1 note assms=this[rule_format]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5290
    have "\<forall>x\<in>s. \<forall>k. (f k x)\<bullet>1 \<le> (g x)\<bullet>1" apply safe apply(rule Lim_component_ge)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5291
      apply(rule goal1(4)[rule_format],assumption) apply(rule trivial_limit_sequentially)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5292
      unfolding eventually_sequentially apply(rule_tac x=k in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5293
      apply(rule transitive_stepwise_le) using goal1(3) by auto note fg=this[rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5294
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5295
    have "\<exists>i. ((\<lambda>k. integral s (f k)) ---> i) sequentially" apply(rule bounded_increasing_convergent)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5296
      apply(rule goal1(5)) apply(rule,rule integral_le) apply(rule goal1(2)[rule_format])+
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5297
      using goal1(3) by auto then guess i .. note i=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5298
    have "\<And>k. \<forall>x\<in>s. \<forall>n\<ge>k. f k x \<le> f n x" apply(rule,rule transitive_stepwise_le) using goal1(3) by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5299
    hence i':"\<forall>k. (integral s (f k))\<bullet>1 \<le> i\<bullet>1" apply-apply(rule,rule Lim_component_ge)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5300
      apply(rule i,rule trivial_limit_sequentially) unfolding eventually_sequentially
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5301
      apply(rule_tac x=k in exI,safe) apply(rule integral_component_le)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5302
      apply simp
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5303
      apply(rule goal1(2)[rule_format])+ by auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5304
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5305
    note int = assms(2)[unfolded integrable_alt[of _ s],THEN conjunct1,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5306
    have ifif:"\<And>k t. (\<lambda>x. if x \<in> t then if x \<in> s then f k x else 0 else 0) =
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5307
      (\<lambda>x. if x \<in> t\<inter>s then f k x else 0)" apply(rule ext) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5308
    have int':"\<And>k a b. f k integrable_on {a..b} \<inter> s" apply(subst integrable_restrict_univ[THEN sym])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5309
      apply(subst ifif[THEN sym]) apply(subst integrable_restrict_univ) using int .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5310
    have "\<And>a b. (\<lambda>x. if x \<in> s then g x else 0) integrable_on {a..b} \<and>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5311
      ((\<lambda>k. integral {a..b} (\<lambda>x. if x \<in> s then f k x else 0)) --->
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5312
      integral {a..b} (\<lambda>x. if x \<in> s then g x else 0)) sequentially"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5313
    proof(rule monotone_convergence_interval,safe)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5314
      case goal1 show ?case using int .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5315
    next case goal2 thus ?case apply-apply(cases "x\<in>s") using assms(3) by auto
44125
230a8665c919 mark some redundant theorems as legacy
huffman
parents: 42871
diff changeset
  5316
    next case goal3 thus ?case apply-apply(cases "x\<in>s")
44457
d366fa5551ef declare euclidean_simps [simp] at the point they are proved;
huffman
parents: 44282
diff changeset
  5317
        using assms(4) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5318
    next case goal4 note * = integral_nonneg
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5319
      have "\<And>k. norm (integral {a..b} (\<lambda>x. if x \<in> s then f k x else 0)) \<le> norm (integral s (f k))"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5320
        unfolding real_norm_def apply(subst abs_of_nonneg) apply(rule *[OF int])
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5321
        apply(safe,case_tac "x\<in>s") apply(drule assms(1)) prefer 3
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5322
        apply(subst abs_of_nonneg) apply(rule *[OF assms(2) goal1(1)[THEN spec]])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5323
        apply(subst integral_restrict_univ[THEN sym,OF int]) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5324
        unfolding ifif unfolding integral_restrict_univ[OF int']
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5325
        apply(rule integral_subset_le[OF _ int' assms(2)]) using assms(1) by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5326
      thus ?case using assms(5) unfolding bounded_iff apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5327
        apply(rule_tac x=aa in exI,safe) apply(erule_tac x="integral s (f k)" in ballE)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5328
        apply(rule order_trans) apply assumption by auto qed note g = conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5329
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5330
    have "(g has_integral i) s" unfolding has_integral_alt' apply safe apply(rule g(1))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5331
    proof- case goal1 hence "e/4>0" by auto
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  5332
      from LIMSEQ_D [OF i this] guess N .. note N=this
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5333
      note assms(2)[of N,unfolded has_integral_integral has_integral_alt'[of "f N"]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5334
      from this[THEN conjunct2,rule_format,OF `e/4>0`] guess B .. note B=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5335
      show ?case apply(rule,rule,rule B,safe)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5336
      proof- fix a b::"'n::ordered_euclidean_space" assume ab:"ball 0 B \<subseteq> {a..b}"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5337
        from `e>0` have "e/2>0" by auto
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  5338
        from LIMSEQ_D [OF g(2)[of a b] this] guess M .. note M=this
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5339
        have **:"norm (integral {a..b} (\<lambda>x. if x \<in> s then f N x else 0) - i) < e/2"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5340
          apply(rule norm_triangle_half_l) using B(2)[rule_format,OF ab] N[rule_format,of N]
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  5341
          apply-defer apply(subst norm_minus_commute) by auto
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5342
        have *:"\<And>f1 f2 g. abs(f1 - i) < e / 2 \<longrightarrow> abs(f2 - g) < e / 2 \<longrightarrow> f1 \<le> f2 \<longrightarrow> f2 \<le> i
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5343
          \<longrightarrow> abs(g - i) < e" unfolding real_inner_1_right by arith
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5344
        show "norm (integral {a..b} (\<lambda>x. if x \<in> s then g x else 0) - i) < e" 
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5345
          unfolding real_norm_def apply(rule *[rule_format])
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5346
          apply(rule **[unfolded real_norm_def])
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  5347
          apply(rule M[rule_format,of "M + N",unfolded real_norm_def]) apply(rule le_add1)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5348
          apply(rule integral_le[OF int int]) defer
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5349
          apply(rule order_trans[OF _ i'[rule_format,of "M + N",unfolded real_inner_1_right]])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5350
        proof safe case goal2 have "\<And>m. x\<in>s \<Longrightarrow> \<forall>n\<ge>m. (f m x)\<bullet>1 \<le> (f n x)\<bullet>1"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5351
            apply(rule transitive_stepwise_le) using assms(3) by auto thus ?case by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5352
        next case goal1 show ?case apply(subst integral_restrict_univ[THEN sym,OF int]) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5353
            unfolding ifif integral_restrict_univ[OF int']
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5354
            apply(rule integral_subset_le[OF _ int']) using assms by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5355
        qed qed qed 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5356
    thus ?case apply safe defer apply(drule integral_unique) using i by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5357
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5358
  have sub:"\<And>k. integral s (\<lambda>x. f k x - f 0 x) = integral s (f k) - integral s (f 0)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5359
    apply(subst integral_sub) apply(rule assms(1)[rule_format])+ by rule
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5360
  have "\<And>x m. x\<in>s \<Longrightarrow> \<forall>n\<ge>m. (f m x) \<le> (f n x)" apply(rule transitive_stepwise_le)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5361
    using assms(2) by auto note * = this[rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5362
  have "(\<lambda>x. g x - f 0 x) integrable_on s \<and>((\<lambda>k. integral s (\<lambda>x. f (Suc k) x - f 0 x)) --->
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5363
      integral s (\<lambda>x. g x - f 0 x)) sequentially" apply(rule lem,safe)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5364
  proof- case goal1 thus ?case using *[of x 0 "Suc k"] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5365
  next case goal2 thus ?case apply(rule integrable_sub) using assms(1) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5366
  next case goal3 thus ?case using *[of x "Suc k" "Suc (Suc k)"] by auto
44125
230a8665c919 mark some redundant theorems as legacy
huffman
parents: 42871
diff changeset
  5367
  next case goal4 thus ?case apply-apply(rule tendsto_diff) 
44457
d366fa5551ef declare euclidean_simps [simp] at the point they are proved;
huffman
parents: 44282
diff changeset
  5368
      using seq_offset[OF assms(3)[rule_format],of x 1] by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5369
  next case goal5 thus ?case using assms(4) unfolding bounded_iff
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5370
      apply safe apply(rule_tac x="a + norm (integral s (\<lambda>x. f 0 x))" in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5371
      apply safe apply(erule_tac x="integral s (\<lambda>x. f (Suc k) x)" in ballE) unfolding sub
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5372
      apply(rule order_trans[OF norm_triangle_ineq4]) by auto qed
44125
230a8665c919 mark some redundant theorems as legacy
huffman
parents: 42871
diff changeset
  5373
  note conjunctD2[OF this] note tendsto_add[OF this(2) tendsto_const[of "integral s (f 0)"]]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5374
    integrable_add[OF this(1) assms(1)[rule_format,of 0]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5375
  thus ?thesis unfolding sub apply-apply rule defer apply(subst(asm) integral_sub)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5376
    using assms(1) apply auto apply(rule seq_offset_rev[where k=1]) by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5377
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5378
lemma monotone_convergence_decreasing: fixes f::"nat \<Rightarrow> 'n::ordered_euclidean_space \<Rightarrow> real"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5379
  assumes "\<forall>k. (f k) integrable_on s"  "\<forall>k. \<forall>x\<in>s. (f (Suc k) x) \<le> (f k x)"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5380
  "\<forall>x\<in>s. ((\<lambda>k. f k x) ---> g x) sequentially" "bounded {integral s (f k)| k. True}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5381
  shows "g integrable_on s \<and> ((\<lambda>k. integral s (f k)) ---> integral s g) sequentially"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5382
proof- note assm = assms[rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5383
  have *:"{integral s (\<lambda>x. - f k x) |k. True} = op *\<^sub>R -1 ` {integral s (f k)| k. True}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5384
    apply safe unfolding image_iff apply(rule_tac x="integral s (f k)" in bexI) prefer 3
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5385
    apply(rule_tac x=k in exI) unfolding integral_neg[OF assm(1)] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5386
  have "(\<lambda>x. - g x) integrable_on s \<and> ((\<lambda>k. integral s (\<lambda>x. - f k x))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5387
    ---> integral s (\<lambda>x. - g x))  sequentially" apply(rule monotone_convergence_increasing)
44125
230a8665c919 mark some redundant theorems as legacy
huffman
parents: 42871
diff changeset
  5388
    apply(safe,rule integrable_neg) apply(rule assm) defer apply(rule tendsto_minus)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5389
    apply(rule assm,assumption) unfolding * apply(rule bounded_scaling) using assm by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5390
  note * = conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5391
  show ?thesis apply rule using integrable_neg[OF *(1)] defer
44125
230a8665c919 mark some redundant theorems as legacy
huffman
parents: 42871
diff changeset
  5392
    using tendsto_minus[OF *(2)] apply- unfolding integral_neg[OF assm(1)]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5393
    unfolding integral_neg[OF *(1),THEN sym] by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5394
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5395
subsection {* absolute integrability (this is the same as Lebesgue integrability). *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5396
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5397
definition absolutely_integrable_on (infixr "absolutely'_integrable'_on" 46) where
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5398
  "f absolutely_integrable_on s \<longleftrightarrow> f integrable_on s \<and> (\<lambda>x. (norm(f x))) integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5399
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5400
lemma absolutely_integrable_onI[intro?]:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5401
  "f integrable_on s \<Longrightarrow> (\<lambda>x. (norm(f x))) integrable_on s \<Longrightarrow> f absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5402
  unfolding absolutely_integrable_on_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5403
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5404
lemma absolutely_integrable_onD[dest]: assumes "f absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5405
  shows "f integrable_on s" "(\<lambda>x. (norm(f x))) integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5406
  using assms unfolding absolutely_integrable_on_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5407
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5408
(*lemma absolutely_integrable_on_trans[simp]: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real" shows
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5409
  "(vec1 o f) absolutely_integrable_on s \<longleftrightarrow> f absolutely_integrable_on s"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5410
  unfolding absolutely_integrable_on_def o_def by auto*)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5411
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5412
lemma integral_norm_bound_integral: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5413
  assumes "f integrable_on s" "g integrable_on s" "\<forall>x\<in>s. norm(f x) \<le> g x"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5414
  shows "norm(integral s f) \<le> (integral s g)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5415
proof- have *:"\<And>x y. (\<forall>e::real. 0 < e \<longrightarrow> x < y + e) \<longrightarrow> x \<le> y" apply(safe,rule ccontr)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5416
    apply(erule_tac x="x - y" in allE) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5417
  have "\<And>e sg dsa dia ig. norm(sg) \<le> dsa \<longrightarrow> abs(dsa - dia) < e / 2 \<longrightarrow> norm(sg - ig) < e / 2
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5418
    \<longrightarrow> norm(ig) < dia + e" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5419
  proof safe case goal1 show ?case apply(rule le_less_trans[OF norm_triangle_sub[of ig sg]])
36844
5f9385ecc1a7 Removed usage of normalizating locales.
hoelzl
parents: 36778
diff changeset
  5420
      apply(subst real_sum_of_halves[of e,THEN sym]) unfolding add_assoc[symmetric]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5421
      apply(rule add_le_less_mono) defer apply(subst norm_minus_commute,rule goal1)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5422
      apply(rule order_trans[OF goal1(1)]) using goal1(2) by arith
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5423
  qed note norm=this[rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5424
  have lem:"\<And>f::'n::ordered_euclidean_space \<Rightarrow> 'a. \<And> g a b. f integrable_on {a..b} \<Longrightarrow> g integrable_on {a..b} \<Longrightarrow>
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5425
    \<forall>x\<in>{a..b}. norm(f x) \<le> (g x) \<Longrightarrow> norm(integral({a..b}) f) \<le> (integral({a..b}) g)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5426
  proof(rule *[rule_format]) case goal1 hence *:"e/2>0" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5427
    from integrable_integral[OF goal1(1),unfolded has_integral[of f],rule_format,OF *]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5428
    guess d1 .. note d1 = conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5429
    from integrable_integral[OF goal1(2),unfolded has_integral[of g],rule_format,OF *]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5430
    guess d2 .. note d2 = conjunctD2[OF this,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5431
    note gauge_inter[OF d1(1) d2(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5432
    from fine_division_exists[OF this, of a b] guess p . note p=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5433
    show ?case apply(rule norm) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5434
      apply(rule d2(2)[OF conjI[OF p(1)],unfolded real_norm_def]) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5435
      apply(rule d1(2)[OF conjI[OF p(1)]]) defer apply(rule setsum_norm_le)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5436
    proof safe fix x k assume "(x,k)\<in>p" note as = tagged_division_ofD(2-4)[OF p(1) this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5437
      from this(3) guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5438
      show "norm (content k *\<^sub>R f x) \<le> content k *\<^sub>R g x" unfolding uv norm_scaleR
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5439
        unfolding abs_of_nonneg[OF content_pos_le] real_scaleR_def
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5440
        apply(rule mult_left_mono) using goal1(3) as by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5441
    qed(insert p[unfolded fine_inter],auto) qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5442
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5443
  { presume "\<And>e. 0 < e \<Longrightarrow> norm (integral s f) < integral s g + e" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5444
    thus ?thesis apply-apply(rule *[rule_format]) by auto }
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5445
  fix e::real assume "e>0" hence e:"e/2 > 0" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5446
  note assms(1)[unfolded integrable_alt[of f]] note f=this[THEN conjunct1,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5447
  note assms(2)[unfolded integrable_alt[of g]] note g=this[THEN conjunct1,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5448
  from integrable_integral[OF assms(1),unfolded has_integral'[of f],rule_format,OF e]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5449
  guess B1 .. note B1=conjunctD2[OF this[rule_format],rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5450
  from integrable_integral[OF assms(2),unfolded has_integral'[of g],rule_format,OF e]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5451
  guess B2 .. note B2=conjunctD2[OF this[rule_format],rule_format]
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5452
  from bounded_subset_closed_interval[OF bounded_ball, of "0::'n::ordered_euclidean_space" "max B1 B2"]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5453
  guess a b apply-by(erule exE)+ note ab=this[unfolded ball_max_Un]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5454
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5455
  have "ball 0 B1 \<subseteq> {a..b}" using ab by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5456
  from B1(2)[OF this] guess z .. note z=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5457
  have "ball 0 B2 \<subseteq> {a..b}" using ab by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5458
  from B2(2)[OF this] guess w .. note w=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5459
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5460
  show "norm (integral s f) < integral s g + e" apply(rule norm)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5461
    apply(rule lem[OF f g, of a b]) unfolding integral_unique[OF z(1)] integral_unique[OF w(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5462
    defer apply(rule w(2)[unfolded real_norm_def],rule z(2))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5463
    apply safe apply(case_tac "x\<in>s") unfolding if_P apply(rule assms(3)[rule_format]) by auto qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5464
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5465
lemma integral_norm_bound_integral_component: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5466
  fixes g::"'n => 'b::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5467
  assumes "f integrable_on s" "g integrable_on s"  "\<forall>x\<in>s. norm(f x) \<le> (g x)\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5468
  shows "norm(integral s f) \<le> (integral s g)\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5469
proof- have "norm (integral s f) \<le> integral s ((\<lambda>x. x \<bullet> k) o g)"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5470
    apply(rule integral_norm_bound_integral[OF assms(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5471
    apply(rule integrable_linear[OF assms(2)],rule)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5472
    unfolding o_def by(rule assms)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5473
  thus ?thesis unfolding o_def integral_component_eq[OF assms(2)] . qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5474
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5475
lemma has_integral_norm_bound_integral_component: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5476
  fixes g::"'n => 'b::ordered_euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5477
  assumes "(f has_integral i) s" "(g has_integral j) s" "\<forall>x\<in>s. norm(f x) \<le> (g x)\<bullet>k"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5478
  shows "norm(i) \<le> j\<bullet>k" using integral_norm_bound_integral_component[of f s g k]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5479
  unfolding integral_unique[OF assms(1)] integral_unique[OF assms(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5480
  using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5481
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5482
lemma absolutely_integrable_le: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5483
  assumes "f absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5484
  shows "norm(integral s f) \<le> integral s (\<lambda>x. norm(f x))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5485
  apply(rule integral_norm_bound_integral) using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5486
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5487
lemma absolutely_integrable_0[intro]: "(\<lambda>x. 0) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5488
  unfolding absolutely_integrable_on_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5489
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5490
lemma absolutely_integrable_cmul[intro]:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5491
 "f absolutely_integrable_on s \<Longrightarrow> (\<lambda>x. c *\<^sub>R f x) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5492
  unfolding absolutely_integrable_on_def using integrable_cmul[of f s c]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5493
  using integrable_cmul[of "\<lambda>x. norm (f x)" s "abs c"] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5494
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5495
lemma absolutely_integrable_neg[intro]:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5496
 "f absolutely_integrable_on s \<Longrightarrow> (\<lambda>x. -f(x)) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5497
  apply(drule absolutely_integrable_cmul[where c="-1"]) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5498
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5499
lemma absolutely_integrable_norm[intro]:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5500
 "f absolutely_integrable_on s \<Longrightarrow> (\<lambda>x. norm(f x)) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5501
  unfolding absolutely_integrable_on_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5502
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5503
lemma absolutely_integrable_abs[intro]:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5504
 "f absolutely_integrable_on s \<Longrightarrow> (\<lambda>x. abs(f x::real)) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5505
  apply(drule absolutely_integrable_norm) unfolding real_norm_def .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5506
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5507
lemma absolutely_integrable_on_subinterval: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach" shows
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5508
  "f absolutely_integrable_on s \<Longrightarrow> {a..b} \<subseteq> s \<Longrightarrow> f absolutely_integrable_on {a..b}" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5509
  unfolding absolutely_integrable_on_def by(meson integrable_on_subinterval)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5510
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5511
lemma absolutely_integrable_bounded_variation: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'a::banach"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5512
  assumes "f absolutely_integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5513
  obtains B where "\<forall>d. d division_of (\<Union>d) \<longrightarrow> setsum (\<lambda>k. norm(integral k f)) d \<le> B"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5514
  apply(rule that[of "integral UNIV (\<lambda>x. norm (f x))"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5515
proof safe case goal1 note d = division_ofD[OF this(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5516
  have "(\<Sum>k\<in>d. norm (integral k f)) \<le> (\<Sum>i\<in>d. integral i (\<lambda>x. norm (f x)))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5517
    apply(rule setsum_mono,rule absolutely_integrable_le) apply(drule d(4),safe)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5518
    apply(rule absolutely_integrable_on_subinterval[OF assms]) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5519
  also have "... \<le> integral (\<Union>d) (\<lambda>x. norm (f x))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5520
    apply(subst integral_combine_division_topdown[OF _ goal1(2)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5521
    using integrable_on_subdivision[OF goal1(2)] using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5522
  also have "... \<le> integral UNIV (\<lambda>x. norm (f x))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5523
    apply(rule integral_subset_le) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5524
    using integrable_on_subdivision[OF goal1(2)] using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5525
  finally show ?case . qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5526
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5527
lemma helplemma:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5528
  assumes "setsum (\<lambda>x. norm(f x - g x)) s < e" "finite s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5529
  shows "abs(setsum (\<lambda>x. norm(f x)) s - setsum (\<lambda>x. norm(g x)) s) < e"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5530
  unfolding setsum_subtractf[THEN sym] apply(rule le_less_trans[OF setsum_abs])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5531
  apply(rule le_less_trans[OF _ assms(1)]) apply(rule setsum_mono)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5532
  using norm_triangle_ineq3 .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5533
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5534
lemma bounded_variation_absolutely_integrable_interval:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5535
  fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space" assumes "f integrable_on {a..b}"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5536
  "\<forall>d. d division_of {a..b} \<longrightarrow> setsum (\<lambda>k. norm(integral k f)) d \<le> B"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5537
  shows "f absolutely_integrable_on {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5538
proof- let ?S = "(\<lambda>d. setsum (\<lambda>k. norm(integral k f)) d) ` {d. d division_of {a..b} }" def i \<equiv> "Sup ?S"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  5539
  have i:"isLub UNIV ?S i" unfolding i_def apply(rule isLub_cSup)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5540
    apply(rule elementary_interval) defer apply(rule_tac x=B in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5541
    apply(rule setleI) using assms(2) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5542
  show ?thesis apply(rule,rule assms) apply rule apply(subst has_integral[of _ i])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5543
  proof safe case goal1 hence "i - e / 2 \<notin> Collect (isUb UNIV (setsum (\<lambda>k. norm (integral k f)) `
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5544
        {d. d division_of {a..b}}))" using isLub_ubs[OF i,rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5545
      unfolding setge_def ubs_def by auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5546
    hence " \<exists>y. y division_of {a..b} \<and> i - e / 2 < (\<Sum>k\<in>y. norm (integral k f))"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5547
      unfolding mem_Collect_eq isUb_def setle_def by(simp add:not_le) then guess d .. note d=conjunctD2[OF this]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5548
    note d' = division_ofD[OF this(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5549
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5550
    have "\<forall>x. \<exists>e>0. \<forall>i\<in>d. x \<notin> i \<longrightarrow> ball x e \<inter> i = {}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5551
    proof case goal1 have "\<exists>da>0. \<forall>xa\<in>\<Union>{i \<in> d. x \<notin> i}. da \<le> dist x xa"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5552
        apply(rule separate_point_closed) apply(rule closed_Union)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5553
        apply(rule finite_subset[OF _ d'(1)]) apply safe apply(drule d'(4)) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5554
      thus ?case apply safe apply(rule_tac x=da in exI,safe)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5555
        apply(erule_tac x=xa in ballE) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5556
    qed from choice[OF this] guess k .. note k=conjunctD2[OF this[rule_format],rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5557
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5558
    have "e/2 > 0" using goal1 by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5559
    from henstock_lemma[OF assms(1) this] guess g . note g=this[rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5560
    let ?g = "\<lambda>x. g x \<inter> ball x (k x)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5561
    show ?case apply(rule_tac x="?g" in exI) apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5562
    proof- show "gauge ?g" using g(1) unfolding gauge_def using k(1) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5563
      fix p assume "p tagged_division_of {a..b}" "?g fine p"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5564
      note p = this(1) conjunctD2[OF this(2)[unfolded fine_inter]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5565
      note p' = tagged_division_ofD[OF p(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5566
      def p' \<equiv> "{(x,k) | x k. \<exists>i l. x \<in> i \<and> i \<in> d \<and> (x,l) \<in> p \<and> k = i \<inter> l}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5567
      have gp':"g fine p'" using p(2) unfolding p'_def fine_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5568
      have p'':"p' tagged_division_of {a..b}" apply(rule tagged_division_ofI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5569
      proof- show "finite p'" apply(rule finite_subset[of _ "(\<lambda>(k,(x,l)). (x,k \<inter> l))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5570
          ` {(k,xl) | k xl. k \<in> d \<and> xl \<in> p}"]) unfolding p'_def 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5571
          defer apply(rule finite_imageI,rule finite_product_dependent[OF d'(1) p'(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5572
          apply safe unfolding image_iff apply(rule_tac x="(i,x,l)" in bexI) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5573
        fix x k assume "(x,k)\<in>p'"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5574
        hence "\<exists>i l. x \<in> i \<and> i \<in> d \<and> (x, l) \<in> p \<and> k = i \<inter> l" unfolding p'_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5575
        then guess i l apply-by(erule exE)+ note il=conjunctD4[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5576
        show "x\<in>k" "k\<subseteq>{a..b}" using p'(2-3)[OF il(3)] il by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5577
        show "\<exists>a b. k = {a..b}" unfolding il using p'(4)[OF il(3)] d'(4)[OF il(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5578
          apply safe unfolding inter_interval by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5579
      next fix x1 k1 assume "(x1,k1)\<in>p'"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5580
        hence "\<exists>i l. x1 \<in> i \<and> i \<in> d \<and> (x1, l) \<in> p \<and> k1 = i \<inter> l" unfolding p'_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5581
        then guess i1 l1 apply-by(erule exE)+ note il1=conjunctD4[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5582
        fix x2 k2 assume "(x2,k2)\<in>p'"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5583
        hence "\<exists>i l. x2 \<in> i \<and> i \<in> d \<and> (x2, l) \<in> p \<and> k2 = i \<inter> l" unfolding p'_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5584
        then guess i2 l2 apply-by(erule exE)+ note il2=conjunctD4[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5585
        assume "(x1, k1) \<noteq> (x2, k2)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5586
        hence "interior(i1) \<inter> interior(i2) = {} \<or> interior(l1) \<inter> interior(l2) = {}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5587
          using d'(5)[OF il1(2) il2(2)] p'(5)[OF il1(3) il2(3)] unfolding il1 il2 by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5588
        thus "interior k1 \<inter> interior k2 = {}" unfolding il1 il2 by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5589
      next have *:"\<forall>(x, X) \<in> p'. X \<subseteq> {a..b}" unfolding p'_def using d' by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5590
        show "\<Union>{k. \<exists>x. (x, k) \<in> p'} = {a..b}" apply rule apply(rule Union_least)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5591
          unfolding mem_Collect_eq apply(erule exE) apply(drule *[rule_format]) apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5592
        proof- fix y assume y:"y\<in>{a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5593
          hence "\<exists>x l. (x, l) \<in> p \<and> y\<in>l" unfolding p'(6)[THEN sym] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5594
          then guess x l apply-by(erule exE)+ note xl=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5595
          hence "\<exists>k. k\<in>d \<and> y\<in>k" using y unfolding d'(6)[THEN sym] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5596
          then guess i .. note i = conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5597
          have "x\<in>i" using fineD[OF p(3) xl(1)] using k(2)[OF i(1), of x] using i(2) xl(2) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5598
          thus "y\<in>\<Union>{k. \<exists>x. (x, k) \<in> p'}" unfolding p'_def Union_iff apply(rule_tac x="i \<inter> l" in bexI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5599
            defer unfolding mem_Collect_eq apply(rule_tac x=x in exI)+ apply(rule_tac x="i\<inter>l" in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5600
            apply safe apply(rule_tac x=i in exI) apply(rule_tac x=l in exI) using i xl by auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5601
        qed qed 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5602
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5603
      hence "(\<Sum>(x, k)\<in>p'. norm (content k *\<^sub>R f x - integral k f)) < e / 2"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5604
        apply-apply(rule g(2)[rule_format]) unfolding tagged_division_of_def apply safe using gp' .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5605
      hence **:" \<bar>(\<Sum>(x,k)\<in>p'. norm (content k *\<^sub>R f x)) - (\<Sum>(x,k)\<in>p'. norm (integral k f))\<bar> < e / 2"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5606
        unfolding split_def apply(rule helplemma) using p'' by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5607
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5608
      have p'alt:"p' = {(x,(i \<inter> l)) | x i l. (x,l) \<in> p \<and> i \<in> d \<and> ~(i \<inter> l = {})}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5609
      proof safe case goal2
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5610
        have "x\<in>i" using fineD[OF p(3) goal2(1)] k(2)[OF goal2(2), of x] goal2(4-) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5611
        hence "(x, i \<inter> l) \<in> p'" unfolding p'_def apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5612
          apply(rule_tac x=x in exI,rule_tac x="i\<inter>l" in exI) apply safe using goal2 by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5613
        thus ?case using goal2(3) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5614
      next fix x k assume "(x,k)\<in>p'"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5615
        hence "\<exists>i l. x \<in> i \<and> i \<in> d \<and> (x, l) \<in> p \<and> k = i \<inter> l" unfolding p'_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5616
        then guess i l apply-by(erule exE)+ note il=conjunctD4[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5617
        thus "\<exists>y i l. (x, k) = (y, i \<inter> l) \<and> (y, l) \<in> p \<and> i \<in> d \<and> i \<inter> l \<noteq> {}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5618
          apply(rule_tac x=x in exI,rule_tac x=i in exI,rule_tac x=l in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5619
          using p'(2)[OF il(3)] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5620
      qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5621
      have sum_p':"(\<Sum>(x, k)\<in>p'. norm (integral k f)) = (\<Sum>k\<in>snd ` p'. norm (integral k f))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5622
        apply(subst setsum_over_tagged_division_lemma[OF p'',of "\<lambda>k. norm (integral k f)"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5623
        unfolding norm_eq_zero apply(rule integral_null,assumption) ..
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5624
      note snd_p = division_ofD[OF division_of_tagged_division[OF p(1)]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5625
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5626
      have *:"\<And>sni sni' sf sf'. abs(sf' - sni') < e / 2 \<longrightarrow> i - e / 2 < sni \<and> sni' \<le> i \<and>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5627
        sni \<le> sni' \<and> sf' = sf \<longrightarrow> abs(sf - i) < e" by arith
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5628
      show "norm ((\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) - i) < e" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5629
        unfolding real_norm_def apply(rule *[rule_format,OF **],safe) apply(rule d(2))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5630
      proof- case goal1 show ?case unfolding sum_p'
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5631
          apply(rule isLubD2[OF i]) using division_of_tagged_division[OF p''] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5632
      next case goal2 have *:"{k \<inter> l | k l. k \<in> d \<and> l \<in> snd ` p} =
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5633
          (\<lambda>(k,l). k \<inter> l) ` {(k,l)|k l. k \<in> d \<and> l \<in> snd ` p}" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5634
        have "(\<Sum>k\<in>d. norm (integral k f)) \<le> (\<Sum>i\<in>d. \<Sum>l\<in>snd ` p. norm (integral (i \<inter> l) f))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5635
        proof(rule setsum_mono) case goal1 note k=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5636
          from d'(4)[OF this] guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5637
          def d' \<equiv> "{{u..v} \<inter> l |l. l \<in> snd ` p \<and>  ~({u..v} \<inter> l = {})}" note uvab = d'(2)[OF k[unfolded uv]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5638
          have "d' division_of {u..v}" apply(subst d'_def) apply(rule division_inter_1) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5639
            apply(rule division_of_tagged_division[OF p(1)]) using uvab .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5640
          hence "norm (integral k f) \<le> setsum (\<lambda>k. norm (integral k f)) d'"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5641
            unfolding uv apply(subst integral_combine_division_topdown[of _ _ d'])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5642
            apply(rule integrable_on_subinterval[OF assms(1) uvab]) apply assumption
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5643
            apply(rule setsum_norm_le) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5644
          also have "... = (\<Sum>k\<in>{k \<inter> l |l. l \<in> snd ` p}. norm (integral k f))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5645
            apply(rule setsum_mono_zero_left) apply(subst simple_image)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5646
            apply(rule finite_imageI)+ apply fact unfolding d'_def uv apply blast
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5647
          proof case goal1 hence "i \<in> {{u..v} \<inter> l |l. l \<in> snd ` p}" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5648
            from this[unfolded mem_Collect_eq] guess l .. note l=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5649
            hence "{u..v} \<inter> l = {}" using goal1 by auto thus ?case using l by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5650
          qed also have "... = (\<Sum>l\<in>snd ` p. norm (integral (k \<inter> l) f))" unfolding  simple_image
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5651
            apply(rule setsum_reindex_nonzero[unfolded o_def])apply(rule finite_imageI,rule p')
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5652
          proof- case goal1 have "interior (k \<inter> l) \<subseteq> interior (l \<inter> y)" apply(subst(2) interior_inter)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5653
              apply(rule Int_greatest) defer apply(subst goal1(4)) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5654
            hence *:"interior (k \<inter> l) = {}" using snd_p(5)[OF goal1(1-3)] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5655
            from d'(4)[OF k] snd_p(4)[OF goal1(1)] guess u1 v1 u2 v2 apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5656
            show ?case using * unfolding uv inter_interval content_eq_0_interior[THEN sym] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5657
          qed finally show ?case .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5658
        qed also have "... = (\<Sum>(i,l)\<in>{(i, l) |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral (i\<inter>l) f))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5659
          apply(subst sum_sum_product[THEN sym],fact) using p'(1) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5660
        also have "... = (\<Sum>x\<in>{(i, l) |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral (split op \<inter> x) f))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5661
          unfolding split_def ..
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5662
        also have "... = (\<Sum>k\<in>{i \<inter> l |i l. i \<in> d \<and> l \<in> snd ` p}. norm (integral k f))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5663
          unfolding * apply(rule setsum_reindex_nonzero[THEN sym,unfolded o_def])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5664
          apply(rule finite_product_dependent) apply(fact,rule finite_imageI,rule p')
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5665
          unfolding split_paired_all mem_Collect_eq split_conv o_def
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5666
        proof- note * = division_ofD(4,5)[OF division_of_tagged_division,OF p(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5667
          fix l1 l2 k1 k2 assume as:"(l1, k1) \<noteq> (l2, k2)"  "l1 \<inter> k1 = l2 \<inter> k2" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5668
            "\<exists>i l. (l1, k1) = (i, l) \<and> i \<in> d \<and> l \<in> snd ` p"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5669
            "\<exists>i l. (l2, k2) = (i, l) \<and> i \<in> d \<and> l \<in> snd ` p"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5670
          hence "l1 \<in> d" "k1 \<in> snd ` p" by auto from d'(4)[OF this(1)] *(1)[OF this(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5671
          guess u1 v1 u2 v2 apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5672
          have "l1 \<noteq> l2 \<or> k1 \<noteq> k2" using as by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5673
          hence "(interior(k1) \<inter> interior(k2) = {} \<or> interior(l1) \<inter> interior(l2) = {})" apply-
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5674
            apply(erule disjE) apply(rule disjI2) apply(rule d'(5)) prefer 4 apply(rule disjI1)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5675
            apply(rule *) using as by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5676
          moreover have "interior(l1 \<inter> k1) = interior(l2 \<inter> k2)" using as(2) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5677
          ultimately have "interior(l1 \<inter> k1) = {}" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5678
          thus "norm (integral (l1 \<inter> k1) f) = 0" unfolding uv inter_interval
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5679
            unfolding content_eq_0_interior[THEN sym] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5680
        qed also have "... = (\<Sum>(x, k)\<in>p'. norm (integral k f))" unfolding sum_p'
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5681
          apply(rule setsum_mono_zero_right) apply(subst *)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5682
          apply(rule finite_imageI[OF finite_product_dependent]) apply fact
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5683
          apply(rule finite_imageI[OF p'(1)]) apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5684
        proof- case goal2 have "ia \<inter> b = {}" using goal2 unfolding p'alt image_iff Bex_def not_ex
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5685
            apply(erule_tac x="(a,ia\<inter>b)" in allE) by auto thus ?case by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5686
        next case goal1 thus ?case unfolding p'_def apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5687
            apply(rule_tac x=i in exI,rule_tac x=l in exI) unfolding snd_conv image_iff 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5688
            apply safe apply(rule_tac x="(a,l)" in bexI) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5689
        qed finally show ?case .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5690
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5691
      next case goal3
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5692
        let ?S = "{(x, i \<inter> l) |x i l. (x, l) \<in> p \<and> i \<in> d}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5693
        have Sigma_alt:"\<And>s t. s \<times> t = {(i, j) |i j. i \<in> s \<and> j \<in> t}" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5694
        have *:"?S = (\<lambda>(xl,i). (fst xl, snd xl \<inter> i)) ` (p \<times> d)" (*{(xl,i)|xl i. xl\<in>p \<and> i\<in>d}"**)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5695
          apply safe unfolding image_iff apply(rule_tac x="((x,l),i)" in bexI) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5696
        note pdfin = finite_cartesian_product[OF p'(1) d'(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5697
        have "(\<Sum>(x, k)\<in>p'. norm (content k *\<^sub>R f x)) = (\<Sum>(x, k)\<in>?S. \<bar>content k\<bar> * norm (f x))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5698
          unfolding norm_scaleR apply(rule setsum_mono_zero_left)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5699
          apply(subst *, rule finite_imageI) apply fact unfolding p'alt apply blast
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5700
          apply safe apply(rule_tac x=x in exI,rule_tac x=i in exI,rule_tac x=l in exI) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5701
        also have "... = (\<Sum>((x,l),i)\<in>p \<times> d. \<bar>content (l \<inter> i)\<bar> * norm (f x))" unfolding *
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5702
          apply(subst setsum_reindex_nonzero,fact) unfolding split_paired_all
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5703
          unfolding  o_def split_def snd_conv fst_conv mem_Sigma_iff Pair_eq apply(erule_tac conjE)+
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5704
        proof- fix x1 l1 k1 x2 l2 k2 assume as:"(x1,l1)\<in>p" "(x2,l2)\<in>p" "k1\<in>d" "k2\<in>d"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5705
            "x1 = x2" "l1 \<inter> k1 = l2 \<inter> k2" "\<not> ((x1 = x2 \<and> l1 = l2) \<and> k1 = k2)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5706
          from d'(4)[OF as(3)] p'(4)[OF as(1)] guess u1 v1 u2 v2 apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5707
          from as have "l1 \<noteq> l2 \<or> k1 \<noteq> k2" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5708
          hence "(interior(k1) \<inter> interior(k2) = {} \<or> interior(l1) \<inter> interior(l2) = {})" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5709
            apply-apply(erule disjE) apply(rule disjI2) defer apply(rule disjI1)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5710
            apply(rule d'(5)[OF as(3-4)],assumption) apply(rule p'(5)[OF as(1-2)]) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5711
          moreover have "interior(l1 \<inter> k1) = interior(l2 \<inter> k2)" unfolding  as ..
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5712
          ultimately have "interior (l1 \<inter> k1) = {}" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5713
          thus "\<bar>content (l1 \<inter> k1)\<bar> * norm (f x1) = 0" unfolding uv inter_interval
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5714
            unfolding content_eq_0_interior[THEN sym] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5715
        qed safe also have "... = (\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x))" unfolding Sigma_alt
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5716
          apply(subst sum_sum_product[THEN sym]) apply(rule p', rule,rule d')
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5717
          apply(rule setsum_cong2) unfolding split_paired_all split_conv
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5718
        proof- fix x l assume as:"(x,l)\<in>p"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5719
          note xl = p'(2-4)[OF this] from this(3) guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5720
          have "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar>) = (\<Sum>k\<in>d. content (k \<inter> {u..v}))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5721
            apply(rule setsum_cong2) apply(drule d'(4),safe) apply(subst Int_commute)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5722
            unfolding inter_interval uv apply(subst abs_of_nonneg) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5723
          also have "... = setsum content {k\<inter>{u..v}| k. k\<in>d}" unfolding simple_image
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5724
            apply(rule setsum_reindex_nonzero[unfolded o_def,THEN sym]) apply(rule d')
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5725
          proof- case goal1 from d'(4)[OF this(1)] d'(4)[OF this(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5726
            guess u1 v1 u2 v2 apply- by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5727
            have "{} = interior ((k \<inter> y) \<inter> {u..v})" apply(subst interior_inter)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5728
              using d'(5)[OF goal1(1-3)] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5729
            also have "... = interior (y \<inter> (k \<inter> {u..v}))" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5730
            also have "... = interior (k \<inter> {u..v})" unfolding goal1(4) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5731
            finally show ?case unfolding uv inter_interval content_eq_0_interior ..
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5732
          qed also have "... = setsum content {{u..v} \<inter> k |k. k \<in> d \<and> ~({u..v} \<inter> k = {})}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5733
            apply(rule setsum_mono_zero_right) unfolding simple_image
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5734
            apply(rule finite_imageI,rule d') apply blast apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5735
            apply(rule_tac x=k in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5736
          proof- case goal1 from d'(4)[OF this(1)] guess a b apply-by(erule exE)+ note ab=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5737
            have "interior (k \<inter> {u..v}) \<noteq> {}" using goal1(2)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5738
              unfolding ab inter_interval content_eq_0_interior by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5739
            thus ?case using goal1(1) using interior_subset[of "k \<inter> {u..v}"] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5740
          qed finally show "(\<Sum>i\<in>d. \<bar>content (l \<inter> i)\<bar> * norm (f x)) = content l *\<^sub>R norm (f x)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5741
            unfolding setsum_left_distrib[THEN sym] real_scaleR_def apply -
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5742
            apply(subst(asm) additive_content_division[OF division_inter_1[OF d(1)]])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5743
            using xl(2)[unfolded uv] unfolding uv by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5744
        qed finally show ?case . 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5745
      qed qed qed qed 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5746
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5747
lemma bounded_variation_absolutely_integrable:  fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5748
  assumes "f integrable_on UNIV" "\<forall>d. d division_of (\<Union>d) \<longrightarrow> setsum (\<lambda>k. norm(integral k f)) d \<le> B"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5749
  shows "f absolutely_integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5750
proof(rule absolutely_integrable_onI,fact,rule)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5751
  let ?S = "(\<lambda>d. setsum (\<lambda>k. norm(integral k f)) d) ` {d. d division_of  (\<Union>d)}" def i \<equiv> "Sup ?S"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  5752
  have i:"isLub UNIV ?S i" unfolding i_def apply(rule isLub_cSup)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5753
    apply(rule elementary_interval) defer apply(rule_tac x=B in exI)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5754
    apply(rule setleI) using assms(2) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5755
  have f_int:"\<And>a b. f absolutely_integrable_on {a..b}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5756
    apply(rule bounded_variation_absolutely_integrable_interval[where B=B])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5757
    apply(rule integrable_on_subinterval[OF assms(1)]) defer apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5758
    apply(rule assms(2)[rule_format]) by auto 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5759
  show "((\<lambda>x. norm (f x)) has_integral i) UNIV" apply(subst has_integral_alt',safe)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5760
  proof- case goal1 show ?case using f_int[of a b] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5761
  next case goal2 have "\<exists>y\<in>setsum (\<lambda>k. norm (integral k f)) ` {d. d division_of \<Union>d}. \<not> y \<le> i - e"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5762
    proof(rule ccontr) case goal1 hence "i \<le> i - e" apply-
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5763
        apply(rule isLub_le_isUb[OF i]) apply(rule isUbI) unfolding setle_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5764
      thus False using goal2 by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5765
    qed then guess K .. note * = this[unfolded image_iff not_le]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5766
    from this(1) guess d .. note this[unfolded mem_Collect_eq]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5767
    note d = this(1) *(2)[unfolded this(2)] note d'=division_ofD[OF this(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5768
    have "bounded (\<Union>d)" by(rule elementary_bounded,fact)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5769
    from this[unfolded bounded_pos] guess K .. note K=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5770
    show ?case apply(rule_tac x="K + 1" in exI,safe)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5771
    proof- fix a b assume ab:"ball 0 (K + 1) \<subseteq> {a..b::'n::ordered_euclidean_space}"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5772
      have *:"\<forall>s s1. i - e < s1 \<and> s1 \<le> s \<and> s < i + e \<longrightarrow> abs(s - i) < (e::real)" by arith
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5773
      show "norm (integral {a..b} (\<lambda>x. if x \<in> UNIV then norm (f x) else 0) - i) < e"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5774
        unfolding real_norm_def apply(rule *[rule_format],safe) apply(rule d(2))
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5775
      proof- case goal1 have "(\<Sum>k\<in>d. norm (integral k f)) \<le> setsum (\<lambda>k. integral k (\<lambda>x. norm (f x))) d"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5776
          apply(rule setsum_mono) apply(rule absolutely_integrable_le)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5777
          apply(drule d'(4),safe) by(rule f_int)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5778
        also have "... = integral (\<Union>d) (\<lambda>x. norm(f x))" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5779
          apply(rule integral_combine_division_bottomup[THEN sym])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5780
          apply(rule d) unfolding forall_in_division[OF d(1)] using f_int by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5781
        also have "... \<le> integral {a..b} (\<lambda>x. if x \<in> UNIV then norm (f x) else 0)" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5782
        proof- case goal1 have "\<Union>d \<subseteq> {a..b}" apply rule apply(drule K(2)[rule_format]) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5783
            apply(rule ab[unfolded subset_eq,rule_format]) by(auto simp add:dist_norm)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5784
          thus ?case apply- apply(subst if_P,rule) apply(rule integral_subset_le) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5785
            apply(rule integrable_on_subdivision[of _ _ _ "{a..b}"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5786
            apply(rule d) using f_int[of a b] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5787
        qed finally show ?case .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5788
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5789
      next note f = absolutely_integrable_onD[OF f_int[of a b]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5790
        note * = this(2)[unfolded has_integral_integral has_integral[of "\<lambda>x. norm (f x)"],rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5791
        have "e/2>0" using `e>0` by auto from *[OF this] guess d1 .. note d1=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5792
        from henstock_lemma[OF f(1) `e/2>0`] guess d2 . note d2=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5793
        from fine_division_exists[OF gauge_inter[OF d1(1) d2(1)], of a b] guess p .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5794
        note p=this(1) conjunctD2[OF this(2)[unfolded fine_inter]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5795
        have *:"\<And>sf sf' si di. sf' = sf \<longrightarrow> si \<le> i \<longrightarrow> abs(sf - si) < e / 2
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5796
          \<longrightarrow> abs(sf' - di) < e / 2 \<longrightarrow> di < i + e" by arith
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5797
        show "integral {a..b} (\<lambda>x. if x \<in> UNIV then norm (f x) else 0) < i + e" apply(subst if_P,rule)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5798
        proof(rule *[rule_format]) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5799
          show "\<bar>(\<Sum>(x,k)\<in>p. norm (content k *\<^sub>R f x)) - (\<Sum>(x,k)\<in>p. norm (integral k f))\<bar> < e / 2"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5800
            unfolding split_def apply(rule helplemma) using d2(2)[rule_format,of p]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5801
            using p(1,3) unfolding tagged_division_of_def split_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5802
          show "abs ((\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) - integral {a..b} (\<lambda>x. norm(f x))) < e / 2"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5803
            using d1(2)[rule_format,OF conjI[OF p(1,2)]] unfolding real_norm_def .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5804
          show "(\<Sum>(x, k)\<in>p. content k *\<^sub>R norm (f x)) = (\<Sum>(x, k)\<in>p. norm (content k *\<^sub>R f x))"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5805
            apply(rule setsum_cong2) unfolding split_paired_all split_conv
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5806
            apply(drule tagged_division_ofD(4)[OF p(1)]) unfolding norm_scaleR
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5807
            apply(subst abs_of_nonneg) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5808
          show "(\<Sum>(x, k)\<in>p. norm (integral k f)) \<le> i"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5809
            apply(subst setsum_over_tagged_division_lemma[OF p(1)]) defer apply(rule isLubD2[OF i])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5810
            unfolding image_iff apply(rule_tac x="snd ` p" in bexI) unfolding mem_Collect_eq defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5811
            apply(rule partial_division_of_tagged_division[of _ "{a..b}"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5812
            using p(1) unfolding tagged_division_of_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5813
        qed qed qed(insert K,auto) qed qed 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5814
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5815
lemma absolutely_integrable_restrict_univ:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5816
 "(\<lambda>x. if x \<in> s then f x else (0::'a::banach)) absolutely_integrable_on UNIV \<longleftrightarrow> f absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5817
  unfolding absolutely_integrable_on_def if_distrib norm_zero integrable_restrict_univ ..
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5818
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5819
lemma absolutely_integrable_add[intro]: fixes f g::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5820
  assumes "f absolutely_integrable_on s" "g absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5821
  shows "(\<lambda>x. f(x) + g(x)) absolutely_integrable_on s"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5822
proof- let ?P = "\<And>f g::'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space. f absolutely_integrable_on UNIV \<Longrightarrow>
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5823
    g absolutely_integrable_on UNIV \<Longrightarrow> (\<lambda>x. f(x) + g(x)) absolutely_integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5824
  { presume as:"PROP ?P" note a = absolutely_integrable_restrict_univ[THEN sym]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5825
    have *:"\<And>x. (if x \<in> s then f x else 0) + (if x \<in> s then g x else 0)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5826
      = (if x \<in> s then f x + g x else 0)" by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5827
    show ?thesis apply(subst a) using as[OF assms[unfolded a[of f] a[of g]]] unfolding * . }
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5828
  fix f g::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space" assume assms:"f absolutely_integrable_on UNIV"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5829
    "g absolutely_integrable_on UNIV" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5830
  note absolutely_integrable_bounded_variation
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5831
  from this[OF assms(1)] this[OF assms(2)] guess B1 B2 . note B=this[rule_format]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5832
  show "(\<lambda>x. f(x) + g(x)) absolutely_integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5833
    apply(rule bounded_variation_absolutely_integrable[of _ "B1+B2"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5834
    apply(rule integrable_add) prefer 3
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5835
  proof safe case goal1 have "\<And>k. k \<in> d \<Longrightarrow> f integrable_on k \<and> g integrable_on k"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5836
      apply(drule division_ofD(4)[OF goal1]) apply safe
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5837
      apply(rule_tac[!] integrable_on_subinterval[of _ UNIV]) using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5838
    hence "(\<Sum>k\<in>d. norm (integral k (\<lambda>x. f x + g x))) \<le>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5839
      (\<Sum>k\<in>d. norm (integral k f)) + (\<Sum>k\<in>d. norm (integral k g))" apply-
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5840
      unfolding setsum_addf[THEN sym] apply(rule setsum_mono)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5841
      apply(subst integral_add) prefer 3 apply(rule norm_triangle_ineq) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5842
    also have "... \<le> B1 + B2" using B(1)[OF goal1] B(2)[OF goal1] by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5843
    finally show ?case .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5844
  qed(insert assms,auto) qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5845
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5846
lemma absolutely_integrable_sub[intro]: fixes f g::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5847
  assumes "f absolutely_integrable_on s" "g absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5848
  shows "(\<lambda>x. f(x) - g(x)) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5849
  using absolutely_integrable_add[OF assms(1) absolutely_integrable_neg[OF assms(2)]]
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
  5850
  unfolding algebra_simps .
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5851
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5852
lemma absolutely_integrable_linear: fixes f::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space" and h::"'n::ordered_euclidean_space \<Rightarrow> 'p::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5853
  assumes "f absolutely_integrable_on s" "bounded_linear h"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5854
  shows "(h o f) absolutely_integrable_on s"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5855
proof- { presume as:"\<And>f::'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space. \<And>h::'n::ordered_euclidean_space \<Rightarrow> 'p::ordered_euclidean_space. 
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5856
    f absolutely_integrable_on UNIV \<Longrightarrow> bounded_linear h \<Longrightarrow>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5857
    (h o f) absolutely_integrable_on UNIV" note a = absolutely_integrable_restrict_univ[THEN sym]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5858
    show ?thesis apply(subst a) using as[OF assms[unfolded a[of f] a[of g]]]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5859
      unfolding o_def if_distrib linear_simps[OF assms(2)] . }
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5860
  fix f::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space" and h::"'n::ordered_euclidean_space \<Rightarrow> 'p::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5861
  assume assms:"f absolutely_integrable_on UNIV" "bounded_linear h" 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5862
  from absolutely_integrable_bounded_variation[OF assms(1)] guess B . note B=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5863
  from bounded_linear.pos_bounded[OF assms(2)] guess b .. note b=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5864
  show "(h o f) absolutely_integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5865
    apply(rule bounded_variation_absolutely_integrable[of _ "B * b"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5866
    apply(rule integrable_linear[OF _ assms(2)]) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5867
  proof safe case goal2
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5868
    have "(\<Sum>k\<in>d. norm (integral k (h \<circ> f))) \<le> setsum (\<lambda>k. norm(integral k f)) d * b"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5869
      unfolding setsum_left_distrib apply(rule setsum_mono)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5870
    proof- case goal1 from division_ofD(4)[OF goal2 this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5871
      guess u v apply-by(erule exE)+ note uv=this
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5872
      have *:"f integrable_on k" unfolding uv apply(rule integrable_on_subinterval[of _ UNIV])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5873
        using assms by auto note this[unfolded has_integral_integral]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5874
      note has_integral_linear[OF this assms(2)] integrable_linear[OF * assms(2)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5875
      note * = has_integral_unique[OF this(2)[unfolded has_integral_integral] this(1)]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5876
      show ?case unfolding * using b by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5877
    qed also have "... \<le> B * b" apply(rule mult_right_mono) using B goal2 b by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5878
    finally show ?case .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5879
  qed(insert assms,auto) qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5880
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5881
lemma absolutely_integrable_setsum: fixes f::"'a \<Rightarrow> 'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5882
  assumes "finite t" "\<And>a. a \<in> t \<Longrightarrow> (f a) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5883
  shows "(\<lambda>x. setsum (\<lambda>a. f a x) t) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5884
  using assms(1,2) apply induct defer apply(subst setsum.insert) apply assumption+ by(rule,auto)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5885
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5886
lemma bounded_linear_setsum:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5887
  fixes f :: "'i \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5888
  assumes f: "\<And>i. i\<in>I \<Longrightarrow> bounded_linear (f i)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5889
  shows "bounded_linear (\<lambda>x. \<Sum>i\<in>I. f i x)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5890
proof cases
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5891
  assume "finite I" from this f show ?thesis
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5892
    by (induct I) (auto intro!: bounded_linear_add bounded_linear_zero)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5893
qed (simp add: bounded_linear_zero)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5894
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5895
lemma absolutely_integrable_vector_abs:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5896
  fixes f::"'a::ordered_euclidean_space => 'b::ordered_euclidean_space"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5897
  fixes T :: "'c::ordered_euclidean_space \<Rightarrow> 'b"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5898
  assumes f: "f absolutely_integrable_on s"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5899
  shows "(\<lambda>x. (\<Sum>i\<in>Basis. abs(f x\<bullet>T i) *\<^sub>R i)) absolutely_integrable_on s"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5900
    (is "?Tf absolutely_integrable_on s")
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5901
proof -
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5902
  have if_distrib: "\<And>P A B x. (if P then A else B) *\<^sub>R x = (if P then A *\<^sub>R x else B *\<^sub>R x)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5903
    by simp
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5904
  have *: "\<And>x. ?Tf x = (\<Sum>i\<in>Basis.
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5905
    ((\<lambda>y. (\<Sum>j\<in>Basis. (if j = i then y else 0) *\<^sub>R j)) o
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5906
     (\<lambda>x. (norm (\<Sum>j\<in>Basis. (if j = i then f x\<bullet>T i else 0) *\<^sub>R j)))) x)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5907
    by (simp add: comp_def if_distrib setsum_cases)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5908
  show ?thesis
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5909
    unfolding *
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5910
    apply (rule absolutely_integrable_setsum[OF finite_Basis])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5911
    apply (rule absolutely_integrable_linear)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5912
    apply (rule absolutely_integrable_norm)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5913
    apply (rule absolutely_integrable_linear[OF f, unfolded o_def])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5914
    apply (auto simp: linear_linear euclidean_eq_iff[where 'a='c] inner_simps intro!: linearI)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5915
    done
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5916
qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5917
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5918
lemma absolutely_integrable_max:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5919
  fixes f g::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5920
  assumes "f absolutely_integrable_on s" "g absolutely_integrable_on s"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5921
  shows "(\<lambda>x. (\<Sum>i\<in>Basis. max (f(x)\<bullet>i) (g(x)\<bullet>i) *\<^sub>R i)::'n) absolutely_integrable_on s"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5922
proof -
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5923
  have *:"\<And>x. (1 / 2) *\<^sub>R (((\<Sum>i\<in>Basis. \<bar>(f x - g x) \<bullet> i\<bar> *\<^sub>R i)::'n) + (f x + g x)) =
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5924
      (\<Sum>i\<in>Basis. max (f(x)\<bullet>i) (g(x)\<bullet>i) *\<^sub>R i)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5925
    unfolding euclidean_eq_iff[where 'a='n] by (auto simp: inner_simps)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5926
  note absolutely_integrable_sub[OF assms] absolutely_integrable_add[OF assms]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5927
  note absolutely_integrable_vector_abs[OF this(1), where T="\<lambda>x. x"] this(2)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5928
  note absolutely_integrable_add[OF this]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5929
  note absolutely_integrable_cmul[OF this, of "1/2"]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5930
  thus ?thesis unfolding * .
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5931
qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5932
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5933
lemma absolutely_integrable_min:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5934
  fixes f g::"'m::ordered_euclidean_space \<Rightarrow> 'n::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5935
  assumes "f absolutely_integrable_on s" "g absolutely_integrable_on s"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5936
  shows "(\<lambda>x. (\<Sum>i\<in>Basis. min (f(x)\<bullet>i) (g(x)\<bullet>i) *\<^sub>R i)::'n) absolutely_integrable_on s"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5937
proof -
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5938
  have *:"\<And>x. (1 / 2) *\<^sub>R ((f x + g x) - (\<Sum>i\<in>Basis. \<bar>(f x - g x) \<bullet> i\<bar> *\<^sub>R i::'n)) =
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5939
      (\<Sum>i\<in>Basis. min (f(x)\<bullet>i) (g(x)\<bullet>i) *\<^sub>R i)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5940
    unfolding euclidean_eq_iff[where 'a='n] by (auto simp: inner_simps)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5941
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5942
  note absolutely_integrable_add[OF assms] absolutely_integrable_sub[OF assms]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5943
  note this(1) absolutely_integrable_vector_abs[OF this(2), where T="\<lambda>x. x"]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5944
  note absolutely_integrable_sub[OF this]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5945
  note absolutely_integrable_cmul[OF this,of "1/2"]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5946
  thus ?thesis unfolding * .
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5947
qed
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5948
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5949
lemma absolutely_integrable_abs_eq:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5950
  fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5951
  shows "f absolutely_integrable_on s \<longleftrightarrow> f integrable_on s \<and>
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5952
          (\<lambda>x. (\<Sum>i\<in>Basis. abs(f x\<bullet>i) *\<^sub>R i)::'m) integrable_on s" (is "?l = ?r")
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5953
proof
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5954
  assume ?l thus ?r apply-apply rule defer
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5955
    apply(drule absolutely_integrable_vector_abs) by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5956
next 
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5957
  assume ?r
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5958
  { presume lem:"\<And>f::'n \<Rightarrow> 'm. f integrable_on UNIV \<Longrightarrow>
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5959
      (\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m) integrable_on UNIV \<Longrightarrow> f absolutely_integrable_on UNIV"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5960
    have *:"\<And>x. (\<Sum>i\<in>Basis. \<bar>(if x \<in> s then f x else 0) \<bullet> i\<bar> *\<^sub>R i) =
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5961
        (if x\<in>s then (\<Sum>i\<in>Basis. \<bar>f x \<bullet> i\<bar> *\<^sub>R i) else (0::'m))"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5962
      unfolding euclidean_eq_iff[where 'a='m] by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5963
    show ?l apply(subst absolutely_integrable_restrict_univ[THEN sym]) apply(rule lem)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5964
      unfolding integrable_restrict_univ * using `?r` by auto }
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5965
  fix f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5966
  assume assms:"f integrable_on UNIV" "(\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m) integrable_on UNIV"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5967
  let ?B = "\<Sum>i\<in>Basis. integral UNIV (\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m) \<bullet> i"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5968
  show "f absolutely_integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5969
    apply(rule bounded_variation_absolutely_integrable[OF assms(1), where B="?B"],safe)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5970
  proof- case goal1 note d=this and d'=division_ofD[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5971
    have "(\<Sum>k\<in>d. norm (integral k f)) \<le>
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5972
      (\<Sum>k\<in>d. setsum (op \<bullet> (integral k (\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m))) Basis)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5973
      apply(rule setsum_mono)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5974
      apply(rule order_trans[OF norm_le_l1]) apply(rule setsum_mono) unfolding lessThan_iff
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5975
    proof- fix k and i :: 'm assume "k\<in>d" and i:"i\<in>Basis"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  5976
      from d'(4)[OF this(1)] guess a b apply-by(erule exE)+ note ab=this
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5977
      show "\<bar>integral k f \<bullet> i\<bar> \<le> integral k (\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m) \<bullet> i"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5978
        apply (rule abs_leI)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5979
        unfolding inner_minus_left[THEN sym] defer apply(subst integral_neg[THEN sym])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5980
        defer apply(rule_tac[1-2] integral_component_le[OF i]) apply(rule integrable_neg)
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5981
        using integrable_on_subinterval[OF assms(1),of a b]
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5982
          integrable_on_subinterval[OF assms(2),of a b] i unfolding ab by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5983
    qed also have "... \<le> setsum (op \<bullet> (integral UNIV (\<lambda>x. (\<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i)::'m))) Basis"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5984
      apply(subst setsum_commute,rule setsum_mono)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5985
    proof- case goal1 have *:"(\<lambda>x. \<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i::'m) integrable_on \<Union>d"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5986
        using integrable_on_subdivision[OF d assms(2)] by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5987
      have "(\<Sum>i\<in>d. integral i (\<lambda>x. \<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i::'m) \<bullet> j)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5988
        = integral (\<Union>d) (\<lambda>x. \<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i::'m) \<bullet> j"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5989
        unfolding inner_setsum_left[symmetric] integral_combine_division_topdown[OF * d] ..
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5990
      also have "... \<le> integral UNIV (\<lambda>x. \<Sum>i\<in>Basis. \<bar>f x\<bullet>i\<bar> *\<^sub>R i::'m) \<bullet> j"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5991
        apply(rule integral_subset_component_le) using assms * `j\<in>Basis` by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5992
      finally show ?case .
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5993
    qed finally show ?case . qed qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5994
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5995
lemma nonnegative_absolutely_integrable:
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5996
  fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5997
  assumes "\<forall>x\<in>s. \<forall>i\<in>Basis. 0 \<le> f(x)\<bullet>i" "f integrable_on s"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  5998
  shows "f absolutely_integrable_on s"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  5999
  unfolding absolutely_integrable_abs_eq
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6000
  apply rule
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6001
  apply (rule assms)
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6002
  apply (rule integrable_eq[of _ f])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6003
  using assms
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6004
  apply (auto simp: euclidean_eq_iff[where 'a='m])
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6005
  done
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  6006
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  6007
lemma absolutely_integrable_integrable_bound: fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6008
  assumes "\<forall>x\<in>s. norm(f x) \<le> g x" "f integrable_on s" "g integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6009
  shows "f absolutely_integrable_on s"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  6010
proof- { presume *:"\<And>f::'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space. \<And> g. \<forall>x. norm(f x) \<le> g x \<Longrightarrow> f integrable_on UNIV
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6011
    \<Longrightarrow> g integrable_on UNIV \<Longrightarrow> f absolutely_integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6012
    show ?thesis apply(subst absolutely_integrable_restrict_univ[THEN sym])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6013
      apply(rule *[of _ "\<lambda>x. if x\<in>s then g x else 0"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6014
      using assms unfolding integrable_restrict_univ by auto }
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  6015
  fix g and f :: "'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6016
  assume assms:"\<forall>x. norm(f x) \<le> g x" "f integrable_on UNIV" "g integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6017
  show "f absolutely_integrable_on UNIV"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6018
    apply(rule bounded_variation_absolutely_integrable[OF assms(2),where B="integral UNIV g"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6019
  proof safe case goal1 note d=this and d'=division_ofD[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6020
    have "(\<Sum>k\<in>d. norm (integral k f)) \<le> (\<Sum>k\<in>d. integral k g)"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6021
      apply(rule setsum_mono) apply(rule integral_norm_bound_integral) apply(drule_tac[!] d'(4),safe) 
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6022
      apply(rule_tac[1-2] integrable_on_subinterval) using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6023
    also have "... = integral (\<Union>d) g" apply(rule integral_combine_division_bottomup[THEN sym])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6024
      apply(rule d,safe) apply(drule d'(4),safe)
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6025
      apply(rule integrable_on_subinterval[OF assms(3)]) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6026
    also have "... \<le> integral UNIV g" apply(rule integral_subset_le) defer
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6027
      apply(rule integrable_on_subdivision[OF d,of _ UNIV]) prefer 4
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6028
      apply(rule,rule_tac y="norm (f x)" in order_trans) using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6029
    finally show ?case . qed qed
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6030
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  6031
lemma absolutely_integrable_integrable_bound_real: fixes f::"'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6032
  assumes "\<forall>x\<in>s. norm(f x) \<le> g x" "f integrable_on s" "g integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6033
  shows "f absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6034
  apply(rule absolutely_integrable_integrable_bound[where g=g])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6035
  using assms unfolding o_def by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6036
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6037
lemma absolutely_integrable_absolutely_integrable_bound:
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36899
diff changeset
  6038
  fixes f::"'n::ordered_euclidean_space \<Rightarrow> 'm::ordered_euclidean_space" and g::"'n::ordered_euclidean_space \<Rightarrow> 'p::ordered_euclidean_space"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6039
  assumes "\<forall>x\<in>s. norm(f x) \<le> norm(g x)" "f integrable_on s" "g absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6040
  shows "f absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6041
  apply(rule absolutely_integrable_integrable_bound[of s f "\<lambda>x. norm (g x)"])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6042
  using assms by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6043
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6044
lemma absolutely_integrable_inf_real:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6045
  assumes "finite k" "k \<noteq> {}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6046
  "\<forall>i\<in>k. (\<lambda>x. (fs x i)::real) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6047
  shows "(\<lambda>x. (Inf ((fs x) ` k))) absolutely_integrable_on s" using assms
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6048
proof induct case (insert a k) let ?P = " (\<lambda>x. if fs x ` k = {} then fs x a
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6049
         else min (fs x a) (Inf (fs x ` k))) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6050
  show ?case unfolding image_insert
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6051
    apply(subst Inf_insert_finite) apply(rule finite_imageI[OF insert(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6052
  proof(cases "k={}") case True
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6053
    thus ?P apply(subst if_P) defer apply(rule insert(5)[rule_format]) by auto
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6054
  next case False thus ?P apply(subst if_not_P) defer
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6055
      apply (rule absolutely_integrable_min[where 'n=real, unfolded Basis_real_def, simplified])
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6056
      defer apply(rule insert(3)[OF False]) using insert(5) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6057
  qed qed auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6058
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6059
lemma absolutely_integrable_sup_real:
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6060
  assumes "finite k" "k \<noteq> {}"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6061
  "\<forall>i\<in>k. (\<lambda>x. (fs x i)::real) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6062
  shows "(\<lambda>x. (Sup ((fs x) ` k))) absolutely_integrable_on s" using assms
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6063
proof induct case (insert a k) let ?P = " (\<lambda>x. if fs x ` k = {} then fs x a
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6064
         else max (fs x a) (Sup (fs x ` k))) absolutely_integrable_on s"
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6065
  show ?case unfolding image_insert
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6066
    apply(subst Sup_insert_finite) apply(rule finite_imageI[OF insert(1)])
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6067
  proof(cases "k={}") case True
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6068
    thus ?P apply(subst if_P) defer apply(rule insert(5)[rule_format]) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6069
  next case False thus ?P apply(subst if_not_P) defer
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50348
diff changeset
  6070
      apply (rule absolutely_integrable_max[where 'n=real, unfolded Basis_real_def, simplified])
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6071
      defer apply(rule insert(3)[OF False]) using insert(5) by auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6072
  qed qed auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6073
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6074
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6075
subsection {* Dominated convergence. *}
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6076
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6077
lemma dominated_convergence:
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6078
  fixes f :: "nat \<Rightarrow> 'n::ordered_euclidean_space \<Rightarrow> real"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6079
  assumes "\<And>k. (f k) integrable_on s" "h integrable_on s"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6080
    "\<And>k. \<forall>x \<in> s. norm(f k x) \<le> (h x)"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6081
    "\<forall>x \<in> s. ((\<lambda>k. f k x) ---> g x) sequentially"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6082
  shows "g integrable_on s"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6083
    "((\<lambda>k. integral s (f k)) ---> integral s g) sequentially"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6084
proof -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6085
  have "\<And>m. (\<lambda>x. Inf {f j x |j. m \<le> j}) integrable_on s \<and>
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6086
    ((\<lambda>k. integral s (\<lambda>x. Inf {f j x |j. j \<in> {m..m + k}})) --->
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6087
    integral s (\<lambda>x. Inf {f j x |j. m \<le> j}))sequentially"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6088
  proof (rule monotone_convergence_decreasing, safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6089
    fix m :: nat
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6090
    show "bounded {integral s (\<lambda>x. Inf {f j x |j. j \<in> {m..m + k}}) |k. True}"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6091
      unfolding bounded_iff
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6092
      apply (rule_tac x="integral s h" in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6093
    proof safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6094
      fix k :: nat
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6095
      show "norm (integral s (\<lambda>x. Inf {f j x |j. j \<in> {m..m + k}})) \<le> integral s h"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6096
        apply (rule integral_norm_bound_integral)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6097
        unfolding simple_image
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6098
        apply (rule absolutely_integrable_onD)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6099
        apply (rule absolutely_integrable_inf_real)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6100
        prefer 5
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6101
        unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6102
        apply rule
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6103
        apply (rule cInf_abs_ge)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6104
        prefer 5
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6105
        apply rule
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6106
        apply (rule_tac g = h in absolutely_integrable_integrable_bound_real)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6107
        using assms
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6108
        unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6109
        apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6110
        done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6111
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6112
    fix k :: nat
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6113
    show "(\<lambda>x. Inf {f j x |j. j \<in> {m..m + k}}) integrable_on s"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6114
      unfolding simple_image
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6115
      apply (rule absolutely_integrable_onD)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6116
      apply (rule absolutely_integrable_inf_real)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6117
      prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6118
      using absolutely_integrable_integrable_bound_real[OF assms(3,1,2)]
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6119
      apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6120
      done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6121
    fix x
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6122
    assume x: "x \<in> s"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6123
    show "Inf {f j x |j. j \<in> {m..m + Suc k}} \<le> Inf {f j x |j. j \<in> {m..m + k}}"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6124
      apply (rule cInf_ge)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6125
      unfolding setge_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6126
      defer
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6127
      apply rule
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6128
      apply (subst cInf_finite_le_iff)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6129
      prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6130
      apply (rule_tac x=xa in bexI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6131
      apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6132
      done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6133
    let ?S = "{f j x| j.  m \<le> j}"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6134
    def i \<equiv> "Inf ?S"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6135
    show "((\<lambda>k. Inf {f j x |j. j \<in> {m..m + k}}) ---> i) sequentially"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6136
    proof (rule LIMSEQ_I)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6137
      case goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6138
      note r = this
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6139
      have i: "isGlb UNIV ?S i"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6140
        unfolding i_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6141
        apply (rule Inf)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6142
        defer
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6143
        apply (rule_tac x="- h x - 1" in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6144
        unfolding setge_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6145
      proof safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6146
        case goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6147
        thus ?case using assms(3)[rule_format,OF x, of j] by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6148
      qed auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6149
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6150
      have "\<exists>y\<in>?S. \<not> y \<ge> i + r"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6151
      proof(rule ccontr)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6152
        case goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6153
        hence "i \<ge> i + r"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6154
          apply -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6155
          apply (rule isGlb_le_isLb[OF i])
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6156
          apply (rule isLbI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6157
          unfolding setge_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6158
          apply fastforce+
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6159
          done
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6160
        thus False using r by auto
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6161
      qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6162
      then guess y .. note y=this[unfolded not_le]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6163
      from this(1)[unfolded mem_Collect_eq] guess N .. note N=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6164
      
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6165
      show ?case
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6166
        apply (rule_tac x=N in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6167
      proof safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6168
        case goal1
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6169
        have *:"\<And>y ix. y < i + r \<longrightarrow> i \<le> ix \<longrightarrow> ix \<le> y \<longrightarrow> abs(ix - i) < r" by arith
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6170
        show ?case
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6171
          unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6172
            apply (rule *[rule_format,OF y(2)])
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6173
            unfolding i_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6174
            apply (rule real_le_inf_subset)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6175
            prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6176
            apply (rule,rule isGlbD1[OF i])
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6177
            prefer 3
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6178
            apply (subst cInf_finite_le_iff)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6179
            prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6180
            apply (rule_tac x=y in bexI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6181
            using N goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6182
            apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6183
            done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6184
      qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6185
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6186
  qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6187
  note dec1 = conjunctD2[OF this]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6188
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6189
  have "\<And>m. (\<lambda>x. Sup {f j x |j. m \<le> j}) integrable_on s \<and>
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6190
    ((\<lambda>k. integral s (\<lambda>x. Sup {f j x |j. j \<in> {m..m + k}})) --->
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6191
    integral s (\<lambda>x. Sup {f j x |j. m \<le> j})) sequentially"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6192
  proof (rule monotone_convergence_increasing,safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6193
    fix m :: nat
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6194
    show "bounded {integral s (\<lambda>x. Sup {f j x |j. j \<in> {m..m + k}}) |k. True}"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6195
      unfolding bounded_iff
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6196
      apply (rule_tac x="integral s h" in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6197
    proof safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6198
      fix k :: nat
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6199
      show "norm (integral s (\<lambda>x. Sup {f j x |j. j \<in> {m..m + k}})) \<le> integral s h"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6200
        apply (rule integral_norm_bound_integral) unfolding simple_image
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6201
        apply (rule absolutely_integrable_onD)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6202
        apply(rule absolutely_integrable_sup_real)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6203
        prefer 5 unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6204
        apply rule
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6205
        apply (rule cSup_abs_le)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6206
        prefer 5
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6207
        apply rule
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6208
        apply (rule_tac g=h in absolutely_integrable_integrable_bound_real)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6209
        using assms
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6210
        unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6211
        apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6212
        done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6213
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6214
    fix k :: nat
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6215
    show "(\<lambda>x. Sup {f j x |j. j \<in> {m..m + k}}) integrable_on s"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6216
      unfolding simple_image
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6217
      apply (rule absolutely_integrable_onD)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6218
      apply (rule absolutely_integrable_sup_real)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6219
      prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6220
      using absolutely_integrable_integrable_bound_real[OF assms(3,1,2)]
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6221
      apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6222
      done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6223
    fix x
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6224
    assume x: "x\<in>s"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6225
    show "Sup {f j x |j. j \<in> {m..m + Suc k}} \<ge> Sup {f j x |j. j \<in> {m..m + k}}"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6226
      apply (rule cSup_le)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6227
      unfolding setle_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6228
      defer
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6229
      apply rule
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6230
      apply (subst cSup_finite_ge_iff)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6231
      prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6232
      apply (rule_tac x=y in bexI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6233
      apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6234
      done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6235
    let ?S = "{f j x| j.  m \<le> j}"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6236
    def i \<equiv> "Sup ?S"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6237
    show "((\<lambda>k. Sup {f j x |j. j \<in> {m..m + k}}) ---> i) sequentially"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6238
    proof (rule LIMSEQ_I)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6239
      case goal1 note r=this
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6240
      have i: "isLub UNIV ?S i"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6241
        unfolding i_def
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6242
        apply (rule isLub_cSup)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6243
        defer
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6244
        apply (rule_tac x="h x" in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6245
        unfolding setle_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6246
      proof safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6247
        case goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6248
        thus ?case using assms(3)[rule_format,OF x, of j] by auto
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6249
      qed auto
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6250
      
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6251
      have "\<exists>y\<in>?S. \<not> y \<le> i - r"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6252
      proof (rule ccontr)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6253
        case goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6254
        hence "i \<le> i - r"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6255
          apply -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6256
          apply (rule isLub_le_isUb[OF i])
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6257
          apply (rule isUbI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6258
          unfolding setle_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6259
          apply fastforce+
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6260
          done
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6261
        thus False using r by auto
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6262
      qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6263
      then guess y .. note y=this[unfolded not_le]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6264
      from this(1)[unfolded mem_Collect_eq] guess N .. note N=conjunctD2[OF this]
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6265
      
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6266
      show ?case
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6267
        apply (rule_tac x=N in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6268
      proof safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6269
        case goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6270
        have *: "\<And>y ix. i - r < y \<longrightarrow> ix \<le> i \<longrightarrow> y \<le> ix \<longrightarrow> abs(ix - i) < r"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6271
          by arith
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6272
        show ?case
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6273
          unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6274
          apply (rule *[rule_format,OF y(2)])
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6275
          unfolding i_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6276
          apply (rule real_ge_sup_subset)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6277
          prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6278
          apply (rule, rule isLubD1[OF i])
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6279
          prefer 3
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6280
          apply (subst cSup_finite_ge_iff)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6281
          prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6282
          apply (rule_tac x = y in bexI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6283
          using N goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6284
          apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6285
          done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6286
      qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6287
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6288
  qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6289
  note inc1 = conjunctD2[OF this]
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6290
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6291
  have "g integrable_on s \<and>
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6292
    ((\<lambda>k. integral s (\<lambda>x. Inf {f j x |j. k \<le> j})) ---> integral s g) sequentially"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6293
    apply (rule monotone_convergence_increasing,safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6294
    apply fact 
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6295
  proof -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6296
    show "bounded {integral s (\<lambda>x. Inf {f j x |j. k \<le> j}) |k. True}"
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6297
      unfolding bounded_iff apply(rule_tac x="integral s h" in exI)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6298
    proof safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6299
      fix k :: nat
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6300
      show "norm (integral s (\<lambda>x. Inf {f j x |j. k \<le> j})) \<le> integral s h"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6301
        apply (rule integral_norm_bound_integral)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6302
        apply fact+
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6303
        unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6304
        apply rule
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6305
        apply (rule cInf_abs_ge)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6306
        using assms(3)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6307
        apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6308
        done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6309
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6310
    fix k :: nat and x
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6311
    assume x: "x \<in> s"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6312
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6313
    have *: "\<And>x y::real. x \<ge> - y \<Longrightarrow> - x \<le> y" by auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6314
    show "Inf {f j x |j. k \<le> j} \<le> Inf {f j x |j. Suc k \<le> j}"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6315
      apply -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6316
      apply (rule real_le_inf_subset)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6317
      prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6318
      unfolding setge_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6319
      apply (rule_tac x="- h x" in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6320
      apply safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6321
      apply (rule *)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6322
      using assms(3)[rule_format,OF x]
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6323
      unfolding real_norm_def abs_le_iff
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6324
      apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6325
      done
51518
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
  6326
6a56b7088a6a separate SupInf into Conditional_Complete_Lattice, move instantiation of real to RealDef
hoelzl
parents: 51489
diff changeset
  6327
    show "(\<lambda>k::nat. Inf {f j x |j. k \<le> j}) ----> g x"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6328
    proof (rule LIMSEQ_I)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6329
      case goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6330
      hence "0<r/2" by auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6331
      from assms(4)[THEN bspec, THEN LIMSEQ_D, OF x this] guess N .. note N = this
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6332
      show ?case
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6333
        apply (rule_tac x=N in exI,safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6334
        unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6335
        apply (rule le_less_trans[of _ "r/2"])
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6336
        apply (rule cInf_asclose)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6337
        apply safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6338
        defer
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6339
        apply (rule less_imp_le)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6340
        using N goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6341
        apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6342
        done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6343
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6344
  qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6345
  note inc2 = conjunctD2[OF this]
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6346
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6347
  have "g integrable_on s \<and>
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6348
    ((\<lambda>k. integral s (\<lambda>x. Sup {f j x |j. k \<le> j})) ---> integral s g) sequentially"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6349
    apply (rule monotone_convergence_decreasing,safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6350
    apply fact
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6351
  proof -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6352
    show "bounded {integral s (\<lambda>x. Sup {f j x |j. k \<le> j}) |k. True}"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6353
      unfolding bounded_iff
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6354
      apply (rule_tac x="integral s h" in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6355
    proof safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6356
      fix k :: nat
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6357
      show "norm (integral s (\<lambda>x. Sup {f j x |j. k \<le> j})) \<le> integral s h"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6358
        apply (rule integral_norm_bound_integral)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6359
        apply fact+
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6360
        unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6361
        apply rule
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6362
        apply (rule cSup_abs_le)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6363
        using assms(3)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6364
        apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6365
        done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6366
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6367
    fix k :: nat and x
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6368
    assume x: "x \<in> s"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6369
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6370
    show "Sup {f j x |j. k \<le> j} \<ge> Sup {f j x |j. Suc k \<le> j}"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6371
      apply -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6372
      apply (rule real_ge_sup_subset)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6373
      prefer 3
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6374
      unfolding setle_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6375
      apply (rule_tac x="h x" in exI)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6376
      apply safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6377
      using assms(3)[rule_format,OF x]
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6378
      unfolding real_norm_def abs_le_iff
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6379
      apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6380
      done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6381
    show "((\<lambda>k. Sup {f j x |j. k \<le> j}) ---> g x) sequentially"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6382
    proof (rule LIMSEQ_I)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6383
      case goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6384
      hence "0<r/2" by auto
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6385
      from assms(4)[THEN bspec, THEN LIMSEQ_D, OF x this] guess N .. note N=this
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6386
      show ?case
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6387
        apply (rule_tac x=N in exI,safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6388
        unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6389
        apply (rule le_less_trans[of _ "r/2"])
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6390
        apply (rule cSup_asclose)
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6391
        apply safe
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6392
        defer
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6393
        apply (rule less_imp_le)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6394
        using N goal1
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6395
        apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6396
        done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6397
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6398
  qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6399
  note dec2 = conjunctD2[OF this]
36243
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6400
027ae62681be Translated remaining theorems about integration from HOL light.
himmelma
parents: 36081
diff changeset
  6401
  show "g integrable_on s" by fact
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6402
  show "((\<lambda>k. integral s (f k)) ---> integral s g) sequentially"
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6403
  proof (rule LIMSEQ_I)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6404
    case goal1
44906
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6405
    from LIMSEQ_D [OF inc2(2) goal1] guess N1 .. note N1=this[unfolded real_norm_def]
8f3625167c76 simplify proofs using LIMSEQ lemmas
huffman
parents: 44890
diff changeset
  6406
    from LIMSEQ_D [OF dec2(2) goal1] guess N2 .. note N2=this[unfolded real_norm_def]
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6407
    show ?case
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6408
      apply (rule_tac x="N1+N2" in exI, safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6409
    proof -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6410
      fix n
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6411
      assume n: "n \<ge> N1 + N2"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6412
      have *: "\<And>i0 i i1 g. \<bar>i0 - g\<bar> < r \<longrightarrow> \<bar>i1 - g\<bar> < r \<longrightarrow> i0 \<le> i \<longrightarrow> i \<le> i1 \<longrightarrow> \<bar>i - g\<bar> < r"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6413
        by arith
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6414
      show "norm (integral s (f n) - integral s g) < r"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6415
        unfolding real_norm_def
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6416
        apply (rule *[rule_format,OF N1[rule_format] N2[rule_format], of n n])
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6417
      proof -
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6418
        show "integral s (\<lambda>x. Inf {f j x |j. n \<le> j}) \<le> integral s (f n)"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6419
        proof (rule integral_le[OF dec1(1) assms(1)], safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6420
          fix x
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6421
          assume x: "x \<in> s" 
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6422
          have *: "\<And>x y::real. x \<ge> - y \<Longrightarrow> - x \<le> y" by auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6423
          show "Inf {f j x |j. n \<le> j} \<le> f n x"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6424
            apply (rule cInf_lower[where z="- h x"])
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6425
            defer
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6426
            apply (rule *)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6427
            using assms(3)[rule_format,OF x]
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6428
            unfolding real_norm_def abs_le_iff
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6429
            apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6430
            done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6431
        qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6432
        show "integral s (f n) \<le> integral s (\<lambda>x. Sup {f j x |j. n \<le> j})"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6433
        proof (rule integral_le[OF assms(1) inc1(1)], safe)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6434
          fix x
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6435
          assume x: "x \<in> s"
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6436
          show "f n x \<le> Sup {f j x |j. n \<le> j}"
51475
ebf9d4fd00ba introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it
hoelzl
parents: 51348
diff changeset
  6437
            apply (rule cSup_upper[where z="h x"])
50919
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6438
            defer
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6439
            using assms(3)[rule_format,OF x]
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6440
            unfolding real_norm_def abs_le_iff
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6441
            apply auto
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6442
            done
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6443
        qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6444
      qed (insert n, auto)
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6445
    qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6446
  qed
cc03437a1f80 tuned proofs;
wenzelm
parents: 50526
diff changeset
  6447
qed
35752
c8a8df426666 reset smt_certificates
himmelma
parents: 35751
diff changeset
  6448
35173
9b24bfca8044 Renamed Multivariate-Analysis/Integration to Multivariate-Analysis/Integration_MV to avoid name clash with Integration.
hoelzl
parents: 35172
diff changeset
  6449
end