src/HOL/Real/RComplete.thy
changeset 28091 50f2d6ba024c
parent 27435 b3f8e9bdf9a7
child 28562 4e74209f113e
equal deleted inserted replaced
28090:29af3c712d2b 28091:50f2d6ba024c
   426 apply (rename_tac n)
   426 apply (rename_tac n)
   427 apply (drule order_le_imp_less_or_eq, auto)
   427 apply (drule order_le_imp_less_or_eq, auto)
   428 apply (rule_tac x = "- n - 1" in exI)
   428 apply (rule_tac x = "- n - 1" in exI)
   429 apply (rule_tac [2] x = "- n" in exI, auto)
   429 apply (rule_tac [2] x = "- n" in exI, auto)
   430 done
   430 done
       
   431 
       
   432 
       
   433 subsection{*Density of the Rational Reals in the Reals*}
       
   434 
       
   435 text{* This density proof is due to Stefan Richter and was ported by TN.  The
       
   436 original source is \emph{Real Analysis} by H.L. Royden.
       
   437 It employs the Archimedean property of the reals. *}
       
   438 
       
   439 lemma Rats_dense_in_nn_real: fixes x::real
       
   440 assumes "0\<le>x" and "x<y" shows "\<exists>r \<in> \<rat>.  x<r \<and> r<y"
       
   441 proof -
       
   442   from `x<y` have "0 < y-x" by simp
       
   443   with reals_Archimedean obtain q::nat 
       
   444     where q: "inverse (real q) < y-x" and "0 < real q" by auto  
       
   445   def p \<equiv> "LEAST n.  y \<le> real (Suc n)/real q"  
       
   446   from reals_Archimedean2 obtain n::nat where "y * real q < real n" by auto
       
   447   with `0 < real q` have ex: "y \<le> real n/real q" (is "?P n")
       
   448     by (simp add: pos_less_divide_eq[THEN sym])
       
   449   also from assms have "\<not> y \<le> real (0::nat) / real q" by simp
       
   450   ultimately have main: "(LEAST n. y \<le> real n/real q) = Suc p"
       
   451     by (unfold p_def) (rule Least_Suc)
       
   452   also from ex have "?P (LEAST x. ?P x)" by (rule LeastI)
       
   453   ultimately have suc: "y \<le> real (Suc p) / real q" by simp
       
   454   def r \<equiv> "real p/real q"
       
   455   have "x = y-(y-x)" by simp
       
   456   also from suc q have "\<dots> < real (Suc p)/real q - inverse (real q)" by arith
       
   457   also have "\<dots> = real p / real q"
       
   458     by (simp only: inverse_eq_divide real_diff_def real_of_nat_Suc 
       
   459     minus_divide_left add_divide_distrib[THEN sym]) simp
       
   460   finally have "x<r" by (unfold r_def)
       
   461   have "p<Suc p" .. also note main[THEN sym]
       
   462   finally have "\<not> ?P p"  by (rule not_less_Least)
       
   463   hence "r<y" by (simp add: r_def)
       
   464   from r_def have "r \<in> \<rat>" by simp
       
   465   with `x<r` `r<y` show ?thesis by fast
       
   466 qed
       
   467 
       
   468 theorem Rats_dense_in_real: fixes x y :: real
       
   469 assumes "x<y" shows "\<exists>r \<in> \<rat>.  x<r \<and> r<y"
       
   470 proof -
       
   471   from reals_Archimedean2 obtain n::nat where "-x < real n" by auto
       
   472   hence "0 \<le> x + real n" by arith
       
   473   also from `x<y` have "x + real n < y + real n" by arith
       
   474   ultimately have "\<exists>r \<in> \<rat>. x + real n < r \<and> r < y + real n"
       
   475     by(rule Rats_dense_in_nn_real)
       
   476   then obtain r where "r \<in> \<rat>" and r2: "x + real n < r" 
       
   477     and r3: "r < y + real n"
       
   478     by blast
       
   479   have "r - real n = r + real (int n)/real (-1::int)" by simp
       
   480   also from `r\<in>\<rat>` have "r + real (int n)/real (-1::int) \<in> \<rat>" by simp
       
   481   also from r2 have "x < r - real n" by arith
       
   482   moreover from r3 have "r - real n < y" by arith
       
   483   ultimately show ?thesis by fast
       
   484 qed
   431 
   485 
   432 
   486 
   433 subsection{*Floor and Ceiling Functions from the Reals to the Integers*}
   487 subsection{*Floor and Ceiling Functions from the Reals to the Integers*}
   434 
   488 
   435 definition
   489 definition