src/HOL/SEQ.thy
changeset 32707 836ec9d0a0c8
parent 32436 10cd49e0c067
child 32877 6f09346c7c08
equal deleted inserted replaced
32649:442e03154ee6 32707:836ec9d0a0c8
   497   shows "convergent X \<longleftrightarrow> convergent (\<lambda>n. - X n)"
   497   shows "convergent X \<longleftrightarrow> convergent (\<lambda>n. - X n)"
   498 apply (simp add: convergent_def)
   498 apply (simp add: convergent_def)
   499 apply (auto dest: LIMSEQ_minus)
   499 apply (auto dest: LIMSEQ_minus)
   500 apply (drule LIMSEQ_minus, auto)
   500 apply (drule LIMSEQ_minus, auto)
   501 done
   501 done
       
   502 
       
   503 lemma lim_le:
       
   504   fixes x :: real
       
   505   assumes f: "convergent f" and fn_le: "!!n. f n \<le> x"
       
   506   shows "lim f \<le> x"
       
   507 proof (rule classical)
       
   508   assume "\<not> lim f \<le> x"
       
   509   hence 0: "0 < lim f - x" by arith
       
   510   have 1: "f----> lim f"
       
   511     by (metis convergent_LIMSEQ_iff f) 
       
   512   thus ?thesis
       
   513     proof (simp add: LIMSEQ_iff)
       
   514       assume "\<forall>r>0. \<exists>no. \<forall>n\<ge>no. \<bar>f n - lim f\<bar> < r"
       
   515       hence "\<exists>no. \<forall>n\<ge>no. \<bar>f n - lim f\<bar> < lim f - x"
       
   516 	by (metis 0)
       
   517       from this obtain no where "\<forall>n\<ge>no. \<bar>f n - lim f\<bar> < lim f - x"
       
   518 	by blast
       
   519       thus "lim f \<le> x"
       
   520 	by (metis add_cancel_end add_minus_cancel diff_def linorder_linear 
       
   521                   linorder_not_le minus_diff_eq abs_diff_less_iff fn_le) 
       
   522     qed
       
   523 qed
   502 
   524 
   503 text{* Given a binary function @{text "f:: nat \<Rightarrow> 'a \<Rightarrow> 'a"}, its values are uniquely determined by a function g *}
   525 text{* Given a binary function @{text "f:: nat \<Rightarrow> 'a \<Rightarrow> 'a"}, its values are uniquely determined by a function g *}
   504 
   526 
   505 lemma nat_function_unique: "EX! g. g 0 = e \<and> (\<forall>n. g (Suc n) = f n (g n))"
   527 lemma nat_function_unique: "EX! g. g 0 = e \<and> (\<forall>n. g (Suc n) = f n (g n))"
   506   unfolding Ex1_def
   528   unfolding Ex1_def
  1080 *}
  1102 *}
  1081 
  1103 
  1082 lemma isUb_UNIV_I: "(\<And>y. y \<in> S \<Longrightarrow> y \<le> u) \<Longrightarrow> isUb UNIV S u"
  1104 lemma isUb_UNIV_I: "(\<And>y. y \<in> S \<Longrightarrow> y \<le> u) \<Longrightarrow> isUb UNIV S u"
  1083 by (simp add: isUbI setleI)
  1105 by (simp add: isUbI setleI)
  1084 
  1106 
  1085 lemma real_abs_diff_less_iff:
       
  1086   "(\<bar>x - a\<bar> < (r::real)) = (a - r < x \<and> x < a + r)"
       
  1087 by auto
       
  1088 
       
  1089 locale real_Cauchy =
  1107 locale real_Cauchy =
  1090   fixes X :: "nat \<Rightarrow> real"
  1108   fixes X :: "nat \<Rightarrow> real"
  1091   assumes X: "Cauchy X"
  1109   assumes X: "Cauchy X"
  1092   fixes S :: "real set"
  1110   fixes S :: "real set"
  1093   defines S_def: "S \<equiv> {x::real. \<exists>N. \<forall>n\<ge>N. x < X n}"
  1111   defines S_def: "S \<equiv> {x::real. \<exists>N. \<forall>n\<ge>N. x < X n}"
  1120     using CauchyD [OF X zero_less_one] by auto
  1138     using CauchyD [OF X zero_less_one] by auto
  1121   hence N: "\<forall>n\<ge>N. norm (X n - X N) < 1" by simp
  1139   hence N: "\<forall>n\<ge>N. norm (X n - X N) < 1" by simp
  1122   show "\<exists>x. x \<in> S"
  1140   show "\<exists>x. x \<in> S"
  1123   proof
  1141   proof
  1124     from N have "\<forall>n\<ge>N. X N - 1 < X n"
  1142     from N have "\<forall>n\<ge>N. X N - 1 < X n"
  1125       by (simp add: real_abs_diff_less_iff)
  1143       by (simp add: abs_diff_less_iff)
  1126     thus "X N - 1 \<in> S" by (rule mem_S)
  1144     thus "X N - 1 \<in> S" by (rule mem_S)
  1127   qed
  1145   qed
  1128   show "\<exists>u. isUb UNIV S u"
  1146   show "\<exists>u. isUb UNIV S u"
  1129   proof
  1147   proof
  1130     from N have "\<forall>n\<ge>N. X n < X N + 1"
  1148     from N have "\<forall>n\<ge>N. X n < X N + 1"
  1131       by (simp add: real_abs_diff_less_iff)
  1149       by (simp add: abs_diff_less_iff)
  1132     thus "isUb UNIV S (X N + 1)"
  1150     thus "isUb UNIV S (X N + 1)"
  1133       by (rule bound_isUb)
  1151       by (rule bound_isUb)
  1134   qed
  1152   qed
  1135 qed
  1153 qed
  1136 
  1154 
  1142   hence r: "0 < r/2" by simp
  1160   hence r: "0 < r/2" by simp
  1143   obtain N where "\<forall>n\<ge>N. \<forall>m\<ge>N. norm (X n - X m) < r/2"
  1161   obtain N where "\<forall>n\<ge>N. \<forall>m\<ge>N. norm (X n - X m) < r/2"
  1144     using CauchyD [OF X r] by auto
  1162     using CauchyD [OF X r] by auto
  1145   hence "\<forall>n\<ge>N. norm (X n - X N) < r/2" by simp
  1163   hence "\<forall>n\<ge>N. norm (X n - X N) < r/2" by simp
  1146   hence N: "\<forall>n\<ge>N. X N - r/2 < X n \<and> X n < X N + r/2"
  1164   hence N: "\<forall>n\<ge>N. X N - r/2 < X n \<and> X n < X N + r/2"
  1147     by (simp only: real_norm_def real_abs_diff_less_iff)
  1165     by (simp only: real_norm_def abs_diff_less_iff)
  1148 
  1166 
  1149   from N have "\<forall>n\<ge>N. X N - r/2 < X n" by fast
  1167   from N have "\<forall>n\<ge>N. X N - r/2 < X n" by fast
  1150   hence "X N - r/2 \<in> S" by (rule mem_S)
  1168   hence "X N - r/2 \<in> S" by (rule mem_S)
  1151   hence 1: "X N - r/2 \<le> x" using x isLub_isUb isUbD by fast
  1169   hence 1: "X N - r/2 \<le> x" using x isLub_isUb isUbD by fast
  1152 
  1170 
  1157   show "\<exists>N. \<forall>n\<ge>N. norm (X n - x) < r"
  1175   show "\<exists>N. \<forall>n\<ge>N. norm (X n - x) < r"
  1158   proof (intro exI allI impI)
  1176   proof (intro exI allI impI)
  1159     fix n assume n: "N \<le> n"
  1177     fix n assume n: "N \<le> n"
  1160     from N n have "X n < X N + r/2" and "X N - r/2 < X n" by simp+
  1178     from N n have "X n < X N + r/2" and "X N - r/2 < X n" by simp+
  1161     thus "norm (X n - x) < r" using 1 2
  1179     thus "norm (X n - x) < r" using 1 2
  1162       by (simp add: real_abs_diff_less_iff)
  1180       by (simp add: abs_diff_less_iff)
  1163   qed
  1181   qed
  1164 qed
  1182 qed
  1165 
  1183 
  1166 lemma (in real_Cauchy) LIMSEQ_ex: "\<exists>x. X ----> x"
  1184 lemma (in real_Cauchy) LIMSEQ_ex: "\<exists>x. X ----> x"
  1167 proof -
  1185 proof -