src/HOL/Real/RComplete.thy
 author paulson Thu Apr 22 10:45:56 2004 +0200 (2004-04-22) changeset 14641 79b7bd936264 parent 14476 758e7acdea2f child 15131 c69542757a4d permissions -rw-r--r--
moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
places
```     1 (*  Title       : RComplete.thy
```
```     2     ID          : \$Id\$
```
```     3     Author      : Jacques D. Fleuriot
```
```     4     Copyright   : 1998  University of Cambridge
```
```     5     Copyright   : 2001,2002  University of Edinburgh
```
```     6 Converted to Isar and polished by lcp
```
```     7 *)
```
```     8
```
```     9 header{*Completeness of the Reals; Floor and Ceiling Functions*}
```
```    10
```
```    11 theory RComplete = Lubs + RealDef:
```
```    12
```
```    13 lemma real_sum_of_halves: "x/2 + x/2 = (x::real)"
```
```    14 by simp
```
```    15
```
```    16
```
```    17 subsection{*Completeness of Reals by Supremum Property of type @{typ preal}*}
```
```    18
```
```    19  (*a few lemmas*)
```
```    20 lemma real_sup_lemma1:
```
```    21      "\<forall>x \<in> P. 0 < x ==>
```
```    22       ((\<exists>x \<in> P. y < x) = (\<exists>X. real_of_preal X \<in> P & y < real_of_preal X))"
```
```    23 by (blast dest!: bspec real_gt_zero_preal_Ex [THEN iffD1])
```
```    24
```
```    25 lemma real_sup_lemma2:
```
```    26      "[| \<forall>x \<in> P. 0 < x;  a \<in> P;   \<forall>x \<in> P. x < y |]
```
```    27       ==> (\<exists>X. X\<in> {w. real_of_preal w \<in> P}) &
```
```    28           (\<exists>Y. \<forall>X\<in> {w. real_of_preal w \<in> P}. X < Y)"
```
```    29 apply (rule conjI)
```
```    30 apply (blast dest: bspec real_gt_zero_preal_Ex [THEN iffD1], auto)
```
```    31 apply (drule bspec, assumption)
```
```    32 apply (frule bspec, assumption)
```
```    33 apply (drule order_less_trans, assumption)
```
```    34 apply (drule real_gt_zero_preal_Ex [THEN iffD1], force)
```
```    35 done
```
```    36
```
```    37 (*-------------------------------------------------------------
```
```    38             Completeness of Positive Reals
```
```    39  -------------------------------------------------------------*)
```
```    40
```
```    41 (**
```
```    42  Supremum property for the set of positive reals
```
```    43  FIXME: long proof - should be improved
```
```    44 **)
```
```    45
```
```    46 (*Let P be a non-empty set of positive reals, with an upper bound y.
```
```    47   Then P has a least upper bound (written S).
```
```    48 FIXME: Can the premise be weakened to \<forall>x \<in> P. x\<le> y ??*)
```
```    49 lemma posreal_complete: "[| \<forall>x \<in> P. (0::real) < x;  \<exists>x. x \<in> P;  \<exists>y. \<forall>x \<in> P. x<y |]
```
```    50       ==> (\<exists>S. \<forall>y. (\<exists>x \<in> P. y < x) = (y < S))"
```
```    51 apply (rule_tac x = "real_of_preal (psup ({w. real_of_preal w \<in> P}))" in exI)
```
```    52 apply clarify
```
```    53 apply (case_tac "0 < ya", auto)
```
```    54 apply (frule real_sup_lemma2, assumption+)
```
```    55 apply (drule real_gt_zero_preal_Ex [THEN iffD1])
```
```    56 apply (drule_tac [3] real_less_all_real2, auto)
```
```    57 apply (rule preal_complete [THEN iffD1])
```
```    58 apply (auto intro: order_less_imp_le)
```
```    59 apply (frule real_gt_preal_preal_Ex, force)
```
```    60 (* second part *)
```
```    61 apply (rule real_sup_lemma1 [THEN iffD2], assumption)
```
```    62 apply (auto dest!: real_less_all_real2 real_gt_zero_preal_Ex [THEN iffD1])
```
```    63 apply (frule_tac [2] real_sup_lemma2)
```
```    64 apply (frule real_sup_lemma2, assumption+, clarify)
```
```    65 apply (rule preal_complete [THEN iffD2, THEN bexE])
```
```    66 prefer 3 apply blast
```
```    67 apply (blast intro!: order_less_imp_le)+
```
```    68 done
```
```    69
```
```    70 (*--------------------------------------------------------
```
```    71    Completeness properties using isUb, isLub etc.
```
```    72  -------------------------------------------------------*)
```
```    73
```
```    74 lemma real_isLub_unique: "[| isLub R S x; isLub R S y |] ==> x = (y::real)"
```
```    75 apply (frule isLub_isUb)
```
```    76 apply (frule_tac x = y in isLub_isUb)
```
```    77 apply (blast intro!: order_antisym dest!: isLub_le_isUb)
```
```    78 done
```
```    79
```
```    80 lemma real_order_restrict: "[| (x::real) <=* S'; S <= S' |] ==> x <=* S"
```
```    81 by (unfold setle_def setge_def, blast)
```
```    82
```
```    83 (*----------------------------------------------------------------
```
```    84            Completeness theorem for the positive reals(again)
```
```    85  ----------------------------------------------------------------*)
```
```    86
```
```    87 lemma posreals_complete:
```
```    88      "[| \<forall>x \<in>S. 0 < x;
```
```    89          \<exists>x. x \<in>S;
```
```    90          \<exists>u. isUb (UNIV::real set) S u
```
```    91       |] ==> \<exists>t. isLub (UNIV::real set) S t"
```
```    92 apply (rule_tac x = "real_of_preal (psup ({w. real_of_preal w \<in> S}))" in exI)
```
```    93 apply (auto simp add: isLub_def leastP_def isUb_def)
```
```    94 apply (auto intro!: setleI setgeI dest!: real_gt_zero_preal_Ex [THEN iffD1])
```
```    95 apply (frule_tac x = y in bspec, assumption)
```
```    96 apply (drule real_gt_zero_preal_Ex [THEN iffD1])
```
```    97 apply (auto simp add: real_of_preal_le_iff)
```
```    98 apply (frule_tac y = "real_of_preal ya" in setleD, assumption)
```
```    99 apply (frule real_ge_preal_preal_Ex, safe)
```
```   100 apply (blast intro!: preal_psup_le dest!: setleD intro: real_of_preal_le_iff [THEN iffD1])
```
```   101 apply (frule_tac x = x in bspec, assumption)
```
```   102 apply (frule isUbD2)
```
```   103 apply (drule real_gt_zero_preal_Ex [THEN iffD1])
```
```   104 apply (auto dest!: isUbD real_ge_preal_preal_Ex simp add: real_of_preal_le_iff)
```
```   105 apply (blast dest!: setleD intro!: psup_le_ub intro: real_of_preal_le_iff [THEN iffD1])
```
```   106 done
```
```   107
```
```   108
```
```   109 (*-------------------------------
```
```   110     Lemmas
```
```   111  -------------------------------*)
```
```   112 lemma real_sup_lemma3: "\<forall>y \<in> {z. \<exists>x \<in> P. z = x + (-xa) + 1} Int {x. 0 < x}. 0 < y"
```
```   113 by auto
```
```   114
```
```   115 lemma lemma_le_swap2: "(xa <= S + X + (-Z)) = (xa + (-X) + Z <= (S::real))"
```
```   116 by auto
```
```   117
```
```   118 lemma lemma_real_complete2b: "[| (x::real) + (-X) + 1 <= S; xa <= x |] ==> xa <= S + X + (- 1)"
```
```   119 by arith
```
```   120
```
```   121 (*----------------------------------------------------------
```
```   122       reals Completeness (again!)
```
```   123  ----------------------------------------------------------*)
```
```   124 lemma reals_complete: "[| \<exists>X. X \<in>S;  \<exists>Y. isUb (UNIV::real set) S Y |]
```
```   125       ==> \<exists>t. isLub (UNIV :: real set) S t"
```
```   126 apply safe
```
```   127 apply (subgoal_tac "\<exists>u. u\<in> {z. \<exists>x \<in>S. z = x + (-X) + 1} Int {x. 0 < x}")
```
```   128 apply (subgoal_tac "isUb (UNIV::real set) ({z. \<exists>x \<in>S. z = x + (-X) + 1} Int {x. 0 < x}) (Y + (-X) + 1) ")
```
```   129 apply (cut_tac P = S and xa = X in real_sup_lemma3)
```
```   130 apply (frule posreals_complete [OF _ _ exI], blast, blast, safe)
```
```   131 apply (rule_tac x = "t + X + (- 1) " in exI)
```
```   132 apply (rule isLubI2)
```
```   133 apply (rule_tac [2] setgeI, safe)
```
```   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) ")
```
```   135 apply (drule_tac [2] y = " (y + (- X) + 1) " in isLub_le_isUb)
```
```   136  prefer 2 apply assumption
```
```   137  prefer 2
```
```   138 apply arith
```
```   139 apply (rule setleI [THEN isUbI], safe)
```
```   140 apply (rule_tac x = x and y = y in linorder_cases)
```
```   141 apply (subst lemma_le_swap2)
```
```   142 apply (frule isLubD2)
```
```   143  prefer 2 apply assumption
```
```   144 apply safe
```
```   145 apply blast
```
```   146 apply arith
```
```   147 apply (subst lemma_le_swap2)
```
```   148 apply (frule isLubD2)
```
```   149  prefer 2 apply assumption
```
```   150 apply blast
```
```   151 apply (rule lemma_real_complete2b)
```
```   152 apply (erule_tac [2] order_less_imp_le)
```
```   153 apply (blast intro!: isLubD2, blast)
```
```   154 apply (simp (no_asm_use) add: real_add_assoc)
```
```   155 apply (blast dest: isUbD intro!: setleI [THEN isUbI] intro: add_right_mono)
```
```   156 apply (blast dest: isUbD intro!: setleI [THEN isUbI] intro: add_right_mono, auto)
```
```   157 done
```
```   158
```
```   159
```
```   160 subsection{*Corollary: the Archimedean Property of the Reals*}
```
```   161
```
```   162 lemma reals_Archimedean: "0 < x ==> \<exists>n. inverse (real(Suc n)) < x"
```
```   163 apply (rule ccontr)
```
```   164 apply (subgoal_tac "\<forall>n. x * real (Suc n) <= 1")
```
```   165  prefer 2
```
```   166 apply (simp add: linorder_not_less inverse_eq_divide, clarify)
```
```   167 apply (drule_tac x = n in spec)
```
```   168 apply (drule_tac c = "real (Suc n)"  in mult_right_mono)
```
```   169 apply (rule real_of_nat_ge_zero)
```
```   170 apply (simp add: real_of_nat_Suc_gt_zero [THEN real_not_refl2, THEN not_sym] real_mult_commute)
```
```   171 apply (subgoal_tac "isUb (UNIV::real set) {z. \<exists>n. z = x* (real (Suc n))} 1")
```
```   172 apply (subgoal_tac "\<exists>X. X \<in> {z. \<exists>n. z = x* (real (Suc n))}")
```
```   173 apply (drule reals_complete)
```
```   174 apply (auto intro: isUbI setleI)
```
```   175 apply (subgoal_tac "\<forall>m. x* (real (Suc m)) <= t")
```
```   176 apply (simp add: real_of_nat_Suc right_distrib)
```
```   177 prefer 2 apply (blast intro: isLubD2)
```
```   178 apply (simp add: le_diff_eq [symmetric] real_diff_def)
```
```   179 apply (subgoal_tac "isUb (UNIV::real set) {z. \<exists>n. z = x* (real (Suc n))} (t + (-x))")
```
```   180 prefer 2 apply (blast intro!: isUbI setleI)
```
```   181 apply (drule_tac y = "t+ (-x) " in isLub_le_isUb)
```
```   182 apply (auto simp add: real_of_nat_Suc right_distrib)
```
```   183 done
```
```   184
```
```   185 (*There must be other proofs, e.g. Suc of the largest integer in the
```
```   186   cut representing x*)
```
```   187 lemma reals_Archimedean2: "\<exists>n. (x::real) < real (n::nat)"
```
```   188 apply (rule_tac x = x and y = 0 in linorder_cases)
```
```   189 apply (rule_tac x = 0 in exI)
```
```   190 apply (rule_tac [2] x = 1 in exI)
```
```   191 apply (auto elim: order_less_trans simp add: real_of_nat_one)
```
```   192 apply (frule positive_imp_inverse_positive [THEN reals_Archimedean], safe)
```
```   193 apply (rule_tac x = "Suc n" in exI)
```
```   194 apply (frule_tac b = "inverse x" in mult_strict_right_mono, auto)
```
```   195 done
```
```   196
```
```   197 lemma reals_Archimedean3: "0 < x ==> \<forall>y. \<exists>(n::nat). y < real n * x"
```
```   198 apply safe
```
```   199 apply (cut_tac x = "y*inverse (x) " in reals_Archimedean2)
```
```   200 apply safe
```
```   201 apply (frule_tac a = "y * inverse x" in mult_strict_right_mono)
```
```   202 apply (auto simp add: mult_assoc real_of_nat_def)
```
```   203 done
```
```   204
```
```   205 ML
```
```   206 {*
```
```   207 val real_sum_of_halves = thm "real_sum_of_halves";
```
```   208 val posreal_complete = thm "posreal_complete";
```
```   209 val real_isLub_unique = thm "real_isLub_unique";
```
```   210 val real_order_restrict = thm "real_order_restrict";
```
```   211 val posreals_complete = thm "posreals_complete";
```
```   212 val reals_complete = thm "reals_complete";
```
```   213 val reals_Archimedean = thm "reals_Archimedean";
```
```   214 val reals_Archimedean2 = thm "reals_Archimedean2";
```
```   215 val reals_Archimedean3 = thm "reals_Archimedean3";
```
```   216 *}
```
```   217
```
```   218
```
```   219 subsection{*Floor and Ceiling Functions from the Reals to the Integers*}
```
```   220
```
```   221 constdefs
```
```   222
```
```   223   floor :: "real => int"
```
```   224    "floor r == (LEAST n::int. r < real (n+1))"
```
```   225
```
```   226   ceiling :: "real => int"
```
```   227     "ceiling r == - floor (- r)"
```
```   228
```
```   229 syntax (xsymbols)
```
```   230   floor :: "real => int"     ("\<lfloor>_\<rfloor>")
```
```   231   ceiling :: "real => int"   ("\<lceil>_\<rceil>")
```
```   232
```
```   233 syntax (HTML output)
```
```   234   floor :: "real => int"     ("\<lfloor>_\<rfloor>")
```
```   235   ceiling :: "real => int"   ("\<lceil>_\<rceil>")
```
```   236
```
```   237
```
```   238 lemma number_of_less_real_of_int_iff [simp]:
```
```   239      "((number_of n) < real (m::int)) = (number_of n < m)"
```
```   240 apply auto
```
```   241 apply (rule real_of_int_less_iff [THEN iffD1])
```
```   242 apply (drule_tac [2] real_of_int_less_iff [THEN iffD2], auto)
```
```   243 done
```
```   244
```
```   245 lemma number_of_less_real_of_int_iff2 [simp]:
```
```   246      "(real (m::int) < (number_of n)) = (m < number_of n)"
```
```   247 apply auto
```
```   248 apply (rule real_of_int_less_iff [THEN iffD1])
```
```   249 apply (drule_tac [2] real_of_int_less_iff [THEN iffD2], auto)
```
```   250 done
```
```   251
```
```   252 lemma number_of_le_real_of_int_iff [simp]:
```
```   253      "((number_of n) \<le> real (m::int)) = (number_of n \<le> m)"
```
```   254 by (simp add: linorder_not_less [symmetric])
```
```   255
```
```   256 lemma number_of_le_real_of_int_iff2 [simp]:
```
```   257      "(real (m::int) \<le> (number_of n)) = (m \<le> number_of n)"
```
```   258 by (simp add: linorder_not_less [symmetric])
```
```   259
```
```   260 lemma floor_zero [simp]: "floor 0 = 0"
```
```   261 apply (simp add: floor_def)
```
```   262 apply (rule Least_equality, auto)
```
```   263 done
```
```   264
```
```   265 lemma floor_real_of_nat_zero [simp]: "floor (real (0::nat)) = 0"
```
```   266 by auto
```
```   267
```
```   268 lemma floor_real_of_nat [simp]: "floor (real (n::nat)) = int n"
```
```   269 apply (simp only: floor_def)
```
```   270 apply (rule Least_equality)
```
```   271 apply (drule_tac [2] real_of_int_real_of_nat [THEN ssubst])
```
```   272 apply (drule_tac [2] real_of_int_less_iff [THEN iffD1])
```
```   273 apply (simp_all add: real_of_int_real_of_nat)
```
```   274 done
```
```   275
```
```   276 lemma floor_minus_real_of_nat [simp]: "floor (- real (n::nat)) = - int n"
```
```   277 apply (simp only: floor_def)
```
```   278 apply (rule Least_equality)
```
```   279 apply (drule_tac [2] real_of_int_real_of_nat [THEN ssubst])
```
```   280 apply (drule_tac [2] real_of_int_minus [THEN subst])
```
```   281 apply (drule_tac [2] real_of_int_less_iff [THEN iffD1])
```
```   282 apply (simp_all add: real_of_int_real_of_nat)
```
```   283 done
```
```   284
```
```   285 lemma floor_real_of_int [simp]: "floor (real (n::int)) = n"
```
```   286 apply (simp only: floor_def)
```
```   287 apply (rule Least_equality)
```
```   288 apply (drule_tac [2] real_of_int_real_of_nat [THEN ssubst])
```
```   289 apply (drule_tac [2] real_of_int_less_iff [THEN iffD1], auto)
```
```   290 done
```
```   291
```
```   292 lemma floor_minus_real_of_int [simp]: "floor (- real (n::int)) = - n"
```
```   293 apply (simp only: floor_def)
```
```   294 apply (rule Least_equality)
```
```   295 apply (drule_tac [2] real_of_int_minus [THEN subst])
```
```   296 apply (drule_tac [2] real_of_int_real_of_nat [THEN ssubst])
```
```   297 apply (drule_tac [2] real_of_int_less_iff [THEN iffD1], auto)
```
```   298 done
```
```   299
```
```   300 lemma reals_Archimedean6:
```
```   301      "0 \<le> r ==> \<exists>(n::nat). real (n - 1) \<le> r & r < real (n)"
```
```   302 apply (insert reals_Archimedean2 [of r], safe)
```
```   303 apply (frule_tac P = "%k. r < real k" and k = n and m = "%x. x"
```
```   304        in ex_has_least_nat, auto)
```
```   305 apply (rule_tac x = x in exI)
```
```   306 apply (case_tac x, simp)
```
```   307 apply (rename_tac x')
```
```   308 apply (drule_tac x = x' in spec, simp)
```
```   309 done
```
```   310
```
```   311 lemma reals_Archimedean6a: "0 \<le> r ==> \<exists>n. real (n) \<le> r & r < real (Suc n)"
```
```   312 by (drule reals_Archimedean6, auto)
```
```   313
```
```   314 lemma reals_Archimedean_6b_int:
```
```   315      "0 \<le> r ==> \<exists>n::int. real n \<le> r & r < real (n+1)"
```
```   316 apply (drule reals_Archimedean6a, auto)
```
```   317 apply (rule_tac x = "int n" in exI)
```
```   318 apply (simp add: real_of_int_real_of_nat real_of_nat_Suc)
```
```   319 done
```
```   320
```
```   321 lemma reals_Archimedean_6c_int:
```
```   322      "r < 0 ==> \<exists>n::int. real n \<le> r & r < real (n+1)"
```
```   323 apply (rule reals_Archimedean_6b_int [of "-r", THEN exE], simp, auto)
```
```   324 apply (rename_tac n)
```
```   325 apply (drule real_le_imp_less_or_eq, auto)
```
```   326 apply (rule_tac x = "- n - 1" in exI)
```
```   327 apply (rule_tac [2] x = "- n" in exI, auto)
```
```   328 done
```
```   329
```
```   330 lemma real_lb_ub_int: " \<exists>n::int. real n \<le> r & r < real (n+1)"
```
```   331 apply (case_tac "r < 0")
```
```   332 apply (blast intro: reals_Archimedean_6c_int)
```
```   333 apply (simp only: linorder_not_less)
```
```   334 apply (blast intro: reals_Archimedean_6b_int reals_Archimedean_6c_int)
```
```   335 done
```
```   336
```
```   337 lemma lemma_floor:
```
```   338   assumes a1: "real m \<le> r" and a2: "r < real n + 1"
```
```   339   shows "m \<le> (n::int)"
```
```   340 proof -
```
```   341   have "real m < real n + 1" by (rule order_le_less_trans)
```
```   342   also have "... = real(n+1)" by simp
```
```   343   finally have "m < n+1" by (simp only: real_of_int_less_iff)
```
```   344   thus ?thesis by arith
```
```   345 qed
```
```   346
```
```   347 lemma real_of_int_floor_le [simp]: "real (floor r) \<le> r"
```
```   348 apply (simp add: floor_def Least_def)
```
```   349 apply (insert real_lb_ub_int [of r], safe)
```
```   350 apply (rule theI2, auto)
```
```   351 done
```
```   352
```
```   353 lemma floor_le: "x < y ==> floor x \<le> floor y"
```
```   354 apply (simp add: floor_def Least_def)
```
```   355 apply (insert real_lb_ub_int [of x])
```
```   356 apply (insert real_lb_ub_int [of y], safe)
```
```   357 apply (rule theI2)
```
```   358 apply (rule_tac [3] theI2, auto)
```
```   359 done
```
```   360
```
```   361 lemma floor_le2: "x \<le> y ==> floor x \<le> floor y"
```
```   362 by (auto dest: real_le_imp_less_or_eq simp add: floor_le)
```
```   363
```
```   364 lemma lemma_floor2: "real n < real (x::int) + 1 ==> n \<le> x"
```
```   365 by (auto intro: lemma_floor)
```
```   366
```
```   367 lemma real_of_int_floor_cancel [simp]:
```
```   368     "(real (floor x) = x) = (\<exists>n::int. x = real n)"
```
```   369 apply (simp add: floor_def Least_def)
```
```   370 apply (insert real_lb_ub_int [of x], erule exE)
```
```   371 apply (rule theI2)
```
```   372 apply (auto intro: lemma_floor)
```
```   373 done
```
```   374
```
```   375 lemma floor_eq: "[| real n < x; x < real n + 1 |] ==> floor x = n"
```
```   376 apply (simp add: floor_def)
```
```   377 apply (rule Least_equality)
```
```   378 apply (auto intro: lemma_floor)
```
```   379 done
```
```   380
```
```   381 lemma floor_eq2: "[| real n \<le> x; x < real n + 1 |] ==> floor x = n"
```
```   382 apply (simp add: floor_def)
```
```   383 apply (rule Least_equality)
```
```   384 apply (auto intro: lemma_floor)
```
```   385 done
```
```   386
```
```   387 lemma floor_eq3: "[| real n < x; x < real (Suc n) |] ==> nat(floor x) = n"
```
```   388 apply (rule inj_int [THEN injD])
```
```   389 apply (simp add: real_of_nat_Suc)
```
```   390 apply (simp add: real_of_nat_Suc floor_eq floor_eq [where n = "of_nat n"])
```
```   391 done
```
```   392
```
```   393 lemma floor_eq4: "[| real n \<le> x; x < real (Suc n) |] ==> nat(floor x) = n"
```
```   394 apply (drule order_le_imp_less_or_eq)
```
```   395 apply (auto intro: floor_eq3)
```
```   396 done
```
```   397
```
```   398 lemma floor_number_of_eq [simp]:
```
```   399      "floor(number_of n :: real) = (number_of n :: int)"
```
```   400 apply (subst real_number_of [symmetric])
```
```   401 apply (rule floor_real_of_int)
```
```   402 done
```
```   403
```
```   404 lemma real_of_int_floor_ge_diff_one [simp]: "r - 1 \<le> real(floor r)"
```
```   405 apply (simp add: floor_def Least_def)
```
```   406 apply (insert real_lb_ub_int [of r], safe)
```
```   407 apply (rule theI2)
```
```   408 apply (auto intro: lemma_floor)
```
```   409 done
```
```   410
```
```   411 lemma real_of_int_floor_add_one_ge [simp]: "r \<le> real(floor r) + 1"
```
```   412 apply (insert real_of_int_floor_ge_diff_one [of r])
```
```   413 apply (auto simp del: real_of_int_floor_ge_diff_one)
```
```   414 done
```
```   415
```
```   416
```
```   417 subsection{*Ceiling Function for Positive Reals*}
```
```   418
```
```   419 lemma ceiling_zero [simp]: "ceiling 0 = 0"
```
```   420 by (simp add: ceiling_def)
```
```   421
```
```   422 lemma ceiling_real_of_nat [simp]: "ceiling (real (n::nat)) = int n"
```
```   423 by (simp add: ceiling_def)
```
```   424
```
```   425 lemma ceiling_real_of_nat_zero [simp]: "ceiling (real (0::nat)) = 0"
```
```   426 by auto
```
```   427
```
```   428 lemma ceiling_floor [simp]: "ceiling (real (floor r)) = floor r"
```
```   429 by (simp add: ceiling_def)
```
```   430
```
```   431 lemma floor_ceiling [simp]: "floor (real (ceiling r)) = ceiling r"
```
```   432 by (simp add: ceiling_def)
```
```   433
```
```   434 lemma real_of_int_ceiling_ge [simp]: "r \<le> real (ceiling r)"
```
```   435 apply (simp add: ceiling_def)
```
```   436 apply (subst le_minus_iff, simp)
```
```   437 done
```
```   438
```
```   439 lemma ceiling_le: "x < y ==> ceiling x \<le> ceiling y"
```
```   440 by (simp add: floor_le ceiling_def)
```
```   441
```
```   442 lemma ceiling_le2: "x \<le> y ==> ceiling x \<le> ceiling y"
```
```   443 by (simp add: floor_le2 ceiling_def)
```
```   444
```
```   445 lemma real_of_int_ceiling_cancel [simp]:
```
```   446      "(real (ceiling x) = x) = (\<exists>n::int. x = real n)"
```
```   447 apply (auto simp add: ceiling_def)
```
```   448 apply (drule arg_cong [where f = uminus], auto)
```
```   449 apply (rule_tac x = "-n" in exI, auto)
```
```   450 done
```
```   451
```
```   452 lemma ceiling_eq: "[| real n < x; x < real n + 1 |] ==> ceiling x = n + 1"
```
```   453 apply (simp add: ceiling_def)
```
```   454 apply (rule minus_equation_iff [THEN iffD1])
```
```   455 apply (simp add: floor_eq [where n = "-(n+1)"])
```
```   456 done
```
```   457
```
```   458 lemma ceiling_eq2: "[| real n < x; x \<le> real n + 1 |] ==> ceiling x = n + 1"
```
```   459 by (simp add: ceiling_def floor_eq2 [where n = "-(n+1)"])
```
```   460
```
```   461 lemma ceiling_eq3: "[| real n - 1 < x; x \<le> real n  |] ==> ceiling x = n"
```
```   462 by (simp add: ceiling_def floor_eq2 [where n = "-n"])
```
```   463
```
```   464 lemma ceiling_real_of_int [simp]: "ceiling (real (n::int)) = n"
```
```   465 by (simp add: ceiling_def)
```
```   466
```
```   467 lemma ceiling_number_of_eq [simp]:
```
```   468      "ceiling (number_of n :: real) = (number_of n)"
```
```   469 apply (subst real_number_of [symmetric])
```
```   470 apply (rule ceiling_real_of_int)
```
```   471 done
```
```   472
```
```   473 lemma real_of_int_ceiling_diff_one_le [simp]: "real (ceiling r) - 1 \<le> r"
```
```   474 apply (rule neg_le_iff_le [THEN iffD1])
```
```   475 apply (simp add: ceiling_def diff_minus)
```
```   476 done
```
```   477
```
```   478 lemma real_of_int_ceiling_le_add_one [simp]: "real (ceiling r) \<le> r + 1"
```
```   479 apply (insert real_of_int_ceiling_diff_one_le [of r])
```
```   480 apply (simp del: real_of_int_ceiling_diff_one_le)
```
```   481 done
```
```   482
```
```   483 ML
```
```   484 {*
```
```   485 val number_of_less_real_of_int_iff = thm "number_of_less_real_of_int_iff";
```
```   486 val number_of_less_real_of_int_iff2 = thm "number_of_less_real_of_int_iff2";
```
```   487 val number_of_le_real_of_int_iff = thm "number_of_le_real_of_int_iff";
```
```   488 val number_of_le_real_of_int_iff2 = thm "number_of_le_real_of_int_iff2";
```
```   489 val floor_zero = thm "floor_zero";
```
```   490 val floor_real_of_nat_zero = thm "floor_real_of_nat_zero";
```
```   491 val floor_real_of_nat = thm "floor_real_of_nat";
```
```   492 val floor_minus_real_of_nat = thm "floor_minus_real_of_nat";
```
```   493 val floor_real_of_int = thm "floor_real_of_int";
```
```   494 val floor_minus_real_of_int = thm "floor_minus_real_of_int";
```
```   495 val reals_Archimedean6 = thm "reals_Archimedean6";
```
```   496 val reals_Archimedean6a = thm "reals_Archimedean6a";
```
```   497 val reals_Archimedean_6b_int = thm "reals_Archimedean_6b_int";
```
```   498 val reals_Archimedean_6c_int = thm "reals_Archimedean_6c_int";
```
```   499 val real_lb_ub_int = thm "real_lb_ub_int";
```
```   500 val lemma_floor = thm "lemma_floor";
```
```   501 val real_of_int_floor_le = thm "real_of_int_floor_le";
```
```   502 val floor_le = thm "floor_le";
```
```   503 val floor_le2 = thm "floor_le2";
```
```   504 val lemma_floor2 = thm "lemma_floor2";
```
```   505 val real_of_int_floor_cancel = thm "real_of_int_floor_cancel";
```
```   506 val floor_eq = thm "floor_eq";
```
```   507 val floor_eq2 = thm "floor_eq2";
```
```   508 val floor_eq3 = thm "floor_eq3";
```
```   509 val floor_eq4 = thm "floor_eq4";
```
```   510 val floor_number_of_eq = thm "floor_number_of_eq";
```
```   511 val real_of_int_floor_ge_diff_one = thm "real_of_int_floor_ge_diff_one";
```
```   512 val real_of_int_floor_add_one_ge = thm "real_of_int_floor_add_one_ge";
```
```   513 val ceiling_zero = thm "ceiling_zero";
```
```   514 val ceiling_real_of_nat = thm "ceiling_real_of_nat";
```
```   515 val ceiling_real_of_nat_zero = thm "ceiling_real_of_nat_zero";
```
```   516 val ceiling_floor = thm "ceiling_floor";
```
```   517 val floor_ceiling = thm "floor_ceiling";
```
```   518 val real_of_int_ceiling_ge = thm "real_of_int_ceiling_ge";
```
```   519 val ceiling_le = thm "ceiling_le";
```
```   520 val ceiling_le2 = thm "ceiling_le2";
```
```   521 val real_of_int_ceiling_cancel = thm "real_of_int_ceiling_cancel";
```
```   522 val ceiling_eq = thm "ceiling_eq";
```
```   523 val ceiling_eq2 = thm "ceiling_eq2";
```
```   524 val ceiling_eq3 = thm "ceiling_eq3";
```
```   525 val ceiling_real_of_int = thm "ceiling_real_of_int";
```
```   526 val ceiling_number_of_eq = thm "ceiling_number_of_eq";
```
```   527 val real_of_int_ceiling_diff_one_le = thm "real_of_int_ceiling_diff_one_le";
```
```   528 val real_of_int_ceiling_le_add_one = thm "real_of_int_ceiling_le_add_one";
```
```   529 *}
```
```   530
```
```   531
```
```   532 end
```
```   533
```
```   534
```
```   535
```
```   536
```