src/HOL/Real/RComplete.thy
author haftmann
Mon, 29 Sep 2008 12:31:58 +0200
changeset 28401 d5f39173444c
parent 28091 50f2d6ba024c
child 28562 4e74209f113e
permissions -rw-r--r--
separate HOL-Main image
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
     1
(*  Title       : HOL/Real/RComplete.thy
7219
4e3f386c2e37 inserted Id: lines
paulson
parents: 5078
diff changeset
     2
    ID          : $Id$
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
     3
    Author      : Jacques D. Fleuriot, University of Edinburgh
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
     4
    Author      : Larry Paulson, University of Cambridge
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
     5
    Author      : Jeremy Avigad, Carnegie Mellon University
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
     6
    Author      : Florian Zuleger, Johannes Hoelzl, and Simon Funke, TU Muenchen
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
     7
*)
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
     8
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
     9
header {* Completeness of the Reals; Floor and Ceiling Functions *}
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    10
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14641
diff changeset
    11
theory RComplete
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
    12
imports Lubs RealDef
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14641
diff changeset
    13
begin
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    14
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    15
lemma real_sum_of_halves: "x/2 + x/2 = (x::real)"
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    16
  by simp
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    17
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    18
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    19
subsection {* Completeness of Positive Reals *}
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    20
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    21
text {*
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    22
  Supremum property for the set of positive reals
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    23
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    24
  Let @{text "P"} be a non-empty set of positive reals, with an upper
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    25
  bound @{text "y"}.  Then @{text "P"} has a least upper bound
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    26
  (written @{text "S"}).
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    27
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    28
  FIXME: Can the premise be weakened to @{text "\<forall>x \<in> P. x\<le> y"}?
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    29
*}
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    30
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    31
lemma posreal_complete:
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    32
  assumes positive_P: "\<forall>x \<in> P. (0::real) < x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    33
    and not_empty_P: "\<exists>x. x \<in> P"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    34
    and upper_bound_Ex: "\<exists>y. \<forall>x \<in> P. x<y"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    35
  shows "\<exists>S. \<forall>y. (\<exists>x \<in> P. y < x) = (y < S)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    36
