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