src/HOL/Real/RComplete.thy
author paulson
Tue Jan 27 15:39:51 2004 +0100 (2004-01-27)
changeset 14365 3d4df8c166ae
parent 9429 8ebc549e9326
child 14387 e96d5c42c4b0
permissions -rw-r--r--
replacing HOL/Real/PRat, PNat by the rational number development
of Markus Wenzel
     1 (*  Title       : RComplete.thy
     2     ID          : $Id$
     3     Author      : Jacques D. Fleuriot
     4     Copyright   : 1998  University of Cambridge
     5     Description : Completeness theorems for positive
     6                   reals and reals 
     7 *) 
     8 
     9 header{*Completeness Theorems for Positive Reals and Reals.*}
    10 
    11 theory RComplete = Lubs + RealArith:
    12 
    13 lemma real_sum_of_halves: "x/2 + x/2 = (x::real)"
    14 apply (simp)
    15 done
    16 
    17 
    18 subsection{*Completeness of Reals by Supremum Property of type @{typ preal}*} 
    19 
    20  (*a few lemmas*)
    21 lemma real_sup_lemma1:
    22      "\<forall>x \<in> P. 0 < x ==>   
    23       ((\<exists>x \<in> P. y < x) = (\<exists>X. real_of_preal X \<in> P & y < real_of_preal X))"
    24 by (blast dest!: bspec real_gt_zero_preal_Ex [THEN iffD1])
    25 
    26 lemma real_sup_lemma2:
    27      "[| \<forall>x \<in> P. 0 < x;  a \<in> P;   \<forall>x \<in> P. x < y |]  
    28       ==> (\<exists>X. X\<in> {w. real_of_preal w \<in> P}) &  
    29           (\<exists>Y. \<forall>X\<in> {w. real_of_preal w \<in> P}. X < Y)"
    30 apply (rule conjI)
    31 apply (blast dest: bspec real_gt_zero_preal_Ex [THEN iffD1], auto)
    32 apply (drule bspec, assumption)
    33 apply (frule bspec, assumption)
    34 apply (drule order_less_trans, assumption)
    35 apply (drule real_gt_zero_preal_Ex [THEN iffD1])
    36 apply (force) 
    37 done
    38 
    39 (*-------------------------------------------------------------
    40             Completeness of Positive Reals
    41  -------------------------------------------------------------*)
    42 
    43 (**
    44  Supremum property for the set of positive reals
    45  FIXME: long proof - should be improved
    46 **)
    47 
    48 (*Let P be a non-empty set of positive reals, with an upper bound y.
    49   Then P has a least upper bound (written S).  
    50 FIXME: Can the premise be weakened to \<forall>x \<in> P. x\<le> y ??*)
    51 lemma posreal_complete: "[| \<forall>x \<in> P. (0::real) < x;  \<exists>x. x \<in> P;  \<exists>y. \<forall>x \<in> P. x<y |]  
    52       ==> (\<exists>S. \<forall>y. (\<exists>x \<in> P. y < x) = (y < S))"
    53 apply (rule_tac x = "real_of_preal (psup ({w. real_of_preal w \<in> P}))" in exI)
    54 apply clarify
    55 apply (case_tac "0 < ya", auto)
    56 apply (frule real_sup_lemma2, assumption+)
    57 apply (drule real_gt_zero_preal_Ex [THEN iffD1])
    58 apply (drule_tac [3] real_less_all_real2)
    59 apply (auto)
    60 apply (rule preal_complete [THEN iffD1])
    61 apply (auto intro: order_less_imp_le)
    62 apply (frule real_gt_preal_preal_Ex)
    63 apply (force)
    64 (* second part *)
    65 apply (rule real_sup_lemma1 [THEN iffD2], assumption)
    66 apply (auto dest!: real_less_all_real2 real_gt_zero_preal_Ex [THEN iffD1])
    67 apply (frule_tac [2] real_sup_lemma2)
    68 apply (frule real_sup_lemma2, assumption+, clarify) 
    69 apply (rule preal_complete [THEN iffD2, THEN bexE])
    70 prefer 3 apply blast
    71 apply (blast intro!: order_less_imp_le)+
    72 done
    73 
    74 (*--------------------------------------------------------
    75    Completeness properties using isUb, isLub etc.
    76  -------------------------------------------------------*)
    77 
    78 lemma real_isLub_unique: "[| isLub R S x; isLub R S y |] ==> x = (y::real)"
    79 apply (frule isLub_isUb)
    80 apply (frule_tac x = y in isLub_isUb)
    81 apply (blast intro!: real_le_anti_sym dest!: isLub_le_isUb)
    82 done
    83 
    84 lemma real_order_restrict: "[| (x::real) <=* S'; S <= S' |] ==> x <=* S"
    85 by (unfold setle_def setge_def, blast)
    86 
    87 (*----------------------------------------------------------------
    88            Completeness theorem for the positive reals(again)
    89  ----------------------------------------------------------------*)
    90 
    91 lemma posreals_complete:
    92      "[| \<forall>x \<in>S. 0 < x;  
    93          \<exists>x. x \<in>S;  
    94          \<exists>u. isUb (UNIV::real set) S u  
    95       |] ==> \<exists>t. isLub (UNIV::real set) S t"
    96 apply (rule_tac x = "real_of_preal (psup ({w. real_of_preal w \<in> S}))" in exI)
    97 apply (auto simp add: isLub_def leastP_def isUb_def)
    98 apply (auto intro!: setleI setgeI dest!: real_gt_zero_preal_Ex [THEN iffD1])
    99 apply (frule_tac x = y in bspec, assumption)
   100 apply (drule real_gt_zero_preal_Ex [THEN iffD1])
   101 apply (auto simp add: real_of_preal_le_iff)
   102 apply (frule_tac y = "real_of_preal ya" in setleD, assumption)
   103 apply (frule real_ge_preal_preal_Ex, safe)
   104 apply (blast intro!: preal_psup_le dest!: setleD intro: real_of_preal_le_iff [THEN iffD1])
   105 apply (frule_tac x = x in bspec, assumption)
   106 apply (frule isUbD2)
   107 apply (drule real_gt_zero_preal_Ex [THEN iffD1])
   108 apply (auto dest!: isUbD real_ge_preal_preal_Ex simp add: real_of_preal_le_iff)
   109 apply (blast dest!: setleD intro!: psup_le_ub intro: real_of_preal_le_iff [THEN iffD1])
   110 done
   111 
   112 
   113 (*-------------------------------
   114     Lemmas
   115  -------------------------------*)
   116 lemma real_sup_lemma3: "\<forall>y \<in> {z. \<exists>x \<in> P. z = x + (-xa) + 1} Int {x. 0 < x}. 0 < y"
   117 by auto
   118  
   119 lemma lemma_le_swap2: "(xa <= S + X + (-Z)) = (xa + (-X) + Z <= (S::real))"
   120 by auto
   121 
   122 lemma lemma_real_complete2b: "[| (x::real) + (-X) + 1 <= S; xa <= x |] ==> xa <= S + X + (- 1)"
   123 by arith
   124 
   125 (*----------------------------------------------------------
   126       reals Completeness (again!)
   127  ----------------------------------------------------------*)
   128 lemma reals_complete: "[| \<exists>X. X \<in>S;  \<exists>Y. isUb (UNIV::real set) S Y |]   
   129       ==> \<exists>t. isLub (UNIV :: real set) S t"
   130 apply safe
   131 apply (subgoal_tac "\<exists>u. u\<in> {z. \<exists>x \<in>S. z = x + (-X) + 1} Int {x. 0 < x}")
   132 apply (subgoal_tac "isUb (UNIV::real set) ({z. \<exists>x \<in>S. z = x + (-X) + 1} Int {x. 0 < x}) (Y + (-X) + 1) ")
   133 apply (cut_tac P = S and xa = X in real_sup_lemma3)
   134 apply (frule posreals_complete [OF _ _ exI], blast, blast) 
   135 apply safe
   136 apply (rule_tac x = "t + X + (- 1) " in exI)
   137 apply (rule isLubI2)
   138 apply (rule_tac [2] setgeI, safe)
   139 apply (subgoal_tac [2] "isUb (UNIV:: real set) ({z. \<exists>x \<in>S. z = x + (-X) + 1} Int {x. 0 < x}) (y + (-X) + 1) ")
   140 apply (drule_tac [2] y = " (y + (- X) + 1) " in isLub_le_isUb)
   141  prefer 2 apply assumption
   142  prefer 2
   143 apply arith
   144 apply (rule setleI [THEN isUbI], safe)
   145 apply (rule_tac x = x and y = y in linorder_cases)
   146 apply (subst lemma_le_swap2)
   147 apply (frule isLubD2)
   148  prefer 2 apply assumption
   149 apply safe
   150 apply blast
   151 apply arith
   152 apply (subst lemma_le_swap2)
   153 apply (frule isLubD2)
   154  prefer 2 apply assumption
   155 apply blast
   156 apply (rule lemma_real_complete2b)
   157 apply (erule_tac [2] order_less_imp_le)
   158 apply (blast intro!: isLubD2, blast) 
   159 apply (simp (no_asm_use) add: real_add_assoc)
   160 apply (blast dest: isUbD intro!: setleI [THEN isUbI] intro: add_right_mono)
   161 apply (blast dest: isUbD intro!: setleI [THEN isUbI] intro: add_right_mono, auto)
   162 done
   163 
   164 
   165 subsection{*Corollary: the Archimedean Property of the Reals*}
   166 
   167 lemma reals_Archimedean: "0 < x ==> \<exists>n. inverse (real(Suc n)) < x"
   168 apply (rule ccontr)
   169 apply (subgoal_tac "\<forall>n. x * real (Suc n) <= 1")
   170  prefer 2
   171 apply (simp add: linorder_not_less inverse_eq_divide, clarify) 
   172 apply (drule_tac x = n in spec)
   173 apply (drule_tac c = "real (Suc n)"  in mult_right_mono)
   174 apply (rule real_of_nat_ge_zero)
   175 apply (simp add: real_of_nat_Suc_gt_zero [THEN real_not_refl2, THEN not_sym] real_mult_commute)
   176 apply (subgoal_tac "isUb (UNIV::real set) {z. \<exists>n. z = x* (real (Suc n))} 1")
   177 apply (subgoal_tac "\<exists>X. X \<in> {z. \<exists>n. z = x* (real (Suc n))}")
   178 apply (drule reals_complete)
   179 apply (auto intro: isUbI setleI)
   180 apply (subgoal_tac "\<forall>m. x* (real (Suc m)) <= t")
   181 apply (simp add: real_of_nat_Suc right_distrib)
   182 prefer 2 apply (blast intro: isLubD2)
   183 apply (simp add: le_diff_eq [symmetric] real_diff_def)
   184 apply (subgoal_tac "isUb (UNIV::real set) {z. \<exists>n. z = x* (real (Suc n))} (t + (-x))")
   185 prefer 2 apply (blast intro!: isUbI setleI)
   186 apply (drule_tac y = "t+ (-x) " in isLub_le_isUb)
   187 apply (auto simp add: real_of_nat_Suc right_distrib)
   188 done
   189 
   190 (*There must be other proofs, e.g. Suc of the largest integer in the
   191   cut representing x*)
   192 lemma reals_Archimedean2: "\<exists>n. (x::real) < real (n::nat)"
   193 apply (rule_tac x = x and y = 0 in linorder_cases)
   194 apply (rule_tac x = 0 in exI)
   195 apply (rule_tac [2] x = 1 in exI)
   196 apply (auto elim: order_less_trans simp add: real_of_nat_one)
   197 apply (frule positive_imp_inverse_positive [THEN reals_Archimedean], safe)
   198 apply (rule_tac x = "Suc n" in exI)
   199 apply (frule_tac b = "inverse x" in mult_strict_right_mono, auto)
   200 done
   201 
   202 lemma reals_Archimedean3: "0 < x ==> \<forall>y. \<exists>(n::nat). y < real n * x"
   203 apply safe
   204 apply (cut_tac x = "y*inverse (x) " in reals_Archimedean2)
   205 apply safe
   206 apply (frule_tac a = "y * inverse x" in mult_strict_right_mono)
   207 apply (auto simp add: mult_assoc real_of_nat_def)
   208 done
   209 
   210 ML
   211 {*
   212 val real_sum_of_halves = thm "real_sum_of_halves";
   213 val posreal_complete = thm "posreal_complete";
   214 val real_isLub_unique = thm "real_isLub_unique";
   215 val real_order_restrict = thm "real_order_restrict";
   216 val posreals_complete = thm "posreals_complete";
   217 val reals_complete = thm "reals_complete";
   218 val reals_Archimedean = thm "reals_Archimedean";
   219 val reals_Archimedean2 = thm "reals_Archimedean2";
   220 val reals_Archimedean3 = thm "reals_Archimedean3";
   221 *}
   222 
   223 end
   224 
   225 
   226