proof (rule exI, rule allI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    37
  fix y
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    38
  let ?pP = "{w. real_of_preal w \<in> P}"
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    39
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    40
  show "(\<exists>x\<in>P. y < x) = (y < real_of_preal (psup ?pP))"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    41
  proof (cases "0 < y")
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    42
    assume neg_y: "\<not> 0 < y"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    43
    show ?thesis
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    44
    proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    45
      assume "\<exists>x\<in>P. y < x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    46
      have "\<forall>x. y < real_of_preal x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    47
        using neg_y by (rule real_less_all_real2)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    48
      thus "y < real_of_preal (psup ?pP)" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    49
    next
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    50
      assume "y < real_of_preal (psup ?pP)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    51
      obtain "x" where x_in_P: "x \<in> P" using not_empty_P ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    52
      hence "0 < x" using positive_P by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    53
      hence "y < x" using neg_y by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    54
      thus "\<exists>x \<in> P. y < x" using x_in_P ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    55
    qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    56
  next
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    57
    assume pos_y: "0 < y"
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    58
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    59
    then obtain py where y_is_py: "y = real_of_preal py"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    60
      by (auto simp add: real_gt_zero_preal_Ex)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    61
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23309
diff changeset
    62
    obtain a where "a \<in> P" using not_empty_P ..
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23309
diff changeset
    63
    with positive_P have a_pos: "0 < a" ..
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    64
    then obtain pa where "a = real_of_preal pa"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    65
      by (auto simp add: real_gt_zero_preal_Ex)
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23309
diff changeset
    66
    hence "pa \<in> ?pP" using `a \<in> P` by auto
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    67
    hence pP_not_empty: "?pP \<noteq> {}" by auto
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    68
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    69
    obtain sup where sup: "\<forall>x \<in> P. x < sup"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    70
      using upper_bound_Ex ..
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23309
diff changeset
    71
    from this and `a \<in> P` have "a < sup" ..
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    72
    hence "0 < sup" using a_pos by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    73
    then obtain possup where "sup = real_of_preal possup"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    74
      by (auto simp add: real_gt_zero_preal_Ex)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    75
    hence "\<forall>X \<in> ?pP. X \<le> possup"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    76
      using sup by (auto simp add: real_of_preal_lessI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    77
    with pP_not_empty have psup: "\<And>Z. (\<exists>X \<in> ?pP. Z < X) = (Z < psup ?pP)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    78
      by (rule preal_complete)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    79
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    80
    show ?thesis
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    81
    proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    82
      assume "\<exists>x \<in> P. y < x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    83
      then obtain x where x_in_P: "x \<in> P" and y_less_x: "y < x" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    84
      hence "0 < x" using pos_y by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    85
      then obtain px where x_is_px: "x = real_of_preal px"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    86
        by (auto simp add: real_gt_zero_preal_Ex)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    87
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    88
      have py_less_X: "\<exists>X \<in> ?pP. py < X"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    89
      proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    90
        show "py < px" using y_is_py and x_is_px and y_less_x
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    91
          by (simp add: real_of_preal_lessI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    92
        show "px \<in> ?pP" using x_in_P and x_is_px by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    93
      qed
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
    94
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    95
      have "(\<exists>X \<in> ?pP. py < X) ==> (py < psup ?pP)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    96
        using psup by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    97
      hence "py < psup ?pP" using py_less_X by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    98
      thus "y < real_of_preal (psup {w. real_of_preal w \<in> P})"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
    99
        using y_is_py and pos_y by (simp add: real_of_preal_lessI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   100
    next
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   101
      assume y_less_psup: "y < real_of_preal (psup ?pP)"
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   102
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   103
      hence "py < psup ?pP" using y_is_py
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   104
        by (simp add: real_of_preal_lessI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   105
      then obtain "X" where py_less_X: "py < X" and X_in_pP: "X \<in> ?pP"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   106
        using psup by auto
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   107
      then obtain x where x_is_X: "x = real_of_preal X"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   108
        by (simp add: real_gt_zero_preal_Ex)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   109
      hence "y < x" using py_less_X and y_is_py
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   110
        by (simp add: real_of_preal_lessI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   111
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   112
      moreover have "x \<in> P" using x_is_X and X_in_pP by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   113
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   114
      ultimately show "\<exists> x \<in> P. y < x" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   115
    qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   116
  qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   117
qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   118
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   119
text {*
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   120
  \medskip Completeness properties using @{text "isUb"}, @{text "isLub"} etc.
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   121
*}
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   122
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   123
lemma real_isLub_unique: "[| isLub R S x; isLub R S y |] ==> x = (y::real)"
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   124
  apply (frule isLub_isUb)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   125
  apply (frule_tac x = y in isLub_isUb)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   126
  apply (blast intro!: order_antisym dest!: isLub_le_isUb)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   127
  done
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   128
5078
7b5ea59c0275 Installation of target HOL-Real
paulson
parents:
diff changeset
   129
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   130
text {*
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   131
  \medskip Completeness theorem for the positive reals (again).
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   132
*}
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   133
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   134
lemma posreals_complete:
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   135
  assumes positive_S: "\<forall>x \<in> S. 0 < x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   136
    and not_empty_S: "\<exists>x. x \<in> S"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   137
    and upper_bound_Ex: "\<exists>u. isUb (UNIV::real set) S u"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   138
  shows "\<exists>t. isLub (UNIV::real set) S t"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   139
proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   140
  let ?pS = "{w. real_of_preal w \<in> S}"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   141
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   142
  obtain u where "isUb UNIV S u" using upper_bound_Ex ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   143
  hence sup: "\<forall>x \<in> S. x \<le> u" by (simp add: isUb_def setle_def)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   144
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   145
  obtain x where x_in_S: "x \<in> S" using not_empty_S ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   146
  hence x_gt_zero: "0 < x" using positive_S by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   147
  have  "x \<le> u" using sup and x_in_S ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   148
  hence "0 < u" using x_gt_zero by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   149
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   150
  then obtain pu where u_is_pu: "u = real_of_preal pu"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   151
    by (auto simp add: real_gt_zero_preal_Ex)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   152
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   153
  have pS_less_pu: "\<forall>pa \<in> ?pS. pa \<le> pu"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   154
  proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   155
    fix pa
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   156
    assume "pa \<in> ?pS"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   157
    then obtain a where "a \<in> S" and "a = real_of_preal pa"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   158
      by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   159
    moreover hence "a \<le> u" using sup by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   160
    ultimately show "pa \<le> pu"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   161
      using sup and u_is_pu by (simp add: real_of_preal_le_iff)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   162
  qed
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   163
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   164
  have "\<forall>y \<in> S. y \<le> real_of_preal (psup ?pS)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   165
  proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   166
    fix y
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   167
    assume y_in_S: "y \<in> S"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   168
    hence "0 < y" using positive_S by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   169
    then obtain py where y_is_py: "y = real_of_preal py"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   170
      by (auto simp add: real_gt_zero_preal_Ex)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   171
    hence py_in_pS: "py \<in> ?pS" using y_in_S by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   172
    with pS_less_pu have "py \<le> psup ?pS"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   173
      by (rule preal_psup_le)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   174
    thus "y \<le> real_of_preal (psup ?pS)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   175
      using y_is_py by (simp add: real_of_preal_le_iff)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   176
  qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   177
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   178
  moreover {
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   179
    fix x
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   180
    assume x_ub_S: "\<forall>y\<in>S. y \<le> x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   181
    have "real_of_preal (psup ?pS) \<le> x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   182
    proof -
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   183
      obtain "s" where s_in_S: "s \<in> S" using not_empty_S ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   184
      hence s_pos: "0 < s" using positive_S by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   185
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   186
      hence "\<exists> ps. s = real_of_preal ps" by (simp add: real_gt_zero_preal_Ex)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   187
      then obtain "ps" where s_is_ps: "s = real_of_preal ps" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   188
      hence ps_in_pS: "ps \<in> {w. real_of_preal w \<in> S}" using s_in_S by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   189
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   190
      from x_ub_S have "s \<le> x" using s_in_S ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   191
      hence "0 < x" using s_pos by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   192
      hence "\<exists> px. x = real_of_preal px" by (simp add: real_gt_zero_preal_Ex)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   193
      then obtain "px" where x_is_px: "x = real_of_preal px" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   194
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   195
      have "\<forall>pe \<in> ?pS. pe \<le> px"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   196
      proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   197
	fix pe
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   198
	assume "pe \<in> ?pS"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   199
	hence "real_of_preal pe \<in> S" by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   200
	hence "real_of_preal pe \<le> x" using x_ub_S by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   201
	thus "pe \<le> px" using x_is_px by (simp add: real_of_preal_le_iff)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   202
      qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   203
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   204
      moreover have "?pS \<noteq> {}" using ps_in_pS by auto
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   205
      ultimately have "(psup ?pS) \<le> px" by (simp add: psup_le_ub)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   206
      thus "real_of_preal (psup ?pS) \<le> x" using x_is_px by (simp add: real_of_preal_le_iff)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   207
    qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   208
  }
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   209
  ultimately show "isLub UNIV S (real_of_preal (psup ?pS))"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   210
    by (simp add: isLub_def leastP_def isUb_def setle_def setge_def)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   211
qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   212
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   213
text {*
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   214
  \medskip reals Completeness (again!)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   215
*}
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   216
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   217
lemma reals_complete:
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   218
  assumes notempty_S: "\<exists>X. X \<in> S"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   219
    and exists_Ub: "\<exists>Y. isUb (UNIV::real set) S Y"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   220
  shows "\<exists>t. isLub (UNIV :: real set) S t"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   221
proof -
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   222
  obtain X where X_in_S: "X \<in> S" using notempty_S ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   223
  obtain Y where Y_isUb: "isUb (UNIV::real set) S Y"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   224
    using exists_Ub ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   225
  let ?SHIFT = "{z. \<exists>x \<in>S. z = x + (-X) + 1} \<inter> {x. 0 < x}"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   226
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   227
  {
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   228
    fix x
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   229
    assume "isUb (UNIV::real set) S x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   230
    hence S_le_x: "\<forall> y \<in> S. y <= x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   231
      by (simp add: isUb_def setle_def)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   232
    {
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   233
      fix s
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   234
      assume "s \<in> {z. \<exists>x\<in>S. z = x + - X + 1}"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   235
      hence "\<exists> x \<in> S. s = x + -X + 1" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   236
      then obtain x1 where "x1 \<in> S" and "s = x1 + (-X) + 1" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   237
      moreover hence "x1 \<le> x" using S_le_x by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   238
      ultimately have "s \<le> x + - X + 1" by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   239
    }
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   240
    then have "isUb (UNIV::real set) ?SHIFT (x + (-X) + 1)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   241
      by (auto simp add: isUb_def setle_def)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   242
  } note S_Ub_is_SHIFT_Ub = this
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   243
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   244
  hence "isUb UNIV ?SHIFT (Y + (-X) + 1)" using Y_isUb by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   245
  hence "\<exists>Z. isUb UNIV ?SHIFT Z" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   246
  moreover have "\<forall>y \<in> ?SHIFT. 0 < y" by auto
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   247
  moreover have shifted_not_empty: "\<exists>u. u \<in> ?SHIFT"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   248
    using X_in_S and Y_isUb by auto
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   249
  ultimately obtain t where t_is_Lub: "isLub UNIV ?SHIFT t"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   250
    using posreals_complete [of ?SHIFT] by blast
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   251
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   252
  show ?thesis
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   253
  proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   254
    show "isLub UNIV S (t + X + (-1))"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   255
    proof (rule isLubI2)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   256
      {
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   257
        fix x
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   258
        assume "isUb (UNIV::real set) S x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   259
        hence "isUb (UNIV::real set) (?SHIFT) (x + (-X) + 1)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   260
	  using S_Ub_is_SHIFT_Ub by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   261
        hence "t \<le> (x + (-X) + 1)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   262
	  using t_is_Lub by (simp add: isLub_le_isUb)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   263
        hence "t + X + -1 \<le> x" by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   264
      }
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   265
      then show "(t + X + -1) <=* Collect (isUb UNIV S)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   266
	by (simp add: setgeI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   267
    next
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   268
      show "isUb UNIV S (t + X + -1)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   269
      proof -
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   270
        {
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   271
          fix y
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   272
          assume y_in_S: "y \<in> S"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   273
          have "y \<le> t + X + -1"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   274
          proof -
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   275
            obtain "u" where u_in_shift: "u \<in> ?SHIFT" using shifted_not_empty ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   276
            hence "\<exists> x \<in> S. u = x + - X + 1" by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   277
            then obtain "x" where x_and_u: "u = x + - X + 1" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   278
            have u_le_t: "u \<le> t" using u_in_shift and t_is_Lub by (simp add: isLubD2)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   279
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   280
            show ?thesis
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   281
            proof cases
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   282
              assume "y \<le> x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   283
              moreover have "x = u + X + - 1" using x_and_u by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   284
              moreover have "u + X + - 1  \<le> t + X + -1" using u_le_t by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   285
              ultimately show "y  \<le> t + X + -1" by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   286
            next
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   287
              assume "~(y \<le> x)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   288
              hence x_less_y: "x < y" by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   289
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   290
              have "x + (-X) + 1 \<in> ?SHIFT" using x_and_u and u_in_shift by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   291
              hence "0 < x + (-X) + 1" by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   292
              hence "0 < y + (-X) + 1" using x_less_y by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   293
              hence "y + (-X) + 1 \<in> ?SHIFT" using y_in_S by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   294
              hence "y + (-X) + 1 \<le> t" using t_is_Lub  by (simp add: isLubD2)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   295
              thus ?thesis by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   296
            qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   297
          qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   298
        }
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   299
        then show ?thesis by (simp add: isUb_def setle_def)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   300
      qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   301
    qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   302
  qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   303
qed
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   304
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   305
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   306
subsection {* The Archimedean Property of the Reals *}
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   307
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   308
theorem reals_Archimedean:
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   309
  assumes x_pos: "0 < x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   310
  shows "\<exists>n. inverse (real (Suc n)) < x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   311
proof (rule ccontr)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   312
  assume contr: "\<not> ?thesis"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   313
  have "\<forall>n. x * real (Suc n) <= 1"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   314
  proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   315
    fix n
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   316
    from contr have "x \<le> inverse (real (Suc n))"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   317
      by (simp add: linorder_not_less)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   318
    hence "x \<le> (1 / (real (Suc n)))"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   319
      by (simp add: inverse_eq_divide)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   320
    moreover have "0 \<le> real (Suc n)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   321
      by (rule real_of_nat_ge_zero)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   322
    ultimately have "x * real (Suc n) \<le> (1 / real (Suc n)) * real (Suc n)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   323
      by (rule mult_right_mono)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   324
    thus "x * real (Suc n) \<le> 1" by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   325
  qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   326
  hence "{z. \<exists>n. z = x * (real (Suc n))} *<= 1"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   327
    by (simp add: setle_def, safe, rule spec)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   328
  hence "isUb (UNIV::real set) {z. \<exists>n. z = x * (real (Suc n))} 1"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   329
    by (simp add: isUbI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   330
  hence "\<exists>Y. isUb (UNIV::real set) {z. \<exists>n. z = x* (real (Suc n))} Y" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   331
  moreover have "\<exists>X. X \<in> {z. \<exists>n. z = x* (real (Suc n))}" by auto
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   332
  ultimately have "\<exists>t. isLub UNIV {z. \<exists>n. z = x * real (Suc n)} t"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   333
    by (simp add: reals_complete)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   334
  then obtain "t" where
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   335
    t_is_Lub: "isLub UNIV {z. \<exists>n. z = x * real (Suc n)} t" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   336
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   337
  have "\<forall>n::nat. x * real n \<le> t + - x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   338
  proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   339
    fix n
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   340
    from t_is_Lub have "x * real (Suc n) \<le> t"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   341
      by (simp add: isLubD2)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   342
    hence  "x * (real n) + x \<le> t"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   343
      by (simp add: right_distrib real_of_nat_Suc)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   344
    thus  "x * (real n) \<le> t + - x" by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   345
  qed
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   346
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   347
  hence "\<forall>m. x * real (Suc m) \<le> t + - x" by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   348
  hence "{z. \<exists>n. z = x * (real (Suc n))}  *<= (t + - x)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   349
    by (auto simp add: setle_def)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   350
  hence "isUb (UNIV::real set) {z. \<exists>n. z = x * (real (Suc n))} (t + (-x))"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   351
    by (simp add: isUbI)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   352
  hence "t \<le> t + - x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   353
    using t_is_Lub by (simp add: isLub_le_isUb)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   354
  thus False using x_pos by arith
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   355
qed
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   356
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   357
text {*
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   358
  There must be other proofs, e.g. @{text "Suc"} of the largest
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   359
  integer in the cut representing @{text "x"}.
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   360
*}
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   361
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   362
lemma reals_Archimedean2: "\<exists>n. (x::real) < real (n::nat)"
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   363
proof cases
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   364
  assume "x \<le> 0"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   365
  hence "x < real (1::nat)" by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   366
  thus ?thesis ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   367
next
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   368
  assume "\<not> x \<le> 0"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   369
  hence x_greater_zero: "0 < x" by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   370
  hence "0 < inverse x" by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   371
  then obtain n where "inverse (real (Suc n)) < inverse x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   372
    using reals_Archimedean by blast
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   373
  hence "inverse (real (Suc n)) * x < inverse x * x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   374
    using x_greater_zero by (rule mult_strict_right_mono)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   375
  hence "inverse (real (Suc n)) * x < 1"
23008
c4a259f3bbcc avoid using real_mult_inverse_left; cleaned up
huffman
parents: 22998
diff changeset
   376
    using x_greater_zero by simp
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   377
  hence "real (Suc n) * (inverse (real (Suc n)) * x) < real (Suc n) * 1"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   378
    by (rule mult_strict_left_mono) simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   379
  hence "x < real (Suc n)"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 23389
diff changeset
   380
    by (simp add: ring_simps)
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   381
  thus "\<exists>(n::nat). x < real n" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   382
qed
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   383
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   384
lemma reals_Archimedean3:
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   385
  assumes x_greater_zero: "0 < x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   386
  shows "\<forall>(y::real). \<exists>(n::nat). y < real n * x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   387
proof
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   388
  fix y
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   389
  have x_not_zero: "x \<noteq> 0" using x_greater_zero by simp
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   390
  obtain n where "y * inverse x < real (n::nat)"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   391
    using reals_Archimedean2 ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   392
  hence "y * inverse x * x < real n * x"
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   393
    using x_greater_zero by (simp add: mult_strict_right_mono)
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   394
  hence "x * inverse x * y < x * real n"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 23389
diff changeset
   395
    by (simp add: ring_simps)
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   396
  hence "y < real (n::nat) * x"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 23389
diff changeset
   397
    using x_not_zero by (simp add: ring_simps)
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   398
  thus "\<exists>(n::nat). y < real n * x" ..
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   399
qed
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
   400
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   401
lemma reals_Archimedean6:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   402
     "0 \<le> r ==> \<exists>(n::nat). real (n - 1) \<le> r & r < real (n)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   403
apply (insert reals_Archimedean2 [of r], safe)
23012
496b42cf588d remove dependence on Hilbert_Choice.thy
huffman
parents: 23008
diff changeset
   404
apply (subgoal_tac "\<exists>x::nat. r < real x \<and> (\<forall>y. r < real y \<longrightarrow> x \<le> y)", auto)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   405
apply (rule_tac x = x in exI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   406
apply (case_tac x, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   407
apply (rename_tac x')
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   408
apply (drule_tac x = x' in spec, simp)
23012
496b42cf588d remove dependence on Hilbert_Choice.thy
huffman
parents: 23008
diff changeset
   409
apply (rule_tac x="LEAST n. r < real n" in exI, safe)
496b42cf588d remove dependence on Hilbert_Choice.thy
huffman
parents: 23008
diff changeset
   410
apply (erule LeastI, erule Least_le)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   411
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   412
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   413
lemma reals_Archimedean6a: "0 \<le> r ==> \<exists>n. real (n) \<le> r & r < real (Suc n)"
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   414
  by (drule reals_Archimedean6) auto
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   415
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   416
lemma reals_Archimedean_6b_int:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   417
     "0 \<le> r ==> \<exists>n::int. real n \<le> r & r < real (n+1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   418
apply (drule reals_Archimedean6a, auto)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   419
apply (rule_tac x = "int n" in exI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   420
apply (simp add: real_of_int_real_of_nat real_of_nat_Suc)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   421
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   422
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   423
lemma reals_Archimedean_6c_int:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   424
     "r < 0 ==> \<exists>n::int. real n \<le> r & r < real (n+1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   425
apply (rule reals_Archimedean_6b_int [of "-r", THEN exE], simp, auto)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   426
apply (rename_tac n)
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 21404
diff changeset
   427
apply (drule order_le_imp_less_or_eq, auto)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   428
apply (rule_tac x = "- n - 1" in exI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   429
apply (rule_tac [2] x = "- n" in exI, auto)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   430
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   431
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   432
28091
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   433
subsection{*Density of the Rational Reals in the Reals*}
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   434
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   435
text{* This density proof is due to Stefan Richter and was ported by TN.  The
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   436
original source is \emph{Real Analysis} by H.L. Royden.
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   437
It employs the Archimedean property of the reals. *}
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   438
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   439
lemma Rats_dense_in_nn_real: fixes x::real
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   440
assumes "0\<le>x" and "x<y" shows "\<exists>r \<in> \<rat>.  x<r \<and> r<y"
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   441
proof -
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   442
  from `x<y` have "0 < y-x" by simp
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   443
  with reals_Archimedean obtain q::nat 
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   444
    where q: "inverse (real q) < y-x" and "0 < real q" by auto  
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   445
  def p \<equiv> "LEAST n.  y \<le> real (Suc n)/real q"  
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   446
  from reals_Archimedean2 obtain n::nat where "y * real q < real n" by auto
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   447
  with `0 < real q` have ex: "y \<le> real n/real q" (is "?P n")
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   448
    by (simp add: pos_less_divide_eq[THEN sym])
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   449
  also from assms have "\<not> y \<le> real (0::nat) / real q" by simp
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   450
  ultimately have main: "(LEAST n. y \<le> real n/real q) = Suc p"
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   451
    by (unfold p_def) (rule Least_Suc)
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   452
  also from ex have "?P (LEAST x. ?P x)" by (rule LeastI)
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   453
  ultimately have suc: "y \<le> real (Suc p) / real q" by simp
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   454
  def r \<equiv> "real p/real q"
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   455
  have "x = y-(y-x)" by simp
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   456
  also from suc q have "\<dots> < real (Suc p)/real q - inverse (real q)" by arith
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   457
  also have "\<dots> = real p / real q"
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   458
    by (simp only: inverse_eq_divide real_diff_def real_of_nat_Suc 
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   459
    minus_divide_left add_divide_distrib[THEN sym]) simp
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   460
  finally have "x<r" by (unfold r_def)
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   461
  have "p<Suc p" .. also note main[THEN sym]
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   462
  finally have "\<not> ?P p"  by (rule not_less_Least)
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   463
  hence "r<y" by (simp add: r_def)
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   464
  from r_def have "r \<in> \<rat>" by simp
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   465
  with `x<r` `r<y` show ?thesis by fast
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   466
qed
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   467
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   468
theorem Rats_dense_in_real: fixes x y :: real
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   469
assumes "x<y" shows "\<exists>r \<in> \<rat>.  x<r \<and> r<y"
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   470
proof -
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   471
  from reals_Archimedean2 obtain n::nat where "-x < real n" by auto
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   472
  hence "0 \<le> x + real n" by arith
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   473
  also from `x<y` have "x + real n < y + real n" by arith
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   474
  ultimately have "\<exists>r \<in> \<rat>. x + real n < r \<and> r < y + real n"
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   475
    by(rule Rats_dense_in_nn_real)
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   476
  then obtain r where "r \<in> \<rat>" and r2: "x + real n < r" 
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   477
    and r3: "r < y + real n"
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   478
    by blast
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   479
  have "r - real n = r + real (int n)/real (-1::int)" by simp
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   480
  also from `r\<in>\<rat>` have "r + real (int n)/real (-1::int) \<in> \<rat>" by simp
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   481
  also from r2 have "x < r - real n" by arith
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   482
  moreover from r3 have "r - real n < y" by arith
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   483
  ultimately show ?thesis by fast
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   484
qed
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   485
50f2d6ba024c Streamlined parts of Complex/ex/DenumRat and AFP/Integration/Rats and
nipkow
parents: 27435
diff changeset
   486
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   487
subsection{*Floor and Ceiling Functions from the Reals to the Integers*}
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   488
19765
dfe940911617 misc cleanup;
wenzelm
parents: 16893
diff changeset
   489
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   490
  floor :: "real => int" where
27435
b3f8e9bdf9a7 cleaned up some code generator configuration
haftmann
parents: 25162
diff changeset
   491
  [code func del]: "floor r = (LEAST n::int. r < real (n+1))"
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   492
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   493
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   494
  ceiling :: "real => int" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 16893
diff changeset
   495
  "ceiling r = - floor (- r)"
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   496
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 20217
diff changeset
   497
notation (xsymbols)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   498
  floor  ("\<lfloor>_\<rfloor>") and
19765
dfe940911617 misc cleanup;
wenzelm
parents: 16893
diff changeset
   499
  ceiling  ("\<lceil>_\<rceil>")
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   500
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 20217
diff changeset
   501
notation (HTML output)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   502
  floor  ("\<lfloor>_\<rfloor>") and
19765
dfe940911617 misc cleanup;
wenzelm
parents: 16893
diff changeset
   503
  ceiling  ("\<lceil>_\<rceil>")
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   504
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   505
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   506
lemma number_of_less_real_of_int_iff [simp]:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   507
     "((number_of n) < real (m::int)) = (number_of n < m)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   508
apply auto
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   509
apply (rule real_of_int_less_iff [THEN iffD1])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   510
apply (drule_tac [2] real_of_int_less_iff [THEN iffD2], auto)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   511
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   512
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   513
lemma number_of_less_real_of_int_iff2 [simp]:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   514
     "(real (m::int) < (number_of n)) = (m < number_of n)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   515
apply auto
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   516
apply (rule real_of_int_less_iff [THEN iffD1])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   517
apply (drule_tac [2] real_of_int_less_iff [THEN iffD2], auto)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   518
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   519
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   520
lemma number_of_le_real_of_int_iff [simp]:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   521
     "((number_of n) \<le> real (m::int)) = (number_of n \<le> m)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   522
by (simp add: linorder_not_less [symmetric])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   523
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   524
lemma number_of_le_real_of_int_iff2 [simp]:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   525
     "(real (m::int) \<le> (number_of n)) = (m \<le> number_of n)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   526
by (simp add: linorder_not_less [symmetric])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   527
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   528
lemma floor_zero [simp]: "floor 0 = 0"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   529
apply (simp add: floor_def del: real_of_int_add)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   530
apply (rule Least_equality)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   531
apply simp_all
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   532
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   533
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   534
lemma floor_real_of_nat_zero [simp]: "floor (real (0::nat)) = 0"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   535
by auto
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   536
24355
93d78fdeb55a remove int_of_nat
huffman
parents: 23477
diff changeset
   537
lemma floor_real_of_nat [simp]: "floor (real (n::nat)) = int n"
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   538
apply (simp only: floor_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   539
apply (rule Least_equality)
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
   540
apply (drule_tac [2] real_of_int_of_nat_eq [THEN ssubst])
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   541
apply (drule_tac [2] real_of_int_less_iff [THEN iffD1])
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
   542
apply simp_all
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   543
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   544
24355
93d78fdeb55a remove int_of_nat
huffman
parents: 23477
diff changeset
   545
lemma floor_minus_real_of_nat [simp]: "floor (- real (n::nat)) = - int n"
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   546
apply (simp only: floor_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   547
apply (rule Least_equality)
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
   548
apply (drule_tac [2] real_of_int_of_nat_eq [THEN ssubst])
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   549
apply (drule_tac [2] real_of_int_minus [THEN sym, THEN subst])
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   550
apply (drule_tac [2] real_of_int_less_iff [THEN iffD1])
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
   551
apply simp_all
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   552
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   553
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   554
lemma floor_real_of_int [simp]: "floor (real (n::int)) = n"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   555
apply (simp only: floor_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   556
apply (rule Least_equality)
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
   557
apply auto
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   558
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   559
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   560
lemma floor_minus_real_of_int [simp]: "floor (- real (n::int)) = - n"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   561
apply (simp only: floor_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   562
apply (rule Least_equality)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   563
apply (drule_tac [2] real_of_int_minus [THEN sym, THEN subst])
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
   564
apply auto
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   565
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   566
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   567
lemma real_lb_ub_int: " \<exists>n::int. real n \<le> r & r < real (n+1)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   568
apply (case_tac "r < 0")
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   569
apply (blast intro: reals_Archimedean_6c_int)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   570
apply (simp only: linorder_not_less)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   571
apply (blast intro: reals_Archimedean_6b_int reals_Archimedean_6c_int)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   572
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   573
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   574
lemma lemma_floor:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   575
  assumes a1: "real m \<le> r" and a2: "r < real n + 1"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   576
  shows "m \<le> (n::int)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   577
proof -
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23309
diff changeset
   578
  have "real m < real n + 1" using a1 a2 by (rule order_le_less_trans)
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23309
diff changeset
   579
  also have "... = real (n + 1)" by simp
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23309
diff changeset
   580
  finally have "m < n + 1" by (simp only: real_of_int_less_iff)
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   581
  thus ?thesis by arith
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   582
qed
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   583
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   584
lemma real_of_int_floor_le [simp]: "real (floor r) \<le> r"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   585
apply (simp add: floor_def Least_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   586
apply (insert real_lb_ub_int [of r], safe)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   587
apply (rule theI2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   588
apply auto
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   589
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   590
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   591
lemma floor_mono: "x < y ==> floor x \<le> floor y"
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   592
apply (simp add: floor_def Least_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   593
apply (insert real_lb_ub_int [of x])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   594
apply (insert real_lb_ub_int [of y], safe)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   595
apply (rule theI2)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   596
apply (rule_tac [3] theI2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   597
apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   598
apply (erule conjI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   599
apply (auto simp add: order_eq_iff int_le_real_less)
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   600
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   601
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   602
lemma floor_mono2: "x \<le> y ==> floor x \<le> floor y"
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 21404
diff changeset
   603
by (auto dest: order_le_imp_less_or_eq simp add: floor_mono)
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   604
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   605
lemma lemma_floor2: "real n < real (x::int) + 1 ==> n \<le> x"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   606
by (auto intro: lemma_floor)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   607
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   608
lemma real_of_int_floor_cancel [simp]:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   609
    "(real (floor x) = x) = (\<exists>n::int. x = real n)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   610
apply (simp add: floor_def Least_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   611
apply (insert real_lb_ub_int [of x], erule exE)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   612
apply (rule theI2)
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   613
apply (auto intro: lemma_floor)
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   614
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   615
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   616
lemma floor_eq: "[| real n < x; x < real n + 1 |] ==> floor x = n"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   617
apply (simp add: floor_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   618
apply (rule Least_equality)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   619
apply (auto intro: lemma_floor)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   620
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   621
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   622
lemma floor_eq2: "[| real n \<le> x; x < real n + 1 |] ==> floor x = n"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   623
apply (simp add: floor_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   624
apply (rule Least_equality)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   625
apply (auto intro: lemma_floor)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   626
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   627
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   628
lemma floor_eq3: "[| real n < x; x < real (Suc n) |] ==> nat(floor x) = n"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   629
apply (rule inj_int [THEN injD])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   630
apply (simp add: real_of_nat_Suc)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15234
diff changeset
   631
apply (simp add: real_of_nat_Suc floor_eq floor_eq [where n = "int n"])
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   632
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   633
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   634
lemma floor_eq4: "[| real n \<le> x; x < real (Suc n) |] ==> nat(floor x) = n"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   635
apply (drule order_le_imp_less_or_eq)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   636
apply (auto intro: floor_eq3)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   637
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   638
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   639
lemma floor_number_of_eq [simp]:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   640
     "floor(number_of n :: real) = (number_of n :: int)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   641
apply (subst real_number_of [symmetric])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   642
apply (rule floor_real_of_int)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   643
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   644
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   645
lemma floor_one [simp]: "floor 1 = 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   646
  apply (rule trans)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   647
  prefer 2
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   648
  apply (rule floor_real_of_int)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   649
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   650
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   651
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   652
lemma real_of_int_floor_ge_diff_one [simp]: "r - 1 \<le> real(floor r)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   653
apply (simp add: floor_def Least_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   654
apply (insert real_lb_ub_int [of r], safe)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   655
apply (rule theI2)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   656
apply (auto intro: lemma_floor)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   657
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   658
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   659
lemma real_of_int_floor_gt_diff_one [simp]: "r - 1 < real(floor r)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   660
apply (simp add: floor_def Least_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   661
apply (insert real_lb_ub_int [of r], safe)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   662
apply (rule theI2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   663
apply (auto intro: lemma_floor)
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   664
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   665
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   666
lemma real_of_int_floor_add_one_ge [simp]: "r \<le> real(floor r) + 1"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   667
apply (insert real_of_int_floor_ge_diff_one [of r])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   668
apply (auto simp del: real_of_int_floor_ge_diff_one)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   669
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   670
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   671
lemma real_of_int_floor_add_one_gt [simp]: "r < real(floor r) + 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   672
apply (insert real_of_int_floor_gt_diff_one [of r])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   673
apply (auto simp del: real_of_int_floor_gt_diff_one)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   674
done
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   675
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   676
lemma le_floor: "real a <= x ==> a <= floor x"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   677
  apply (subgoal_tac "a < floor x + 1")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   678
  apply arith
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   679
  apply (subst real_of_int_less_iff [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   680
  apply simp
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   681
  apply (insert real_of_int_floor_add_one_gt [of x])
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   682
  apply arith
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   683
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   684
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   685
lemma real_le_floor: "a <= floor x ==> real a <= x"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   686
  apply (rule order_trans)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   687
  prefer 2
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   688
  apply (rule real_of_int_floor_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   689
  apply (subst real_of_int_le_iff)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   690
  apply assumption
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   691
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   692
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   693
lemma le_floor_eq: "(a <= floor x) = (real a <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   694
  apply (rule iffI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   695
  apply (erule real_le_floor)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   696
  apply (erule le_floor)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   697
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   698
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   699
lemma le_floor_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   700
    "(number_of n <= floor x) = (number_of n <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   701
by (simp add: le_floor_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   702
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   703
lemma le_floor_eq_zero [simp]: "(0 <= floor x) = (0 <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   704
by (simp add: le_floor_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   705
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   706
lemma le_floor_eq_one [simp]: "(1 <= floor x) = (1 <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   707
by (simp add: le_floor_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   708
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   709
lemma floor_less_eq: "(floor x < a) = (x < real a)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   710
  apply (subst linorder_not_le [THEN sym])+
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   711
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   712
  apply (rule le_floor_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   713
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   714
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   715
lemma floor_less_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   716
    "(floor x < number_of n) = (x < number_of n)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   717
by (simp add: floor_less_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   718
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   719
lemma floor_less_eq_zero [simp]: "(floor x < 0) = (x < 0)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   720
by (simp add: floor_less_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   721
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   722
lemma floor_less_eq_one [simp]: "(floor x < 1) = (x < 1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   723
by (simp add: floor_less_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   724
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   725
lemma less_floor_eq: "(a < floor x) = (real a + 1 <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   726
  apply (insert le_floor_eq [of "a + 1" x])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   727
  apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   728
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   729
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   730
lemma less_floor_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   731
    "(number_of n < floor x) = (number_of n + 1 <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   732
by (simp add: less_floor_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   733
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   734
lemma less_floor_eq_zero [simp]: "(0 < floor x) = (1 <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   735
by (simp add: less_floor_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   736
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   737
lemma less_floor_eq_one [simp]: "(1 < floor x) = (2 <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   738
by (simp add: less_floor_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   739
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   740
lemma floor_le_eq: "(floor x <= a) = (x < real a + 1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   741
  apply (insert floor_less_eq [of x "a + 1"])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   742
  apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   743
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   744
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   745
lemma floor_le_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   746
    "(floor x <= number_of n) = (x < number_of n + 1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   747
by (simp add: floor_le_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   748
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   749
lemma floor_le_eq_zero [simp]: "(floor x <= 0) = (x < 1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   750
by (simp add: floor_le_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   751
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   752
lemma floor_le_eq_one [simp]: "(floor x <= 1) = (x < 2)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   753
by (simp add: floor_le_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   754
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   755
lemma floor_add [simp]: "floor (x + real a) = floor x + a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   756
  apply (subst order_eq_iff)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   757
  apply (rule conjI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   758
  prefer 2
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   759
  apply (subgoal_tac "floor x + a < floor (x + real a) + 1")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   760
  apply arith
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   761
  apply (subst real_of_int_less_iff [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   762
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   763
  apply (subgoal_tac "x + real a < real(floor(x + real a)) + 1")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   764
  apply (subgoal_tac "real (floor x) <= x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   765
  apply arith
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   766
  apply (rule real_of_int_floor_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   767
  apply (rule real_of_int_floor_add_one_gt)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   768
  apply (subgoal_tac "floor (x + real a) < floor x + a + 1")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   769
  apply arith
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   770
  apply (subst real_of_int_less_iff [THEN sym])
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   771
  apply simp
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   772
  apply (subgoal_tac "real(floor(x + real a)) <= x + real a")
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   773
  apply (subgoal_tac "x < real(floor x) + 1")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   774
  apply arith
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   775
  apply (rule real_of_int_floor_add_one_gt)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   776
  apply (rule real_of_int_floor_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   777
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   778
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   779
lemma floor_add_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   780
    "floor (x + number_of n) = floor x + number_of n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   781
  apply (subst floor_add [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   782
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   783
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   784
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   785
lemma floor_add_one [simp]: "floor (x + 1) = floor x + 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   786
  apply (subst floor_add [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   787
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   788
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   789
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   790
lemma floor_subtract [simp]: "floor (x - real a) = floor x - a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   791
  apply (subst diff_minus)+
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   792
  apply (subst real_of_int_minus [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   793
  apply (rule floor_add)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   794
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   795
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   796
lemma floor_subtract_number_of [simp]: "floor (x - number_of n) =
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   797
    floor x - number_of n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   798
  apply (subst floor_subtract [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   799
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   800
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   801
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   802
lemma floor_subtract_one [simp]: "floor (x - 1) = floor x - 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   803
  apply (subst floor_subtract [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   804
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   805
done
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   806
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   807
lemma ceiling_zero [simp]: "ceiling 0 = 0"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   808
by (simp add: ceiling_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   809
24355
93d78fdeb55a remove int_of_nat
huffman
parents: 23477
diff changeset
   810
lemma ceiling_real_of_nat [simp]: "ceiling (real (n::nat)) = int n"
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   811
by (simp add: ceiling_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   812
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   813
lemma ceiling_real_of_nat_zero [simp]: "ceiling (real (0::nat)) = 0"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   814
by auto
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   815
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   816
lemma ceiling_floor [simp]: "ceiling (real (floor r)) = floor r"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   817
by (simp add: ceiling_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   818
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   819
lemma floor_ceiling [simp]: "floor (real (ceiling r)) = ceiling r"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   820
by (simp add: ceiling_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   821
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   822
lemma real_of_int_ceiling_ge [simp]: "r \<le> real (ceiling r)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   823
apply (simp add: ceiling_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   824
apply (subst le_minus_iff, simp)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   825
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   826
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   827
lemma ceiling_mono: "x < y ==> ceiling x \<le> ceiling y"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   828
by (simp add: floor_mono ceiling_def)
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   829
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   830
lemma ceiling_mono2: "x \<le> y ==> ceiling x \<le> ceiling y"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   831
by (simp add: floor_mono2 ceiling_def)
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   832
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   833
lemma real_of_int_ceiling_cancel [simp]:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   834
     "(real (ceiling x) = x) = (\<exists>n::int. x = real n)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   835
apply (auto simp add: ceiling_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   836
apply (drule arg_cong [where f = uminus], auto)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   837
apply (rule_tac x = "-n" in exI, auto)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   838
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   839
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   840
lemma ceiling_eq: "[| real n < x; x < real n + 1 |] ==> ceiling x = n + 1"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   841
apply (simp add: ceiling_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   842
apply (rule minus_equation_iff [THEN iffD1])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   843
apply (simp add: floor_eq [where n = "-(n+1)"])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   844
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   845
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   846
lemma ceiling_eq2: "[| real n < x; x \<le> real n + 1 |] ==> ceiling x = n + 1"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   847
by (simp add: ceiling_def floor_eq2 [where n = "-(n+1)"])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   848
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   849
lemma ceiling_eq3: "[| real n - 1 < x; x \<le> real n  |] ==> ceiling x = n"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   850
by (simp add: ceiling_def floor_eq2 [where n = "-n"])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   851
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   852
lemma ceiling_real_of_int [simp]: "ceiling (real (n::int)) = n"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   853
by (simp add: ceiling_def)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   854
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   855
lemma ceiling_number_of_eq [simp]:
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   856
     "ceiling (number_of n :: real) = (number_of n)"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   857
apply (subst real_number_of [symmetric])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   858
apply (rule ceiling_real_of_int)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   859
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   860
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   861
lemma ceiling_one [simp]: "ceiling 1 = 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   862
  by (unfold ceiling_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   863
14641
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   864
lemma real_of_int_ceiling_diff_one_le [simp]: "real (ceiling r) - 1 \<le> r"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   865
apply (rule neg_le_iff_le [THEN iffD1])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   866
apply (simp add: ceiling_def diff_minus)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   867
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   868
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   869
lemma real_of_int_ceiling_le_add_one [simp]: "real (ceiling r) \<le> r + 1"
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   870
apply (insert real_of_int_ceiling_diff_one_le [of r])
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   871
apply (simp del: real_of_int_ceiling_diff_one_le)
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   872
done
79b7bd936264 moved Complex/NSInduct and Hyperreal/IntFloor to more appropriate
paulson
parents: 14476
diff changeset
   873
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   874
lemma ceiling_le: "x <= real a ==> ceiling x <= a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   875
  apply (unfold ceiling_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   876
  apply (subgoal_tac "-a <= floor(- x)")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   877
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   878
  apply (rule le_floor)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   879
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   880
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   881
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   882
lemma ceiling_le_real: "ceiling x <= a ==> x <= real a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   883
  apply (unfold ceiling_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   884
  apply (subgoal_tac "real(- a) <= - x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   885
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   886
  apply (rule real_le_floor)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   887
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   888
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   889
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   890
lemma ceiling_le_eq: "(ceiling x <= a) = (x <= real a)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   891
  apply (rule iffI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   892
  apply (erule ceiling_le_real)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   893
  apply (erule ceiling_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   894
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   895
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   896
lemma ceiling_le_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   897
    "(ceiling x <= number_of n) = (x <= number_of n)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   898
by (simp add: ceiling_le_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   899
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   900
lemma ceiling_le_zero_eq [simp]: "(ceiling x <= 0) = (x <= 0)"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   901
by (simp add: ceiling_le_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   902
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   903
lemma ceiling_le_eq_one [simp]: "(ceiling x <= 1) = (x <= 1)"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   904
by (simp add: ceiling_le_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   905
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   906
lemma less_ceiling_eq: "(a < ceiling x) = (real a < x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   907
  apply (subst linorder_not_le [THEN sym])+
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   908
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   909
  apply (rule ceiling_le_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   910
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   911
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   912
lemma less_ceiling_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   913
    "(number_of n < ceiling x) = (number_of n < x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   914
by (simp add: less_ceiling_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   915
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   916
lemma less_ceiling_eq_zero [simp]: "(0 < ceiling x) = (0 < x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   917
by (simp add: less_ceiling_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   918
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   919
lemma less_ceiling_eq_one [simp]: "(1 < ceiling x) = (1 < x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   920
by (simp add: less_ceiling_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   921
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   922
lemma ceiling_less_eq: "(ceiling x < a) = (x <= real a - 1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   923
  apply (insert ceiling_le_eq [of x "a - 1"])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   924
  apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   925
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   926
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   927
lemma ceiling_less_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   928
    "(ceiling x < number_of n) = (x <= number_of n - 1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   929
by (simp add: ceiling_less_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   930
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   931
lemma ceiling_less_eq_zero [simp]: "(ceiling x < 0) = (x <= -1)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   932
by (simp add: ceiling_less_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   933
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   934
lemma ceiling_less_eq_one [simp]: "(ceiling x < 1) = (x <= 0)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   935
by (simp add: ceiling_less_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   936
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   937
lemma le_ceiling_eq: "(a <= ceiling x) = (real a - 1 < x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   938
  apply (insert less_ceiling_eq [of "a - 1" x])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   939
  apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   940
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   941
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   942
lemma le_ceiling_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   943
    "(number_of n <= ceiling x) = (number_of n - 1 < x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   944
by (simp add: le_ceiling_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   945
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   946
lemma le_ceiling_eq_zero [simp]: "(0 <= ceiling x) = (-1 < x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   947
by (simp add: le_ceiling_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   948
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   949
lemma le_ceiling_eq_one [simp]: "(1 <= ceiling x) = (0 < x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   950
by (simp add: le_ceiling_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   951
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   952
lemma ceiling_add [simp]: "ceiling (x + real a) = ceiling x + a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   953
  apply (unfold ceiling_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   954
  apply (subst real_of_int_minus [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   955
  apply (subst floor_add)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   956
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   957
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   958
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   959
lemma ceiling_add_number_of [simp]: "ceiling (x + number_of n) =
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   960
    ceiling x + number_of n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   961
  apply (subst ceiling_add [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   962
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   963
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   964
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   965
lemma ceiling_add_one [simp]: "ceiling (x + 1) = ceiling x + 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   966
  apply (subst ceiling_add [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   967
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   968
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   969
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   970
lemma ceiling_subtract [simp]: "ceiling (x - real a) = ceiling x - a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   971
  apply (subst diff_minus)+
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   972
  apply (subst real_of_int_minus [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   973
  apply (rule ceiling_add)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   974
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   975
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
   976
lemma ceiling_subtract_number_of [simp]: "ceiling (x - number_of n) =
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   977
    ceiling x - number_of n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   978
  apply (subst ceiling_subtract [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   979
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   980
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   981
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   982
lemma ceiling_subtract_one [simp]: "ceiling (x - 1) = ceiling x - 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   983
  apply (subst ceiling_subtract [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   984
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   985
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   986
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   987
subsection {* Versions for the natural numbers *}
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   988
19765
dfe940911617 misc cleanup;
wenzelm
parents: 16893
diff changeset
   989
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   990
  natfloor :: "real => nat" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 16893
diff changeset
   991
  "natfloor x = nat(floor x)"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   992
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   993
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
   994
  natceiling :: "real => nat" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 16893
diff changeset
   995
  "natceiling x = nat(ceiling x)"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   996
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   997
lemma natfloor_zero [simp]: "natfloor 0 = 0"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   998
  by (unfold natfloor_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
   999
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1000
lemma natfloor_one [simp]: "natfloor 1 = 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1001
  by (unfold natfloor_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1002
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1003
lemma zero_le_natfloor [simp]: "0 <= natfloor x"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1004
  by (unfold natfloor_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1005
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1006
lemma natfloor_number_of_eq [simp]: "natfloor (number_of n) = number_of n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1007
  by (unfold natfloor_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1008
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1009
lemma natfloor_real_of_nat [simp]: "natfloor(real n) = n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1010
  by (unfold natfloor_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1011
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1012
lemma real_natfloor_le: "0 <= x ==> real(natfloor x) <= x"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1013
  by (unfold natfloor_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1014
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1015
lemma natfloor_neg: "x <= 0 ==> natfloor x = 0"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1016
  apply (unfold natfloor_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1017
  apply (subgoal_tac "floor x <= floor 0")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1018
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1019
  apply (erule floor_mono2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1020
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1021
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1022
lemma natfloor_mono: "x <= y ==> natfloor x <= natfloor y"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1023
  apply (case_tac "0 <= x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1024
  apply (subst natfloor_def)+
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1025
  apply (subst nat_le_eq_zle)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1026
  apply force
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1027
  apply (erule floor_mono2)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1028
  apply (subst natfloor_neg)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1029
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1030
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1031
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1032
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1033
lemma le_natfloor: "real x <= a ==> x <= natfloor a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1034
  apply (unfold natfloor_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1035
  apply (subst nat_int [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1036
  apply (subst nat_le_eq_zle)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1037
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1038
  apply (rule le_floor)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1039
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1040
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1041
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1042
lemma le_natfloor_eq: "0 <= x ==> (a <= natfloor x) = (real a <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1043
  apply (rule iffI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1044
  apply (rule order_trans)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1045
  prefer 2
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1046
  apply (erule real_natfloor_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1047
  apply (subst real_of_nat_le_iff)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1048
  apply assumption
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1049
  apply (erule le_natfloor)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1050
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1051
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1052
lemma le_natfloor_eq_number_of [simp]:
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1053
    "~ neg((number_of n)::int) ==> 0 <= x ==>
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1054
      (number_of n <= natfloor x) = (number_of n <= x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1055
  apply (subst le_natfloor_eq, assumption)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1056
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1057
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1058
16820
5c9d597e4cb9 fixed typos in theorem names
avigad
parents: 16819
diff changeset
  1059
lemma le_natfloor_eq_one [simp]: "(1 <= natfloor x) = (1 <= x)"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1060
  apply (case_tac "0 <= x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1061
  apply (subst le_natfloor_eq, assumption, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1062
  apply (rule iffI)
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1063
  apply (subgoal_tac "natfloor x <= natfloor 0")
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1064
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1065
  apply (rule natfloor_mono)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1066
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1067
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1068
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1069
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1070
lemma natfloor_eq: "real n <= x ==> x < real n + 1 ==> natfloor x = n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1071
  apply (unfold natfloor_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1072
  apply (subst nat_int [THEN sym]);back;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1073
  apply (subst eq_nat_nat_iff)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1074
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1075
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1076
  apply (rule floor_eq2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1077
  apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1078
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1079
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1080
lemma real_natfloor_add_one_gt: "x < real(natfloor x) + 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1081
  apply (case_tac "0 <= x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1082
  apply (unfold natfloor_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1083
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1084
  apply simp_all
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1085
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1086
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1087
lemma real_natfloor_gt_diff_one: "x - 1 < real(natfloor x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1088
  apply (simp add: compare_rls)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1089
  apply (rule real_natfloor_add_one_gt)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1090
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1091
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1092
lemma ge_natfloor_plus_one_imp_gt: "natfloor z + 1 <= n ==> z < real n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1093
  apply (subgoal_tac "z < real(natfloor z) + 1")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1094
  apply arith
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1095
  apply (rule real_natfloor_add_one_gt)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1096
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1097
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1098
lemma natfloor_add [simp]: "0 <= x ==> natfloor (x + real a) = natfloor x + a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1099
  apply (unfold natfloor_def)
24355
93d78fdeb55a remove int_of_nat
huffman
parents: 23477
diff changeset
  1100
  apply (subgoal_tac "real a = real (int a)")
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1101
  apply (erule ssubst)
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
  1102
  apply (simp add: nat_add_distrib del: real_of_int_of_nat_eq)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1103
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1104
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1105
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1106
lemma natfloor_add_number_of [simp]:
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1107
    "~neg ((number_of n)::int) ==> 0 <= x ==>
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1108
      natfloor (x + number_of n) = natfloor x + number_of n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1109
  apply (subst natfloor_add [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1110
  apply simp_all
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1111
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1112
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1113
lemma natfloor_add_one: "0 <= x ==> natfloor(x + 1) = natfloor x + 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1114
  apply (subst natfloor_add [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1115
  apply assumption
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1116
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1117
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1118
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1119
lemma natfloor_subtract [simp]: "real a <= x ==>
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1120
    natfloor(x - real a) = natfloor x - a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1121
  apply (unfold natfloor_def)
24355
93d78fdeb55a remove int_of_nat
huffman
parents: 23477
diff changeset
  1122
  apply (subgoal_tac "real a = real (int a)")
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1123
  apply (erule ssubst)
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
  1124
  apply (simp del: real_of_int_of_nat_eq)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1125
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1126
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1127
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1128
lemma natceiling_zero [simp]: "natceiling 0 = 0"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1129
  by (unfold natceiling_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1130
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1131
lemma natceiling_one [simp]: "natceiling 1 = 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1132
  by (unfold natceiling_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1133
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1134
lemma zero_le_natceiling [simp]: "0 <= natceiling x"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1135
  by (unfold natceiling_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1136
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1137
lemma natceiling_number_of_eq [simp]: "natceiling (number_of n) = number_of n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1138
  by (unfold natceiling_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1139
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1140
lemma natceiling_real_of_nat [simp]: "natceiling(real n) = n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1141
  by (unfold natceiling_def, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1142
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1143
lemma real_natceiling_ge: "x <= real(natceiling x)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1144
  apply (unfold natceiling_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1145
  apply (case_tac "x < 0")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1146
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1147
  apply (subst real_nat_eq_real)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1148
  apply (subgoal_tac "ceiling 0 <= ceiling x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1149
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1150
  apply (rule ceiling_mono2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1151
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1152
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1153
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1154
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1155
lemma natceiling_neg: "x <= 0 ==> natceiling x = 0"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1156
  apply (unfold natceiling_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1157
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1158
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1159
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1160
lemma natceiling_mono: "x <= y ==> natceiling x <= natceiling y"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1161
  apply (case_tac "0 <= x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1162
  apply (subst natceiling_def)+
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1163
  apply (subst nat_le_eq_zle)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1164
  apply (rule disjI2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1165
  apply (subgoal_tac "real (0::int) <= real(ceiling y)")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1166
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1167
  apply (rule order_trans)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1168
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1169
  apply (erule order_trans)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1170
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1171
  apply (erule ceiling_mono2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1172
  apply (subst natceiling_neg)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1173
  apply simp_all
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1174
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1175
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1176
lemma natceiling_le: "x <= real a ==> natceiling x <= a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1177
  apply (unfold natceiling_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1178
  apply (case_tac "x < 0")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1179
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1180
  apply (subst nat_int [THEN sym]);back;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1181
  apply (subst nat_le_eq_zle)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1182
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1183
  apply (rule ceiling_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1184
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1185
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1186
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1187
lemma natceiling_le_eq: "0 <= x ==> (natceiling x <= a) = (x <= real a)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1188
  apply (rule iffI)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1189
  apply (rule order_trans)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1190
  apply (rule real_natceiling_ge)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1191
  apply (subst real_of_nat_le_iff)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1192
  apply assumption
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1193
  apply (erule natceiling_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1194
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1195
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1196
lemma natceiling_le_eq_number_of [simp]:
16820
5c9d597e4cb9 fixed typos in theorem names
avigad
parents: 16819
diff changeset
  1197
    "~ neg((number_of n)::int) ==> 0 <= x ==>
5c9d597e4cb9 fixed typos in theorem names
avigad
parents: 16819
diff changeset
  1198
      (natceiling x <= number_of n) = (x <= number_of n)"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1199
  apply (subst natceiling_le_eq, assumption)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1200
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1201
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1202
16820
5c9d597e4cb9 fixed typos in theorem names
avigad
parents: 16819
diff changeset
  1203
lemma natceiling_le_eq_one: "(natceiling x <= 1) = (x <= 1)"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1204
  apply (case_tac "0 <= x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1205
  apply (subst natceiling_le_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1206
  apply assumption
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1207
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1208
  apply (subst natceiling_neg)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1209
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1210
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1211
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1212
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1213
lemma natceiling_eq: "real n < x ==> x <= real n + 1 ==> natceiling x = n + 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1214
  apply (unfold natceiling_def)
19850
29c125556d86 fixed subst step;
wenzelm
parents: 19765
diff changeset
  1215
  apply (simplesubst nat_int [THEN sym]) back back
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1216
  apply (subgoal_tac "nat(int n) + 1 = nat(int n + 1)")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1217
  apply (erule ssubst)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1218
  apply (subst eq_nat_nat_iff)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1219
  apply (subgoal_tac "ceiling 0 <= ceiling x")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1220
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1221
  apply (rule ceiling_mono2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1222
  apply force
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1223
  apply force
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1224
  apply (rule ceiling_eq2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1225
  apply (simp, simp)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1226
  apply (subst nat_add_distrib)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1227
  apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1228
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1229
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1230
lemma natceiling_add [simp]: "0 <= x ==>
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1231
    natceiling (x + real a) = natceiling x + a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1232
  apply (unfold natceiling_def)
24355
93d78fdeb55a remove int_of_nat
huffman
parents: 23477
diff changeset
  1233
  apply (subgoal_tac "real a = real (int a)")
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1234
  apply (erule ssubst)
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
  1235
  apply (simp del: real_of_int_of_nat_eq)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1236
  apply (subst nat_add_distrib)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1237
  apply (subgoal_tac "0 = ceiling 0")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1238
  apply (erule ssubst)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1239
  apply (erule ceiling_mono2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1240
  apply simp_all
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1241
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1242
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1243
lemma natceiling_add_number_of [simp]:
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1244
    "~ neg ((number_of n)::int) ==> 0 <= x ==>
16820
5c9d597e4cb9 fixed typos in theorem names
avigad
parents: 16819
diff changeset
  1245
      natceiling (x + number_of n) = natceiling x + number_of n"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1246
  apply (subst natceiling_add [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1247
  apply simp_all
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1248
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1249
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1250
lemma natceiling_add_one: "0 <= x ==> natceiling(x + 1) = natceiling x + 1"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1251
  apply (subst natceiling_add [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1252
  apply assumption
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1253
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1254
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1255
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1256
lemma natceiling_subtract [simp]: "real a <= x ==>
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1257
    natceiling(x - real a) = natceiling x - a"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1258
  apply (unfold natceiling_def)
24355
93d78fdeb55a remove int_of_nat
huffman
parents: 23477
diff changeset
  1259
  apply (subgoal_tac "real a = real (int a)")
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1260
  apply (erule ssubst)
23309
678ee30499d2 remove references to constant int::nat=>int
huffman
parents: 23012
diff changeset
  1261
  apply (simp del: real_of_int_of_nat_eq)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1262
  apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1263
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1264
25162
ad4d5365d9d8 went back to >0
nipkow
parents: 25140
diff changeset
  1265
lemma natfloor_div_nat: "1 <= x ==> y > 0 ==>
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1266
  natfloor (x / real y) = natfloor x div y"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1267
proof -
25162
ad4d5365d9d8 went back to >0
nipkow
parents: 25140
diff changeset
  1268
  assume "1 <= (x::real)" and "(y::nat) > 0"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1269
  have "natfloor x = (natfloor x) div y * y + (natfloor x) mod y"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1270
    by simp
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1271
  then have a: "real(natfloor x) = real ((natfloor x) div y) * real y +
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1272
    real((natfloor x) mod y)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1273
    by (simp only: real_of_nat_add [THEN sym] real_of_nat_mult [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1274
  have "x = real(natfloor x) + (x - real(natfloor x))"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1275
    by simp
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1276
  then have "x = real ((natfloor x) div y) * real y +
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1277
      real((natfloor x) mod y) + (x - real(natfloor x))"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1278
    by (simp add: a)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1279
  then have "x / real y = ... / real y"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1280
    by simp
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1281
  also have "... = real((natfloor x) div y) + real((natfloor x) mod y) /
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1282
    real y + (x - real(natfloor x)) / real y"
23477
f4b83f03cac9 tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents: 23389
diff changeset
  1283
    by (auto simp add: ring_simps add_divide_distrib
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1284
      diff_divide_distrib prems)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1285
  finally have "natfloor (x / real y) = natfloor(...)" by simp
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1286
  also have "... = natfloor(real((natfloor x) mod y) /
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1287
    real y + (x - real(natfloor x)) / real y + real((natfloor x) div y))"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1288
    by (simp add: add_ac)
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1289
  also have "... = natfloor(real((natfloor x) mod y) /
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1290
    real y + (x - real(natfloor x)) / real y) + (natfloor x) div y"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1291
    apply (rule natfloor_add)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1292
    apply (rule add_nonneg_nonneg)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1293
    apply (rule divide_nonneg_pos)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1294
    apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1295
    apply (simp add: prems)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1296
    apply (rule divide_nonneg_pos)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1297
    apply (simp add: compare_rls)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1298
    apply (rule real_natfloor_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1299
    apply (insert prems, auto)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1300
    done
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1301
  also have "natfloor(real((natfloor x) mod y) /
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1302
    real y + (x - real(natfloor x)) / real y) = 0"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1303
    apply (rule natfloor_eq)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1304
    apply simp
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1305
    apply (rule add_nonneg_nonneg)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1306
    apply (rule divide_nonneg_pos)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1307
    apply force
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1308
    apply (force simp add: prems)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1309
    apply (rule divide_nonneg_pos)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1310
    apply (simp add: compare_rls)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1311
    apply (rule real_natfloor_le)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1312
    apply (auto simp add: prems)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1313
    apply (insert prems, arith)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1314
    apply (simp add: add_divide_distrib [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1315
    apply (subgoal_tac "real y = real y - 1 + 1")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1316
    apply (erule ssubst)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1317
    apply (rule add_le_less_mono)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1318
    apply (simp add: compare_rls)
16893
0cc94e6f6ae5 some structured proofs on completeness;
wenzelm
parents: 16827
diff changeset
  1319
    apply (subgoal_tac "real(natfloor x mod y) + 1 =
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1320
      real(natfloor x mod y + 1)")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1321
    apply (erule ssubst)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1322
    apply (subst real_of_nat_le_iff)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1323
    apply (subgoal_tac "natfloor x mod y < y")
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1324
    apply arith
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1325
    apply (rule mod_less_divisor)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1326
    apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1327
    apply (simp add: compare_rls)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1328
    apply (subst add_commute)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1329
    apply (rule real_natfloor_add_one_gt)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1330
    done
25140
273772abbea2 More changes from >0 to ~=0::nat
nipkow
parents: 24355
diff changeset
  1331
  finally show ?thesis by simp
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1332
qed
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 15539
diff changeset
  1333
14365
3d4df8c166ae replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents: 9429
diff changeset
  1334
end