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