src/HOL/Archimedean_Field.thy
author wenzelm
Tue, 03 Mar 2009 14:07:43 +0100
changeset 30211 556d1810cdad
parent 30102 799b687e4aac
child 35028 108662d50512
permissions -rw-r--r--
Thm.binding;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30096
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     1
(* Title:      Archimedean_Field.thy
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     2
   Author:     Brian Huffman
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     3
*)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     4
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     5
header {* Archimedean Fields, Floor and Ceiling Functions *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     6
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     7
theory Archimedean_Field
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     8
imports Main
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
     9
begin
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    10
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    11
subsection {* Class of Archimedean fields *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    12
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    13
text {* Archimedean fields have no infinite elements. *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    14
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    15
class archimedean_field = ordered_field + number_ring +
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    16
  assumes ex_le_of_int: "\<exists>z. x \<le> of_int z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    17
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    18
lemma ex_less_of_int:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    19
  fixes x :: "'a::archimedean_field" shows "\<exists>z. x < of_int z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    20
proof -
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    21
  from ex_le_of_int obtain z where "x \<le> of_int z" ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    22
  then have "x < of_int (z + 1)" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    23
  then show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    24
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    25
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    26
lemma ex_of_int_less:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    27
  fixes x :: "'a::archimedean_field" shows "\<exists>z. of_int z < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    28
proof -
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    29
  from ex_less_of_int obtain z where "- x < of_int z" ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    30
  then have "of_int (- z) < x" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    31
  then show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    32
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    33
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    34
lemma ex_less_of_nat:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    35
  fixes x :: "'a::archimedean_field" shows "\<exists>n. x < of_nat n"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    36
proof -
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    37
  obtain z where "x < of_int z" using ex_less_of_int ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    38
  also have "\<dots> \<le> of_int (int (nat z))" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    39
  also have "\<dots> = of_nat (nat z)" by (simp only: of_int_of_nat_eq)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    40
  finally show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    41
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    42
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    43
lemma ex_le_of_nat:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    44
  fixes x :: "'a::archimedean_field" shows "\<exists>n. x \<le> of_nat n"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    45
proof -
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    46
  obtain n where "x < of_nat n" using ex_less_of_nat ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    47
  then have "x \<le> of_nat n" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    48
  then show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    49
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    50
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    51
text {* Archimedean fields have no infinitesimal elements. *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    52
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    53
lemma ex_inverse_of_nat_Suc_less:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    54
  fixes x :: "'a::archimedean_field"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    55
  assumes "0 < x" shows "\<exists>n. inverse (of_nat (Suc n)) < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    56
proof -
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    57
  from `0 < x` have "0 < inverse x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    58
    by (rule positive_imp_inverse_positive)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    59
  obtain n where "inverse x < of_nat n"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    60
    using ex_less_of_nat ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    61
  then obtain m where "inverse x < of_nat (Suc m)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    62
    using `0 < inverse x` by (cases n) (simp_all del: of_nat_Suc)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    63
  then have "inverse (of_nat (Suc m)) < inverse (inverse x)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    64
    using `0 < inverse x` by (rule less_imp_inverse_less)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    65
  then have "inverse (of_nat (Suc m)) < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    66
    using `0 < x` by (simp add: nonzero_inverse_inverse_eq)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    67
  then show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    68
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    69
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    70
lemma ex_inverse_of_nat_less:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    71
  fixes x :: "'a::archimedean_field"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    72
  assumes "0 < x" shows "\<exists>n>0. inverse (of_nat n) < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    73
  using ex_inverse_of_nat_Suc_less [OF `0 < x`] by auto
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    74
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    75
lemma ex_less_of_nat_mult:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    76
  fixes x :: "'a::archimedean_field"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    77
  assumes "0 < x" shows "\<exists>n. y < of_nat n * x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    78
proof -
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    79
  obtain n where "y / x < of_nat n" using ex_less_of_nat ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    80
  with `0 < x` have "y < of_nat n * x" by (simp add: pos_divide_less_eq)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    81
  then show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    82
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    83
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    84
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    85
subsection {* Existence and uniqueness of floor function *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    86
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    87
lemma exists_least_lemma:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    88
  assumes "\<not> P 0" and "\<exists>n. P n"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    89
  shows "\<exists>n. \<not> P n \<and> P (Suc n)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    90
proof -
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    91
  from `\<exists>n. P n` have "P (Least P)" by (rule LeastI_ex)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    92
  with `\<not> P 0` obtain n where "Least P = Suc n"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    93
    by (cases "Least P") auto
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    94
  then have "n < Least P" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    95
  then have "\<not> P n" by (rule not_less_Least)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    96
  then have "\<not> P n \<and> P (Suc n)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    97
    using `P (Least P)` `Least P = Suc n` by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    98
  then show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
    99
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   100
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   101
lemma floor_exists:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   102
  fixes x :: "'a::archimedean_field"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   103
  shows "\<exists>z. of_int z \<le> x \<and> x < of_int (z + 1)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   104
proof (cases)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   105
  assume "0 \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   106
  then have "\<not> x < of_nat 0" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   107
  then have "\<exists>n. \<not> x < of_nat n \<and> x < of_nat (Suc n)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   108
    using ex_less_of_nat by (rule exists_least_lemma)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   109
  then obtain n where "\<not> x < of_nat n \<and> x < of_nat (Suc n)" ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   110
  then have "of_int (int n) \<le> x \<and> x < of_int (int n + 1)" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   111
  then show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   112
next
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   113
  assume "\<not> 0 \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   114
  then have "\<not> - x \<le> of_nat 0" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   115
  then have "\<exists>n. \<not> - x \<le> of_nat n \<and> - x \<le> of_nat (Suc n)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   116
    using ex_le_of_nat by (rule exists_least_lemma)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   117
  then obtain n where "\<not> - x \<le> of_nat n \<and> - x \<le> of_nat (Suc n)" ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   118
  then have "of_int (- int n - 1) \<le> x \<and> x < of_int (- int n - 1 + 1)" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   119
  then show ?thesis ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   120
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   121
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   122
lemma floor_exists1:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   123
  fixes x :: "'a::archimedean_field"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   124
  shows "\<exists>!z. of_int z \<le> x \<and> x < of_int (z + 1)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   125
proof (rule ex_ex1I)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   126
  show "\<exists>z. of_int z \<le> x \<and> x < of_int (z + 1)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   127
    by (rule floor_exists)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   128
next
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   129
  fix y z assume
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   130
    "of_int y \<le> x \<and> x < of_int (y + 1)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   131
    "of_int z \<le> x \<and> x < of_int (z + 1)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   132
  then have
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   133
    "of_int y \<le> x" "x < of_int (y + 1)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   134
    "of_int z \<le> x" "x < of_int (z + 1)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   135
    by simp_all
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   136
  from le_less_trans [OF `of_int y \<le> x` `x < of_int (z + 1)`]
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   137
       le_less_trans [OF `of_int z \<le> x` `x < of_int (y + 1)`]
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   138
  show "y = z" by (simp del: of_int_add)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   139
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   140
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   141
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   142
subsection {* Floor function *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   143
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   144
definition
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   145
  floor :: "'a::archimedean_field \<Rightarrow> int" where
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   146
  [code del]: "floor x = (THE z. of_int z \<le> x \<and> x < of_int (z + 1))"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   147
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   148
notation (xsymbols)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   149
  floor  ("\<lfloor>_\<rfloor>")
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   150
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   151
notation (HTML output)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   152
  floor  ("\<lfloor>_\<rfloor>")
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   153
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   154
lemma floor_correct: "of_int (floor x) \<le> x \<and> x < of_int (floor x + 1)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   155
  unfolding floor_def using floor_exists1 by (rule theI')
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   156
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   157
lemma floor_unique: "\<lbrakk>of_int z \<le> x; x < of_int z + 1\<rbrakk> \<Longrightarrow> floor x = z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   158
  using floor_correct [of x] floor_exists1 [of x] by auto
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   159
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   160
lemma of_int_floor_le: "of_int (floor x) \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   161
  using floor_correct ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   162
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   163
lemma le_floor_iff: "z \<le> floor x \<longleftrightarrow> of_int z \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   164
proof
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   165
  assume "z \<le> floor x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   166
  then have "(of_int z :: 'a) \<le> of_int (floor x)" by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   167
  also have "of_int (floor x) \<le> x" by (rule of_int_floor_le)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   168
  finally show "of_int z \<le> x" .
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   169
next
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   170
  assume "of_int z \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   171
  also have "x < of_int (floor x + 1)" using floor_correct ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   172
  finally show "z \<le> floor x" by (simp del: of_int_add)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   173
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   174
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   175
lemma floor_less_iff: "floor x < z \<longleftrightarrow> x < of_int z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   176
  by (simp add: not_le [symmetric] le_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   177
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   178
lemma less_floor_iff: "z < floor x \<longleftrightarrow> of_int z + 1 \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   179
  using le_floor_iff [of "z + 1" x] by auto
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   180
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   181
lemma floor_le_iff: "floor x \<le> z \<longleftrightarrow> x < of_int z + 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   182
  by (simp add: not_less [symmetric] less_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   183
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   184
lemma floor_mono: assumes "x \<le> y" shows "floor x \<le> floor y"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   185
proof -
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   186
  have "of_int (floor x) \<le> x" by (rule of_int_floor_le)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   187
  also note `x \<le> y`
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   188
  finally show ?thesis by (simp add: le_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   189
qed
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   190
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   191
lemma floor_less_cancel: "floor x < floor y \<Longrightarrow> x < y"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   192
  by (auto simp add: not_le [symmetric] floor_mono)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   193
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   194
lemma floor_of_int [simp]: "floor (of_int z) = z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   195
  by (rule floor_unique) simp_all
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   196
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   197
lemma floor_of_nat [simp]: "floor (of_nat n) = int n"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   198
  using floor_of_int [of "of_nat n"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   199
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   200
text {* Floor with numerals *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   201
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   202
lemma floor_zero [simp]: "floor 0 = 0"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   203
  using floor_of_int [of 0] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   204
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   205
lemma floor_one [simp]: "floor 1 = 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   206
  using floor_of_int [of 1] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   207
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   208
lemma floor_number_of [simp]: "floor (number_of v) = number_of v"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   209
  using floor_of_int [of "number_of v"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   210
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   211
lemma zero_le_floor [simp]: "0 \<le> floor x \<longleftrightarrow> 0 \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   212
  by (simp add: le_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   213
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   214
lemma one_le_floor [simp]: "1 \<le> floor x \<longleftrightarrow> 1 \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   215
  by (simp add: le_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   216
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   217
lemma number_of_le_floor [simp]: "number_of v \<le> floor x \<longleftrightarrow> number_of v \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   218
  by (simp add: le_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   219
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   220
lemma zero_less_floor [simp]: "0 < floor x \<longleftrightarrow> 1 \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   221
  by (simp add: less_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   222
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   223
lemma one_less_floor [simp]: "1 < floor x \<longleftrightarrow> 2 \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   224
  by (simp add: less_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   225
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   226
lemma number_of_less_floor [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   227
  "number_of v < floor x \<longleftrightarrow> number_of v + 1 \<le> x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   228
  by (simp add: less_floor_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   229
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   230
lemma floor_le_zero [simp]: "floor x \<le> 0 \<longleftrightarrow> x < 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   231
  by (simp add: floor_le_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   232
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   233
lemma floor_le_one [simp]: "floor x \<le> 1 \<longleftrightarrow> x < 2"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   234
  by (simp add: floor_le_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   235
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   236
lemma floor_le_number_of [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   237
  "floor x \<le> number_of v \<longleftrightarrow> x < number_of v + 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   238
  by (simp add: floor_le_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   239
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   240
lemma floor_less_zero [simp]: "floor x < 0 \<longleftrightarrow> x < 0"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   241
  by (simp add: floor_less_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   242
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   243
lemma floor_less_one [simp]: "floor x < 1 \<longleftrightarrow> x < 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   244
  by (simp add: floor_less_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   245
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   246
lemma floor_less_number_of [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   247
  "floor x < number_of v \<longleftrightarrow> x < number_of v"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   248
  by (simp add: floor_less_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   249
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   250
text {* Addition and subtraction of integers *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   251
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   252
lemma floor_add_of_int [simp]: "floor (x + of_int z) = floor x + z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   253
  using floor_correct [of x] by (simp add: floor_unique)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   254
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   255
lemma floor_add_number_of [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   256
    "floor (x + number_of v) = floor x + number_of v"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   257
  using floor_add_of_int [of x "number_of v"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   258
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   259
lemma floor_add_one [simp]: "floor (x + 1) = floor x + 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   260
  using floor_add_of_int [of x 1] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   261
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   262
lemma floor_diff_of_int [simp]: "floor (x - of_int z) = floor x - z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   263
  using floor_add_of_int [of x "- z"] by (simp add: algebra_simps)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   264
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   265
lemma floor_diff_number_of [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   266
  "floor (x - number_of v) = floor x - number_of v"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   267
  using floor_diff_of_int [of x "number_of v"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   268
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   269
lemma floor_diff_one [simp]: "floor (x - 1) = floor x - 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   270
  using floor_diff_of_int [of x 1] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   271
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   272
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   273
subsection {* Ceiling function *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   274
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   275
definition
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   276
  ceiling :: "'a::archimedean_field \<Rightarrow> int" where
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   277
  [code del]: "ceiling x = - floor (- x)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   278
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   279
notation (xsymbols)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   280
  ceiling  ("\<lceil>_\<rceil>")
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   281
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   282
notation (HTML output)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   283
  ceiling  ("\<lceil>_\<rceil>")
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   284
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   285
lemma ceiling_correct: "of_int (ceiling x) - 1 < x \<and> x \<le> of_int (ceiling x)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   286
  unfolding ceiling_def using floor_correct [of "- x"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   287
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   288
lemma ceiling_unique: "\<lbrakk>of_int z - 1 < x; x \<le> of_int z\<rbrakk> \<Longrightarrow> ceiling x = z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   289
  unfolding ceiling_def using floor_unique [of "- z" "- x"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   290
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   291
lemma le_of_int_ceiling: "x \<le> of_int (ceiling x)"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   292
  using ceiling_correct ..
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   293
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   294
lemma ceiling_le_iff: "ceiling x \<le> z \<longleftrightarrow> x \<le> of_int z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   295
  unfolding ceiling_def using le_floor_iff [of "- z" "- x"] by auto
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   296
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   297
lemma less_ceiling_iff: "z < ceiling x \<longleftrightarrow> of_int z < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   298
  by (simp add: not_le [symmetric] ceiling_le_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   299
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   300
lemma ceiling_less_iff: "ceiling x < z \<longleftrightarrow> x \<le> of_int z - 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   301
  using ceiling_le_iff [of x "z - 1"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   302
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   303
lemma le_ceiling_iff: "z \<le> ceiling x \<longleftrightarrow> of_int z - 1 < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   304
  by (simp add: not_less [symmetric] ceiling_less_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   305
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   306
lemma ceiling_mono: "x \<ge> y \<Longrightarrow> ceiling x \<ge> ceiling y"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   307
  unfolding ceiling_def by (simp add: floor_mono)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   308
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   309
lemma ceiling_less_cancel: "ceiling x < ceiling y \<Longrightarrow> x < y"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   310
  by (auto simp add: not_le [symmetric] ceiling_mono)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   311
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   312
lemma ceiling_of_int [simp]: "ceiling (of_int z) = z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   313
  by (rule ceiling_unique) simp_all
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   314
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   315
lemma ceiling_of_nat [simp]: "ceiling (of_nat n) = int n"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   316
  using ceiling_of_int [of "of_nat n"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   317
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   318
text {* Ceiling with numerals *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   319
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   320
lemma ceiling_zero [simp]: "ceiling 0 = 0"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   321
  using ceiling_of_int [of 0] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   322
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   323
lemma ceiling_one [simp]: "ceiling 1 = 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   324
  using ceiling_of_int [of 1] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   325
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   326
lemma ceiling_number_of [simp]: "ceiling (number_of v) = number_of v"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   327
  using ceiling_of_int [of "number_of v"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   328
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   329
lemma ceiling_le_zero [simp]: "ceiling x \<le> 0 \<longleftrightarrow> x \<le> 0"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   330
  by (simp add: ceiling_le_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   331
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   332
lemma ceiling_le_one [simp]: "ceiling x \<le> 1 \<longleftrightarrow> x \<le> 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   333
  by (simp add: ceiling_le_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   334
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   335
lemma ceiling_le_number_of [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   336
  "ceiling x \<le> number_of v \<longleftrightarrow> x \<le> number_of v"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   337
  by (simp add: ceiling_le_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   338
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   339
lemma ceiling_less_zero [simp]: "ceiling x < 0 \<longleftrightarrow> x \<le> -1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   340
  by (simp add: ceiling_less_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   341
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   342
lemma ceiling_less_one [simp]: "ceiling x < 1 \<longleftrightarrow> x \<le> 0"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   343
  by (simp add: ceiling_less_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   344
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   345
lemma ceiling_less_number_of [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   346
  "ceiling x < number_of v \<longleftrightarrow> x \<le> number_of v - 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   347
  by (simp add: ceiling_less_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   348
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   349
lemma zero_le_ceiling [simp]: "0 \<le> ceiling x \<longleftrightarrow> -1 < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   350
  by (simp add: le_ceiling_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   351
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   352
lemma one_le_ceiling [simp]: "1 \<le> ceiling x \<longleftrightarrow> 0 < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   353
  by (simp add: le_ceiling_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   354
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   355
lemma number_of_le_ceiling [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   356
  "number_of v \<le> ceiling x\<longleftrightarrow> number_of v - 1 < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   357
  by (simp add: le_ceiling_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   358
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   359
lemma zero_less_ceiling [simp]: "0 < ceiling x \<longleftrightarrow> 0 < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   360
  by (simp add: less_ceiling_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   361
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   362
lemma one_less_ceiling [simp]: "1 < ceiling x \<longleftrightarrow> 1 < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   363
  by (simp add: less_ceiling_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   364
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   365
lemma number_of_less_ceiling [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   366
  "number_of v < ceiling x \<longleftrightarrow> number_of v < x"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   367
  by (simp add: less_ceiling_iff)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   368
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   369
text {* Addition and subtraction of integers *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   370
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   371
lemma ceiling_add_of_int [simp]: "ceiling (x + of_int z) = ceiling x + z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   372
  using ceiling_correct [of x] by (simp add: ceiling_unique)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   373
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   374
lemma ceiling_add_number_of [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   375
    "ceiling (x + number_of v) = ceiling x + number_of v"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   376
  using ceiling_add_of_int [of x "number_of v"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   377
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   378
lemma ceiling_add_one [simp]: "ceiling (x + 1) = ceiling x + 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   379
  using ceiling_add_of_int [of x 1] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   380
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   381
lemma ceiling_diff_of_int [simp]: "ceiling (x - of_int z) = ceiling x - z"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   382
  using ceiling_add_of_int [of x "- z"] by (simp add: algebra_simps)
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   383
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   384
lemma ceiling_diff_number_of [simp]:
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   385
  "ceiling (x - number_of v) = ceiling x - number_of v"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   386
  using ceiling_diff_of_int [of x "number_of v"] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   387
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   388
lemma ceiling_diff_one [simp]: "ceiling (x - 1) = ceiling x - 1"
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   389
  using ceiling_diff_of_int [of x 1] by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   390
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   391
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   392
subsection {* Negation *}
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   393
30102
799b687e4aac disable floor_minus and ceiling_minus [simp]
huffman
parents: 30096
diff changeset
   394
lemma floor_minus: "floor (- x) = - ceiling x"
30096
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   395
  unfolding ceiling_def by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   396
30102
799b687e4aac disable floor_minus and ceiling_minus [simp]
huffman
parents: 30096
diff changeset
   397
lemma ceiling_minus: "ceiling (- x) = - floor x"
30096
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   398
  unfolding ceiling_def by simp
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   399
c5497842ee35 new theory of Archimedean fields
huffman
parents:
diff changeset
   400
end