author | haftmann |
Sat, 02 Jul 2016 08:41:05 +0200 | |
changeset 63365 | 5340fb6633d0 |
parent 63353 | 176d1f408696 |
child 63494 | ac0a3b9c6dae |
permissions | -rw-r--r-- |
51523 | 1 |
(* Title: HOL/Real.thy |
2 |
Author: Jacques D. Fleuriot, University of Edinburgh, 1998 |
|
3 |
Author: Larry Paulson, University of Cambridge |
|
4 |
Author: Jeremy Avigad, Carnegie Mellon University |
|
5 |
Author: Florian Zuleger, Johannes Hoelzl, and Simon Funke, TU Muenchen |
|
6 |
Conversion to Isar and new proofs by Lawrence C Paulson, 2003/4 |
|
7 |
Construction of Cauchy Reals by Brian Huffman, 2010 |
|
8 |
*) |
|
9 |
||
60758 | 10 |
section \<open>Development of the Reals using Cauchy Sequences\<close> |
51523 | 11 |
|
12 |
theory Real |
|
63331 | 13 |
imports Rat |
51523 | 14 |
begin |
15 |
||
60758 | 16 |
text \<open> |
51523 | 17 |
This theory contains a formalization of the real numbers as |
18 |
equivalence classes of Cauchy sequences of rationals. See |
|
19 |
@{file "~~/src/HOL/ex/Dedekind_Real.thy"} for an alternative |
|
20 |
construction using Dedekind cuts. |
|
60758 | 21 |
\<close> |
51523 | 22 |
|
63353 | 23 |
|
60758 | 24 |
subsection \<open>Preliminary lemmas\<close> |
51523 | 25 |
|
63353 | 26 |
lemma inj_add_left [simp]: "inj (op + x)" for x :: "'a::cancel_semigroup_add" |
27 |
by (meson add_left_imp_eq injI) |
|
61204 | 28 |
|
63353 | 29 |
lemma inj_mult_left [simp]: "inj (op * x) \<longleftrightarrow> x \<noteq> 0" for x :: "'a::idom" |
61204 | 30 |
by (metis injI mult_cancel_left the_inv_f_f zero_neq_one) |
31 |
||
63353 | 32 |
lemma add_diff_add: "(a + c) - (b + d) = (a - b) + (c - d)" for a b c d :: "'a::ab_group_add" |
51523 | 33 |
by simp |
34 |
||
63353 | 35 |
lemma minus_diff_minus: "- a - - b = - (a - b)" for a b :: "'a::ab_group_add" |
51523 | 36 |
by simp |
37 |
||
63353 | 38 |
lemma mult_diff_mult: "(x * y - a * b) = x * (y - b) + (x - a) * b" for x y a b :: "'a::ring" |
51523 | 39 |
by (simp add: algebra_simps) |
40 |
||
41 |
lemma inverse_diff_inverse: |
|
42 |
fixes a b :: "'a::division_ring" |
|
43 |
assumes "a \<noteq> 0" and "b \<noteq> 0" |
|
44 |
shows "inverse a - inverse b = - (inverse a * (a - b) * inverse b)" |
|
45 |
using assms by (simp add: algebra_simps) |
|
46 |
||
47 |
lemma obtain_pos_sum: |
|
48 |
fixes r :: rat assumes r: "0 < r" |
|
49 |
obtains s t where "0 < s" and "0 < t" and "r = s + t" |
|
50 |
proof |
|
63353 | 51 |
from r show "0 < r/2" by simp |
52 |
from r show "0 < r/2" by simp |
|
53 |
show "r = r/2 + r/2" by simp |
|
51523 | 54 |
qed |
55 |
||
63353 | 56 |
|
60758 | 57 |
subsection \<open>Sequences that converge to zero\<close> |
51523 | 58 |
|
63353 | 59 |
definition vanishes :: "(nat \<Rightarrow> rat) \<Rightarrow> bool" |
60 |
where "vanishes X \<longleftrightarrow> (\<forall>r>0. \<exists>k. \<forall>n\<ge>k. \<bar>X n\<bar> < r)" |
|
51523 | 61 |
|
62 |
lemma vanishesI: "(\<And>r. 0 < r \<Longrightarrow> \<exists>k. \<forall>n\<ge>k. \<bar>X n\<bar> < r) \<Longrightarrow> vanishes X" |
|
63 |
unfolding vanishes_def by simp |
|
64 |
||
63353 | 65 |
lemma vanishesD: "vanishes X \<Longrightarrow> 0 < r \<Longrightarrow> \<exists>k. \<forall>n\<ge>k. \<bar>X n\<bar> < r" |
51523 | 66 |
unfolding vanishes_def by simp |
67 |
||
68 |
lemma vanishes_const [simp]: "vanishes (\<lambda>n. c) \<longleftrightarrow> c = 0" |
|
69 |
unfolding vanishes_def |
|
63353 | 70 |
apply (cases "c = 0") |
71 |
apply auto |
|
72 |
apply (rule exI [where x = "\<bar>c\<bar>"]) |
|
73 |
apply auto |
|
51523 | 74 |
done |
75 |
||
76 |
lemma vanishes_minus: "vanishes X \<Longrightarrow> vanishes (\<lambda>n. - X n)" |
|
77 |
unfolding vanishes_def by simp |
|
78 |
||
79 |
lemma vanishes_add: |
|
63353 | 80 |
assumes X: "vanishes X" |
81 |
and Y: "vanishes Y" |
|
51523 | 82 |
shows "vanishes (\<lambda>n. X n + Y n)" |
83 |
proof (rule vanishesI) |
|
63353 | 84 |
fix r :: rat |
85 |
assume "0 < r" |
|
51523 | 86 |
then obtain s t where s: "0 < s" and t: "0 < t" and r: "r = s + t" |
87 |
by (rule obtain_pos_sum) |
|
88 |
obtain i where i: "\<forall>n\<ge>i. \<bar>X n\<bar> < s" |
|
89 |
using vanishesD [OF X s] .. |
|
90 |
obtain j where j: "\<forall>n\<ge>j. \<bar>Y n\<bar> < t" |
|
91 |
using vanishesD [OF Y t] .. |
|
92 |
have "\<forall>n\<ge>max i j. \<bar>X n + Y n\<bar> < r" |
|
63353 | 93 |
proof clarsimp |
94 |
fix n |
|
95 |
assume n: "i \<le> n" "j \<le> n" |
|
51523 | 96 |
have "\<bar>X n + Y n\<bar> \<le> \<bar>X n\<bar> + \<bar>Y n\<bar>" by (rule abs_triangle_ineq) |
97 |
also have "\<dots> < s + t" by (simp add: add_strict_mono i j n) |
|
98 |
finally show "\<bar>X n + Y n\<bar> < r" unfolding r . |
|
99 |
qed |
|
63353 | 100 |
then show "\<exists>k. \<forall>n\<ge>k. \<bar>X n + Y n\<bar> < r" .. |
51523 | 101 |
qed |
102 |
||
103 |
lemma vanishes_diff: |
|
63353 | 104 |
assumes "vanishes X" "vanishes Y" |
51523 | 105 |
shows "vanishes (\<lambda>n. X n - Y n)" |
63353 | 106 |
unfolding diff_conv_add_uminus by (intro vanishes_add vanishes_minus assms) |
51523 | 107 |
|
108 |
lemma vanishes_mult_bounded: |
|
109 |
assumes X: "\<exists>a>0. \<forall>n. \<bar>X n\<bar> < a" |
|
110 |
assumes Y: "vanishes (\<lambda>n. Y n)" |
|
111 |
shows "vanishes (\<lambda>n. X n * Y n)" |
|
112 |
proof (rule vanishesI) |
|
63353 | 113 |
fix r :: rat |
114 |
assume r: "0 < r" |
|
51523 | 115 |
obtain a where a: "0 < a" "\<forall>n. \<bar>X n\<bar> < a" |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
116 |
using X by blast |
51523 | 117 |
obtain b where b: "0 < b" "r = a * b" |
118 |
proof |
|
56541 | 119 |
show "0 < r / a" using r a by simp |
51523 | 120 |
show "r = a * (r / a)" using a by simp |
121 |
qed |
|
122 |
obtain k where k: "\<forall>n\<ge>k. \<bar>Y n\<bar> < b" |
|
123 |
using vanishesD [OF Y b(1)] .. |
|
124 |
have "\<forall>n\<ge>k. \<bar>X n * Y n\<bar> < r" |
|
125 |
by (simp add: b(2) abs_mult mult_strict_mono' a k) |
|
63353 | 126 |
then show "\<exists>k. \<forall>n\<ge>k. \<bar>X n * Y n\<bar> < r" .. |
51523 | 127 |
qed |
128 |
||
63353 | 129 |
|
60758 | 130 |
subsection \<open>Cauchy sequences\<close> |
51523 | 131 |
|
63353 | 132 |
definition cauchy :: "(nat \<Rightarrow> rat) \<Rightarrow> bool" |
133 |
where "cauchy X \<longleftrightarrow> (\<forall>r>0. \<exists>k. \<forall>m\<ge>k. \<forall>n\<ge>k. \<bar>X m - X n\<bar> < r)" |
|
51523 | 134 |
|
63353 | 135 |
lemma cauchyI: "(\<And>r. 0 < r \<Longrightarrow> \<exists>k. \<forall>m\<ge>k. \<forall>n\<ge>k. \<bar>X m - X n\<bar> < r) \<Longrightarrow> cauchy X" |
51523 | 136 |
unfolding cauchy_def by simp |
137 |
||
63353 | 138 |
lemma cauchyD: "cauchy X \<Longrightarrow> 0 < r \<Longrightarrow> \<exists>k. \<forall>m\<ge>k. \<forall>n\<ge>k. \<bar>X m - X n\<bar> < r" |
51523 | 139 |
unfolding cauchy_def by simp |
140 |
||
141 |
lemma cauchy_const [simp]: "cauchy (\<lambda>n. x)" |
|
142 |
unfolding cauchy_def by simp |
|
143 |
||
144 |
lemma cauchy_add [simp]: |
|
145 |
assumes X: "cauchy X" and Y: "cauchy Y" |
|
146 |
shows "cauchy (\<lambda>n. X n + Y n)" |
|
147 |
proof (rule cauchyI) |
|
63353 | 148 |
fix r :: rat |
149 |
assume "0 < r" |
|
51523 | 150 |
then obtain s t where s: "0 < s" and t: "0 < t" and r: "r = s + t" |
151 |
by (rule obtain_pos_sum) |
|
152 |
obtain i where i: "\<forall>m\<ge>i. \<forall>n\<ge>i. \<bar>X m - X n\<bar> < s" |
|
153 |
using cauchyD [OF X s] .. |
|
154 |
obtain j where j: "\<forall>m\<ge>j. \<forall>n\<ge>j. \<bar>Y m - Y n\<bar> < t" |
|
155 |
using cauchyD [OF Y t] .. |
|
156 |
have "\<forall>m\<ge>max i j. \<forall>n\<ge>max i j. \<bar>(X m + Y m) - (X n + Y n)\<bar> < r" |
|
63353 | 157 |
proof clarsimp |
158 |
fix m n |
|
159 |
assume *: "i \<le> m" "j \<le> m" "i \<le> n" "j \<le> n" |
|
51523 | 160 |
have "\<bar>(X m + Y m) - (X n + Y n)\<bar> \<le> \<bar>X m - X n\<bar> + \<bar>Y m - Y n\<bar>" |
161 |
unfolding add_diff_add by (rule abs_triangle_ineq) |
|
162 |
also have "\<dots> < s + t" |
|
63353 | 163 |
by (rule add_strict_mono) (simp_all add: i j *) |
164 |
finally show "\<bar>(X m + Y m) - (X n + Y n)\<bar> < r" by (simp only: r) |
|
51523 | 165 |
qed |
63353 | 166 |
then show "\<exists>k. \<forall>m\<ge>k. \<forall>n\<ge>k. \<bar>(X m + Y m) - (X n + Y n)\<bar> < r" .. |
51523 | 167 |
qed |
168 |
||
169 |
lemma cauchy_minus [simp]: |
|
170 |
assumes X: "cauchy X" |
|
171 |
shows "cauchy (\<lambda>n. - X n)" |
|
63353 | 172 |
using assms unfolding cauchy_def |
173 |
unfolding minus_diff_minus abs_minus_cancel . |
|
51523 | 174 |
|
175 |
lemma cauchy_diff [simp]: |
|
63353 | 176 |
assumes "cauchy X" "cauchy Y" |
51523 | 177 |
shows "cauchy (\<lambda>n. X n - Y n)" |
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
53652
diff
changeset
|
178 |
using assms unfolding diff_conv_add_uminus by (simp del: add_uminus_conv_diff) |
51523 | 179 |
|
180 |
lemma cauchy_imp_bounded: |
|
63353 | 181 |
assumes "cauchy X" |
182 |
shows "\<exists>b>0. \<forall>n. \<bar>X n\<bar> < b" |
|
51523 | 183 |
proof - |
184 |
obtain k where k: "\<forall>m\<ge>k. \<forall>n\<ge>k. \<bar>X m - X n\<bar> < 1" |
|
185 |
using cauchyD [OF assms zero_less_one] .. |
|
186 |
show "\<exists>b>0. \<forall>n. \<bar>X n\<bar> < b" |
|
187 |
proof (intro exI conjI allI) |
|
188 |
have "0 \<le> \<bar>X 0\<bar>" by simp |
|
189 |
also have "\<bar>X 0\<bar> \<le> Max (abs ` X ` {..k})" by simp |
|
190 |
finally have "0 \<le> Max (abs ` X ` {..k})" . |
|
63353 | 191 |
then show "0 < Max (abs ` X ` {..k}) + 1" by simp |
51523 | 192 |
next |
193 |
fix n :: nat |
|
194 |
show "\<bar>X n\<bar> < Max (abs ` X ` {..k}) + 1" |
|
195 |
proof (rule linorder_le_cases) |
|
196 |
assume "n \<le> k" |
|
63353 | 197 |
then have "\<bar>X n\<bar> \<le> Max (abs ` X ` {..k})" by simp |
198 |
then show "\<bar>X n\<bar> < Max (abs ` X ` {..k}) + 1" by simp |
|
51523 | 199 |
next |
200 |
assume "k \<le> n" |
|
201 |
have "\<bar>X n\<bar> = \<bar>X k + (X n - X k)\<bar>" by simp |
|
202 |
also have "\<bar>X k + (X n - X k)\<bar> \<le> \<bar>X k\<bar> + \<bar>X n - X k\<bar>" |
|
203 |
by (rule abs_triangle_ineq) |
|
204 |
also have "\<dots> < Max (abs ` X ` {..k}) + 1" |
|
63353 | 205 |
by (rule add_le_less_mono) (simp_all add: k \<open>k \<le> n\<close>) |
51523 | 206 |
finally show "\<bar>X n\<bar> < Max (abs ` X ` {..k}) + 1" . |
207 |
qed |
|
208 |
qed |
|
209 |
qed |
|
210 |
||
211 |
lemma cauchy_mult [simp]: |
|
212 |
assumes X: "cauchy X" and Y: "cauchy Y" |
|
213 |
shows "cauchy (\<lambda>n. X n * Y n)" |
|
214 |
proof (rule cauchyI) |
|
215 |
fix r :: rat assume "0 < r" |
|
216 |
then obtain u v where u: "0 < u" and v: "0 < v" and "r = u + v" |
|
217 |
by (rule obtain_pos_sum) |
|
218 |
obtain a where a: "0 < a" "\<forall>n. \<bar>X n\<bar> < a" |
|
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
219 |
using cauchy_imp_bounded [OF X] by blast |
51523 | 220 |
obtain b where b: "0 < b" "\<forall>n. \<bar>Y n\<bar> < b" |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
221 |
using cauchy_imp_bounded [OF Y] by blast |
51523 | 222 |
obtain s t where s: "0 < s" and t: "0 < t" and r: "r = a * t + s * b" |
223 |
proof |
|
56541 | 224 |
show "0 < v/b" using v b(1) by simp |
225 |
show "0 < u/a" using u a(1) by simp |
|
51523 | 226 |
show "r = a * (u/a) + (v/b) * b" |
60758 | 227 |
using a(1) b(1) \<open>r = u + v\<close> by simp |
51523 | 228 |
qed |
229 |
obtain i where i: "\<forall>m\<ge>i. \<forall>n\<ge>i. \<bar>X m - X n\<bar> < s" |
|
230 |
using cauchyD [OF X s] .. |
|
231 |
obtain j where j: "\<forall>m\<ge>j. \<forall>n\<ge>j. \<bar>Y m - Y n\<bar> < t" |
|
232 |
using cauchyD [OF Y t] .. |
|
233 |
have "\<forall>m\<ge>max i j. \<forall>n\<ge>max i j. \<bar>X m * Y m - X n * Y n\<bar> < r" |
|
63353 | 234 |
proof clarsimp |
235 |
fix m n |
|
236 |
assume *: "i \<le> m" "j \<le> m" "i \<le> n" "j \<le> n" |
|
51523 | 237 |
have "\<bar>X m * Y m - X n * Y n\<bar> = \<bar>X m * (Y m - Y n) + (X m - X n) * Y n\<bar>" |
238 |
unfolding mult_diff_mult .. |
|
239 |
also have "\<dots> \<le> \<bar>X m * (Y m - Y n)\<bar> + \<bar>(X m - X n) * Y n\<bar>" |
|
240 |
by (rule abs_triangle_ineq) |
|
241 |
also have "\<dots> = \<bar>X m\<bar> * \<bar>Y m - Y n\<bar> + \<bar>X m - X n\<bar> * \<bar>Y n\<bar>" |
|
242 |
unfolding abs_mult .. |
|
243 |
also have "\<dots> < a * t + s * b" |
|
244 |
by (simp_all add: add_strict_mono mult_strict_mono' a b i j *) |
|
63353 | 245 |
finally show "\<bar>X m * Y m - X n * Y n\<bar> < r" by (simp only: r) |
51523 | 246 |
qed |
63353 | 247 |
then show "\<exists>k. \<forall>m\<ge>k. \<forall>n\<ge>k. \<bar>X m * Y m - X n * Y n\<bar> < r" .. |
51523 | 248 |
qed |
249 |
||
250 |
lemma cauchy_not_vanishes_cases: |
|
251 |
assumes X: "cauchy X" |
|
252 |
assumes nz: "\<not> vanishes X" |
|
253 |
shows "\<exists>b>0. \<exists>k. (\<forall>n\<ge>k. b < - X n) \<or> (\<forall>n\<ge>k. b < X n)" |
|
254 |
proof - |
|
255 |
obtain r where "0 < r" and r: "\<forall>k. \<exists>n\<ge>k. r \<le> \<bar>X n\<bar>" |
|
256 |
using nz unfolding vanishes_def by (auto simp add: not_less) |
|
257 |
obtain s t where s: "0 < s" and t: "0 < t" and "r = s + t" |
|
60758 | 258 |
using \<open>0 < r\<close> by (rule obtain_pos_sum) |
51523 | 259 |
obtain i where i: "\<forall>m\<ge>i. \<forall>n\<ge>i. \<bar>X m - X n\<bar> < s" |
260 |
using cauchyD [OF X s] .. |
|
261 |
obtain k where "i \<le> k" and "r \<le> \<bar>X k\<bar>" |
|
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
262 |
using r by blast |
51523 | 263 |
have k: "\<forall>n\<ge>k. \<bar>X n - X k\<bar> < s" |
60758 | 264 |
using i \<open>i \<le> k\<close> by auto |
51523 | 265 |
have "X k \<le> - r \<or> r \<le> X k" |
60758 | 266 |
using \<open>r \<le> \<bar>X k\<bar>\<close> by auto |
63353 | 267 |
then have "(\<forall>n\<ge>k. t < - X n) \<or> (\<forall>n\<ge>k. t < X n)" |
60758 | 268 |
unfolding \<open>r = s + t\<close> using k by auto |
63353 | 269 |
then have "\<exists>k. (\<forall>n\<ge>k. t < - X n) \<or> (\<forall>n\<ge>k. t < X n)" .. |
270 |
then show "\<exists>t>0. \<exists>k. (\<forall>n\<ge>k. t < - X n) \<or> (\<forall>n\<ge>k. t < X n)" |
|
51523 | 271 |
using t by auto |
272 |
qed |
|
273 |
||
274 |
lemma cauchy_not_vanishes: |
|
275 |
assumes X: "cauchy X" |
|
276 |
assumes nz: "\<not> vanishes X" |
|
277 |
shows "\<exists>b>0. \<exists>k. \<forall>n\<ge>k. b < \<bar>X n\<bar>" |
|
63353 | 278 |
using cauchy_not_vanishes_cases [OF assms] |
279 |
apply clarify |
|
280 |
apply (rule exI) |
|
281 |
apply (erule conjI) |
|
282 |
apply (rule_tac x = k in exI) |
|
283 |
apply auto |
|
284 |
done |
|
51523 | 285 |
|
286 |
lemma cauchy_inverse [simp]: |
|
287 |
assumes X: "cauchy X" |
|
288 |
assumes nz: "\<not> vanishes X" |
|
289 |
shows "cauchy (\<lambda>n. inverse (X n))" |
|
290 |
proof (rule cauchyI) |
|
63353 | 291 |
fix r :: rat |
292 |
assume "0 < r" |
|
51523 | 293 |
obtain b i where b: "0 < b" and i: "\<forall>n\<ge>i. b < \<bar>X n\<bar>" |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
294 |
using cauchy_not_vanishes [OF X nz] by blast |
51523 | 295 |
from b i have nz: "\<forall>n\<ge>i. X n \<noteq> 0" by auto |
296 |
obtain s where s: "0 < s" and r: "r = inverse b * s * inverse b" |
|
297 |
proof |
|
60758 | 298 |
show "0 < b * r * b" by (simp add: \<open>0 < r\<close> b) |
51523 | 299 |
show "r = inverse b * (b * r * b) * inverse b" |
300 |
using b by simp |
|
301 |
qed |
|
302 |
obtain j where j: "\<forall>m\<ge>j. \<forall>n\<ge>j. \<bar>X m - X n\<bar> < s" |
|
303 |
using cauchyD [OF X s] .. |
|
304 |
have "\<forall>m\<ge>max i j. \<forall>n\<ge>max i j. \<bar>inverse (X m) - inverse (X n)\<bar> < r" |
|
63353 | 305 |
proof clarsimp |
306 |
fix m n |
|
307 |
assume *: "i \<le> m" "j \<le> m" "i \<le> n" "j \<le> n" |
|
308 |
have "\<bar>inverse (X m) - inverse (X n)\<bar> = inverse \<bar>X m\<bar> * \<bar>X m - X n\<bar> * inverse \<bar>X n\<bar>" |
|
51523 | 309 |
by (simp add: inverse_diff_inverse nz * abs_mult) |
310 |
also have "\<dots> < inverse b * s * inverse b" |
|
63353 | 311 |
by (simp add: mult_strict_mono less_imp_inverse_less i j b * s) |
312 |
finally show "\<bar>inverse (X m) - inverse (X n)\<bar> < r" by (simp only: r) |
|
51523 | 313 |
qed |
63353 | 314 |
then show "\<exists>k. \<forall>m\<ge>k. \<forall>n\<ge>k. \<bar>inverse (X m) - inverse (X n)\<bar> < r" .. |
51523 | 315 |
qed |
316 |
||
317 |
lemma vanishes_diff_inverse: |
|
318 |
assumes X: "cauchy X" "\<not> vanishes X" |
|
63353 | 319 |
and Y: "cauchy Y" "\<not> vanishes Y" |
320 |
and XY: "vanishes (\<lambda>n. X n - Y n)" |
|
51523 | 321 |
shows "vanishes (\<lambda>n. inverse (X n) - inverse (Y n))" |
322 |
proof (rule vanishesI) |
|
63353 | 323 |
fix r :: rat |
324 |
assume r: "0 < r" |
|
51523 | 325 |
obtain a i where a: "0 < a" and i: "\<forall>n\<ge>i. a < \<bar>X n\<bar>" |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
326 |
using cauchy_not_vanishes [OF X] by blast |
51523 | 327 |
obtain b j where b: "0 < b" and j: "\<forall>n\<ge>j. b < \<bar>Y n\<bar>" |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
328 |
using cauchy_not_vanishes [OF Y] by blast |
51523 | 329 |
obtain s where s: "0 < s" and "inverse a * s * inverse b = r" |
330 |
proof |
|
63353 | 331 |
show "0 < a * r * b" using a r b by simp |
332 |
show "inverse a * (a * r * b) * inverse b = r" using a r b by simp |
|
51523 | 333 |
qed |
334 |
obtain k where k: "\<forall>n\<ge>k. \<bar>X n - Y n\<bar> < s" |
|
335 |
using vanishesD [OF XY s] .. |
|
336 |
have "\<forall>n\<ge>max (max i j) k. \<bar>inverse (X n) - inverse (Y n)\<bar> < r" |
|
63353 | 337 |
proof clarsimp |
338 |
fix n |
|
339 |
assume n: "i \<le> n" "j \<le> n" "k \<le> n" |
|
340 |
with i j a b have "X n \<noteq> 0" and "Y n \<noteq> 0" |
|
341 |
by auto |
|
342 |
then have "\<bar>inverse (X n) - inverse (Y n)\<bar> = inverse \<bar>X n\<bar> * \<bar>X n - Y n\<bar> * inverse \<bar>Y n\<bar>" |
|
51523 | 343 |
by (simp add: inverse_diff_inverse abs_mult) |
344 |
also have "\<dots> < inverse a * s * inverse b" |
|
63353 | 345 |
by (intro mult_strict_mono' less_imp_inverse_less) (simp_all add: a b i j k n) |
60758 | 346 |
also note \<open>inverse a * s * inverse b = r\<close> |
51523 | 347 |
finally show "\<bar>inverse (X n) - inverse (Y n)\<bar> < r" . |
348 |
qed |
|
63353 | 349 |
then show "\<exists>k. \<forall>n\<ge>k. \<bar>inverse (X n) - inverse (Y n)\<bar> < r" .. |
51523 | 350 |
qed |
351 |
||
63353 | 352 |
|
60758 | 353 |
subsection \<open>Equivalence relation on Cauchy sequences\<close> |
51523 | 354 |
|
355 |
definition realrel :: "(nat \<Rightarrow> rat) \<Rightarrow> (nat \<Rightarrow> rat) \<Rightarrow> bool" |
|
356 |
where "realrel = (\<lambda>X Y. cauchy X \<and> cauchy Y \<and> vanishes (\<lambda>n. X n - Y n))" |
|
357 |
||
63353 | 358 |
lemma realrelI [intro?]: "cauchy X \<Longrightarrow> cauchy Y \<Longrightarrow> vanishes (\<lambda>n. X n - Y n) \<Longrightarrow> realrel X Y" |
359 |
by (simp add: realrel_def) |
|
51523 | 360 |
|
361 |
lemma realrel_refl: "cauchy X \<Longrightarrow> realrel X X" |
|
63353 | 362 |
by (simp add: realrel_def) |
51523 | 363 |
|
364 |
lemma symp_realrel: "symp realrel" |
|
365 |
unfolding realrel_def |
|
63353 | 366 |
apply (rule sympI) |
367 |
apply clarify |
|
368 |
apply (drule vanishes_minus) |
|
369 |
apply simp |
|
370 |
done |
|
51523 | 371 |
|
372 |
lemma transp_realrel: "transp realrel" |
|
373 |
unfolding realrel_def |
|
63353 | 374 |
apply (rule transpI) |
375 |
apply clarify |
|
51523 | 376 |
apply (drule (1) vanishes_add) |
377 |
apply (simp add: algebra_simps) |
|
378 |
done |
|
379 |
||
380 |
lemma part_equivp_realrel: "part_equivp realrel" |
|
63353 | 381 |
by (blast intro: part_equivpI symp_realrel transp_realrel realrel_refl cauchy_const) |
382 |
||
51523 | 383 |
|
60758 | 384 |
subsection \<open>The field of real numbers\<close> |
51523 | 385 |
|
386 |
quotient_type real = "nat \<Rightarrow> rat" / partial: realrel |
|
387 |
morphisms rep_real Real |
|
388 |
by (rule part_equivp_realrel) |
|
389 |
||
390 |
lemma cr_real_eq: "pcr_real = (\<lambda>x y. cauchy x \<and> Real x = y)" |
|
391 |
unfolding real.pcr_cr_eq cr_real_def realrel_def by auto |
|
392 |
||
393 |
lemma Real_induct [induct type: real]: (* TODO: generate automatically *) |
|
63353 | 394 |
assumes "\<And>X. cauchy X \<Longrightarrow> P (Real X)" |
395 |
shows "P x" |
|
51523 | 396 |
proof (induct x) |
397 |
case (1 X) |
|
63353 | 398 |
then have "cauchy X" by (simp add: realrel_def) |
399 |
then show "P (Real X)" by (rule assms) |
|
51523 | 400 |
qed |
401 |
||
63353 | 402 |
lemma eq_Real: "cauchy X \<Longrightarrow> cauchy Y \<Longrightarrow> Real X = Real Y \<longleftrightarrow> vanishes (\<lambda>n. X n - Y n)" |
51523 | 403 |
using real.rel_eq_transfer |
55945 | 404 |
unfolding real.pcr_cr_eq cr_real_def rel_fun_def realrel_def by simp |
51523 | 405 |
|
51956
a4d81cdebf8b
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
kuncar
parents:
51775
diff
changeset
|
406 |
lemma Domainp_pcr_real [transfer_domain_rule]: "Domainp pcr_real = cauchy" |
63353 | 407 |
by (simp add: real.domain_eq realrel_def) |
51523 | 408 |
|
59867
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
haftmann
parents:
59587
diff
changeset
|
409 |
instantiation real :: field |
51523 | 410 |
begin |
411 |
||
412 |
lift_definition zero_real :: "real" is "\<lambda>n. 0" |
|
413 |
by (simp add: realrel_refl) |
|
414 |
||
415 |
lift_definition one_real :: "real" is "\<lambda>n. 1" |
|
416 |
by (simp add: realrel_refl) |
|
417 |
||
418 |
lift_definition plus_real :: "real \<Rightarrow> real \<Rightarrow> real" is "\<lambda>X Y n. X n + Y n" |
|
419 |
unfolding realrel_def add_diff_add |
|
420 |
by (simp only: cauchy_add vanishes_add simp_thms) |
|
421 |
||
422 |
lift_definition uminus_real :: "real \<Rightarrow> real" is "\<lambda>X n. - X n" |
|
423 |
unfolding realrel_def minus_diff_minus |
|
424 |
by (simp only: cauchy_minus vanishes_minus simp_thms) |
|
425 |
||
426 |
lift_definition times_real :: "real \<Rightarrow> real \<Rightarrow> real" is "\<lambda>X Y n. X n * Y n" |
|
427 |
unfolding realrel_def mult_diff_mult |
|
63353 | 428 |
apply (subst (4) mult.commute) |
429 |
apply (simp only: cauchy_mult vanishes_add vanishes_mult_bounded cauchy_imp_bounded simp_thms) |
|
430 |
done |
|
51523 | 431 |
|
432 |
lift_definition inverse_real :: "real \<Rightarrow> real" |
|
433 |
is "\<lambda>X. if vanishes X then (\<lambda>n. 0) else (\<lambda>n. inverse (X n))" |
|
434 |
proof - |
|
63353 | 435 |
fix X Y |
436 |
assume "realrel X Y" |
|
437 |
then have X: "cauchy X" and Y: "cauchy Y" and XY: "vanishes (\<lambda>n. X n - Y n)" |
|
51523 | 438 |
unfolding realrel_def by simp_all |
439 |
have "vanishes X \<longleftrightarrow> vanishes Y" |
|
440 |
proof |
|
441 |
assume "vanishes X" |
|
442 |
from vanishes_diff [OF this XY] show "vanishes Y" by simp |
|
443 |
next |
|
444 |
assume "vanishes Y" |
|
445 |
from vanishes_add [OF this XY] show "vanishes X" by simp |
|
446 |
qed |
|
63353 | 447 |
then show "?thesis X Y" by (simp add: vanishes_diff_inverse X Y XY realrel_def) |
51523 | 448 |
qed |
449 |
||
63353 | 450 |
definition "x - y = x + - y" for x y :: real |
51523 | 451 |
|
63353 | 452 |
definition "x div y = x * inverse y" for x y :: real |
453 |
||
454 |
lemma add_Real: "cauchy X \<Longrightarrow> cauchy Y \<Longrightarrow> Real X + Real Y = Real (\<lambda>n. X n + Y n)" |
|
455 |
using plus_real.transfer by (simp add: cr_real_eq rel_fun_def) |
|
51523 | 456 |
|
63353 | 457 |
lemma minus_Real: "cauchy X \<Longrightarrow> - Real X = Real (\<lambda>n. - X n)" |
458 |
using uminus_real.transfer by (simp add: cr_real_eq rel_fun_def) |
|
51523 | 459 |
|
63353 | 460 |
lemma diff_Real: "cauchy X \<Longrightarrow> cauchy Y \<Longrightarrow> Real X - Real Y = Real (\<lambda>n. X n - Y n)" |
461 |
by (simp add: minus_Real add_Real minus_real_def) |
|
51523 | 462 |
|
63353 | 463 |
lemma mult_Real: "cauchy X \<Longrightarrow> cauchy Y \<Longrightarrow> Real X * Real Y = Real (\<lambda>n. X n * Y n)" |
464 |
using times_real.transfer by (simp add: cr_real_eq rel_fun_def) |
|
51523 | 465 |
|
466 |
lemma inverse_Real: |
|
63353 | 467 |
"cauchy X \<Longrightarrow> inverse (Real X) = (if vanishes X then 0 else Real (\<lambda>n. inverse (X n)))" |
468 |
using inverse_real.transfer zero_real.transfer |
|
62390 | 469 |
unfolding cr_real_eq rel_fun_def by (simp split: if_split_asm, metis) |
51523 | 470 |
|
63353 | 471 |
instance |
472 |
proof |
|
51523 | 473 |
fix a b c :: real |
474 |
show "a + b = b + a" |
|
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
475 |
by transfer (simp add: ac_simps realrel_def) |
51523 | 476 |
show "(a + b) + c = a + (b + c)" |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
477 |
by transfer (simp add: ac_simps realrel_def) |
51523 | 478 |
show "0 + a = a" |
479 |
by transfer (simp add: realrel_def) |
|
480 |
show "- a + a = 0" |
|
481 |
by transfer (simp add: realrel_def) |
|
482 |
show "a - b = a + - b" |
|
483 |
by (rule minus_real_def) |
|
484 |
show "(a * b) * c = a * (b * c)" |
|
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
485 |
by transfer (simp add: ac_simps realrel_def) |
51523 | 486 |
show "a * b = b * a" |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
487 |
by transfer (simp add: ac_simps realrel_def) |
51523 | 488 |
show "1 * a = a" |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
489 |
by transfer (simp add: ac_simps realrel_def) |
51523 | 490 |
show "(a + b) * c = a * c + b * c" |
491 |
by transfer (simp add: distrib_right realrel_def) |
|
61076 | 492 |
show "(0::real) \<noteq> (1::real)" |
51523 | 493 |
by transfer (simp add: realrel_def) |
494 |
show "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1" |
|
495 |
apply transfer |
|
496 |
apply (simp add: realrel_def) |
|
497 |
apply (rule vanishesI) |
|
498 |
apply (frule (1) cauchy_not_vanishes, clarify) |
|
499 |
apply (rule_tac x=k in exI, clarify) |
|
500 |
apply (drule_tac x=n in spec, simp) |
|
501 |
done |
|
60429
d3d1e185cd63
uniform _ div _ as infix syntax for ring division
haftmann
parents:
60352
diff
changeset
|
502 |
show "a div b = a * inverse b" |
51523 | 503 |
by (rule divide_real_def) |
504 |
show "inverse (0::real) = 0" |
|
505 |
by transfer (simp add: realrel_def) |
|
506 |
qed |
|
507 |
||
508 |
end |
|
509 |
||
63353 | 510 |
|
60758 | 511 |
subsection \<open>Positive reals\<close> |
51523 | 512 |
|
513 |
lift_definition positive :: "real \<Rightarrow> bool" |
|
514 |
is "\<lambda>X. \<exists>r>0. \<exists>k. \<forall>n\<ge>k. r < X n" |
|
515 |
proof - |
|
63353 | 516 |
have 1: "\<exists>r>0. \<exists>k. \<forall>n\<ge>k. r < Y n" |
517 |
if *: "realrel X Y" and **: "\<exists>r>0. \<exists>k. \<forall>n\<ge>k. r < X n" for X Y |
|
518 |
proof - |
|
519 |
from * have XY: "vanishes (\<lambda>n. X n - Y n)" |
|
520 |
by (simp_all add: realrel_def) |
|
521 |
from ** obtain r i where "0 < r" and i: "\<forall>n\<ge>i. r < X n" |
|
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
522 |
by blast |
51523 | 523 |
obtain s t where s: "0 < s" and t: "0 < t" and r: "r = s + t" |
60758 | 524 |
using \<open>0 < r\<close> by (rule obtain_pos_sum) |
51523 | 525 |
obtain j where j: "\<forall>n\<ge>j. \<bar>X n - Y n\<bar> < s" |
526 |
using vanishesD [OF XY s] .. |
|
527 |
have "\<forall>n\<ge>max i j. t < Y n" |
|
63353 | 528 |
proof clarsimp |
529 |
fix n |
|
530 |
assume n: "i \<le> n" "j \<le> n" |
|
51523 | 531 |
have "\<bar>X n - Y n\<bar> < s" and "r < X n" |
532 |
using i j n by simp_all |
|
63353 | 533 |
then show "t < Y n" by (simp add: r) |
51523 | 534 |
qed |
63353 | 535 |
then show ?thesis using t by blast |
536 |
qed |
|
51523 | 537 |
fix X Y assume "realrel X Y" |
63353 | 538 |
then have "realrel X Y" and "realrel Y X" |
539 |
using symp_realrel by (auto simp: symp_def) |
|
540 |
then show "?thesis X Y" |
|
51523 | 541 |
by (safe elim!: 1) |
542 |
qed |
|
543 |
||
63353 | 544 |
lemma positive_Real: "cauchy X \<Longrightarrow> positive (Real X) \<longleftrightarrow> (\<exists>r>0. \<exists>k. \<forall>n\<ge>k. r < X n)" |
545 |
using positive.transfer by (simp add: cr_real_eq rel_fun_def) |
|
51523 | 546 |
|
547 |
lemma positive_zero: "\<not> positive 0" |
|
548 |
by transfer auto |
|
549 |
||
63353 | 550 |
lemma positive_add: "positive x \<Longrightarrow> positive y \<Longrightarrow> positive (x + y)" |
551 |
apply transfer |
|
552 |
apply clarify |
|
553 |
apply (rename_tac a b i j) |
|
554 |
apply (rule_tac x = "a + b" in exI) |
|
555 |
apply simp |
|
556 |
apply (rule_tac x = "max i j" in exI) |
|
557 |
apply clarsimp |
|
558 |
apply (simp add: add_strict_mono) |
|
559 |
done |
|
51523 | 560 |
|
63353 | 561 |
lemma positive_mult: "positive x \<Longrightarrow> positive y \<Longrightarrow> positive (x * y)" |
562 |
apply transfer |
|
563 |
apply clarify |
|
564 |
apply (rename_tac a b i j) |
|
565 |
apply (rule_tac x = "a * b" in exI) |
|
566 |
apply simp |
|
567 |
apply (rule_tac x = "max i j" in exI) |
|
568 |
apply clarsimp |
|
569 |
apply (rule mult_strict_mono) |
|
570 |
apply auto |
|
571 |
done |
|
51523 | 572 |
|
63353 | 573 |
lemma positive_minus: "\<not> positive x \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> positive (- x)" |
574 |
apply transfer |
|
575 |
apply (simp add: realrel_def) |
|
576 |
apply (drule (1) cauchy_not_vanishes_cases, safe) |
|
577 |
apply blast+ |
|
578 |
done |
|
51523 | 579 |
|
59867
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
haftmann
parents:
59587
diff
changeset
|
580 |
instantiation real :: linordered_field |
51523 | 581 |
begin |
582 |
||
63353 | 583 |
definition "x < y \<longleftrightarrow> positive (y - x)" |
51523 | 584 |
|
63353 | 585 |
definition "x \<le> y \<longleftrightarrow> x < y \<or> x = y" for x y :: real |
51523 | 586 |
|
63353 | 587 |
definition "\<bar>a\<bar> = (if a < 0 then - a else a)" for a :: real |
51523 | 588 |
|
63353 | 589 |
definition "sgn a = (if a = 0 then 0 else if 0 < a then 1 else - 1)" for a :: real |
51523 | 590 |
|
63353 | 591 |
instance |
592 |
proof |
|
51523 | 593 |
fix a b c :: real |
594 |
show "\<bar>a\<bar> = (if a < 0 then - a else a)" |
|
595 |
by (rule abs_real_def) |
|
596 |
show "a < b \<longleftrightarrow> a \<le> b \<and> \<not> b \<le> a" |
|
597 |
unfolding less_eq_real_def less_real_def |
|
63353 | 598 |
apply auto |
599 |
apply (drule (1) positive_add) |
|
600 |
apply (simp_all add: positive_zero) |
|
601 |
done |
|
51523 | 602 |
show "a \<le> a" |
603 |
unfolding less_eq_real_def by simp |
|
604 |
show "a \<le> b \<Longrightarrow> b \<le> c \<Longrightarrow> a \<le> c" |
|
605 |
unfolding less_eq_real_def less_real_def |
|
63353 | 606 |
apply auto |
607 |
apply (drule (1) positive_add) |
|
608 |
apply (simp add: algebra_simps) |
|
609 |
done |
|
51523 | 610 |
show "a \<le> b \<Longrightarrow> b \<le> a \<Longrightarrow> a = b" |
611 |
unfolding less_eq_real_def less_real_def |
|
63353 | 612 |
apply auto |
613 |
apply (drule (1) positive_add) |
|
614 |
apply (simp add: positive_zero) |
|
615 |
done |
|
51523 | 616 |
show "a \<le> b \<Longrightarrow> c + a \<le> c + b" |
63353 | 617 |
by (auto simp: less_eq_real_def less_real_def) |
51523 | 618 |
(* FIXME: Procedure int_combine_numerals: c + b - (c + a) \<equiv> b + - a *) |
619 |
(* Should produce c + b - (c + a) \<equiv> b - a *) |
|
620 |
show "sgn a = (if a = 0 then 0 else if 0 < a then 1 else - 1)" |
|
621 |
by (rule sgn_real_def) |
|
622 |
show "a \<le> b \<or> b \<le> a" |
|
63353 | 623 |
by (auto dest!: positive_minus simp: less_eq_real_def less_real_def) |
51523 | 624 |
show "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c * a < c * b" |
625 |
unfolding less_real_def |
|
63353 | 626 |
apply (drule (1) positive_mult) |
627 |
apply (simp add: algebra_simps) |
|
628 |
done |
|
51523 | 629 |
qed |
630 |
||
631 |
end |
|
632 |
||
633 |
instantiation real :: distrib_lattice |
|
634 |
begin |
|
635 |
||
63353 | 636 |
definition "(inf :: real \<Rightarrow> real \<Rightarrow> real) = min" |
51523 | 637 |
|
63353 | 638 |
definition "(sup :: real \<Rightarrow> real \<Rightarrow> real) = max" |
51523 | 639 |
|
63353 | 640 |
instance by standard (auto simp add: inf_real_def sup_real_def max_min_distrib2) |
51523 | 641 |
|
642 |
end |
|
643 |
||
644 |
lemma of_nat_Real: "of_nat x = Real (\<lambda>n. of_nat x)" |
|
63353 | 645 |
by (induct x) (simp_all add: zero_real_def one_real_def add_Real) |
51523 | 646 |
|
647 |
lemma of_int_Real: "of_int x = Real (\<lambda>n. of_int x)" |
|
63353 | 648 |
by (cases x rule: int_diff_cases) (simp add: of_nat_Real diff_Real) |
51523 | 649 |
|
650 |
lemma of_rat_Real: "of_rat x = Real (\<lambda>n. x)" |
|
63353 | 651 |
apply (induct x) |
652 |
apply (simp add: Fract_of_int_quotient of_rat_divide) |
|
653 |
apply (simp add: of_int_Real divide_inverse) |
|
654 |
apply (simp add: inverse_Real mult_Real) |
|
655 |
done |
|
51523 | 656 |
|
657 |
instance real :: archimedean_field |
|
658 |
proof |
|
659 |
fix x :: real |
|
660 |
show "\<exists>z. x \<le> of_int z" |
|
661 |
apply (induct x) |
|
662 |
apply (frule cauchy_imp_bounded, clarify) |
|
61942 | 663 |
apply (rule_tac x="\<lceil>b\<rceil> + 1" in exI) |
51523 | 664 |
apply (rule less_imp_le) |
665 |
apply (simp add: of_int_Real less_real_def diff_Real positive_Real) |
|
666 |
apply (rule_tac x=1 in exI, simp add: algebra_simps) |
|
667 |
apply (rule_tac x=0 in exI, clarsimp) |
|
668 |
apply (rule le_less_trans [OF abs_ge_self]) |
|
669 |
apply (rule less_le_trans [OF _ le_of_int_ceiling]) |
|
670 |
apply simp |
|
671 |
done |
|
672 |
qed |
|
673 |
||
674 |
instantiation real :: floor_ceiling |
|
675 |
begin |
|
676 |
||
63353 | 677 |
definition [code del]: "\<lfloor>x::real\<rfloor> = (THE z. of_int z \<le> x \<and> x < of_int (z + 1))" |
51523 | 678 |
|
61942 | 679 |
instance |
680 |
proof |
|
63353 | 681 |
show "of_int \<lfloor>x\<rfloor> \<le> x \<and> x < of_int (\<lfloor>x\<rfloor> + 1)" for x :: real |
51523 | 682 |
unfolding floor_real_def using floor_exists1 by (rule theI') |
683 |
qed |
|
684 |
||
685 |
end |
|
686 |
||
63353 | 687 |
|
60758 | 688 |
subsection \<open>Completeness\<close> |
51523 | 689 |
|
690 |
lemma not_positive_Real: |
|
691 |
assumes X: "cauchy X" |
|
692 |
shows "\<not> positive (Real X) \<longleftrightarrow> (\<forall>r>0. \<exists>k. \<forall>n\<ge>k. X n \<le> r)" |
|
63353 | 693 |
unfolding positive_Real [OF X] |
694 |
apply auto |
|
695 |
apply (unfold not_less) |
|
696 |
apply (erule obtain_pos_sum) |
|
697 |
apply (drule_tac x=s in spec) |
|
698 |
apply simp |
|
699 |
apply (drule_tac r=t in cauchyD [OF X]) |
|
700 |
apply clarify |
|
701 |
apply (drule_tac x=k in spec) |
|
702 |
apply clarsimp |
|
703 |
apply (rule_tac x=n in exI) |
|
704 |
apply clarify |
|
705 |
apply (rename_tac m) |
|
706 |
apply (drule_tac x=m in spec) |
|
707 |
apply simp |
|
708 |
apply (drule_tac x=n in spec) |
|
709 |
apply simp |
|
710 |
apply (drule spec) |
|
711 |
apply (drule (1) mp) |
|
712 |
apply clarify |
|
713 |
apply (rename_tac i) |
|
714 |
apply (rule_tac x = "max i k" in exI) |
|
715 |
apply simp |
|
716 |
done |
|
51523 | 717 |
|
718 |
lemma le_Real: |
|
63353 | 719 |
assumes "cauchy X" "cauchy Y" |
51523 | 720 |
shows "Real X \<le> Real Y = (\<forall>r>0. \<exists>k. \<forall>n\<ge>k. X n \<le> Y n + r)" |
63353 | 721 |
unfolding not_less [symmetric, where 'a=real] less_real_def |
722 |
apply (simp add: diff_Real not_positive_Real assms) |
|
723 |
apply (simp add: diff_le_eq ac_simps) |
|
724 |
done |
|
51523 | 725 |
|
726 |
lemma le_RealI: |
|
727 |
assumes Y: "cauchy Y" |
|
728 |
shows "\<forall>n. x \<le> of_rat (Y n) \<Longrightarrow> x \<le> Real Y" |
|
729 |
proof (induct x) |
|
63353 | 730 |
fix X |
731 |
assume X: "cauchy X" and "\<forall>n. Real X \<le> of_rat (Y n)" |
|
732 |
then have le: "\<And>m r. 0 < r \<Longrightarrow> \<exists>k. \<forall>n\<ge>k. X n \<le> Y m + r" |
|
51523 | 733 |
by (simp add: of_rat_Real le_Real) |
63353 | 734 |
then have "\<exists>k. \<forall>n\<ge>k. X n \<le> Y n + r" if "0 < r" for r :: rat |
735 |
proof - |
|
736 |
from that obtain s t where s: "0 < s" and t: "0 < t" and r: "r = s + t" |
|
51523 | 737 |
by (rule obtain_pos_sum) |
738 |
obtain i where i: "\<forall>m\<ge>i. \<forall>n\<ge>i. \<bar>Y m - Y n\<bar> < s" |
|
739 |
using cauchyD [OF Y s] .. |
|
740 |
obtain j where j: "\<forall>n\<ge>j. X n \<le> Y i + t" |
|
741 |
using le [OF t] .. |
|
742 |
have "\<forall>n\<ge>max i j. X n \<le> Y n + r" |
|
63353 | 743 |
proof clarsimp |
744 |
fix n |
|
745 |
assume n: "i \<le> n" "j \<le> n" |
|
51523 | 746 |
have "X n \<le> Y i + t" using n j by simp |
747 |
moreover have "\<bar>Y i - Y n\<bar> < s" using n i by simp |
|
748 |
ultimately show "X n \<le> Y n + r" unfolding r by simp |
|
749 |
qed |
|
63353 | 750 |
then show ?thesis .. |
751 |
qed |
|
752 |
then show "Real X \<le> Real Y" |
|
51523 | 753 |
by (simp add: of_rat_Real le_Real X Y) |
754 |
qed |
|
755 |
||
756 |
lemma Real_leI: |
|
757 |
assumes X: "cauchy X" |
|
758 |
assumes le: "\<forall>n. of_rat (X n) \<le> y" |
|
759 |
shows "Real X \<le> y" |
|
760 |
proof - |
|
761 |
have "- y \<le> - Real X" |
|
762 |
by (simp add: minus_Real X le_RealI of_rat_minus le) |
|
63353 | 763 |
then show ?thesis by simp |
51523 | 764 |
qed |
765 |
||
766 |
lemma less_RealD: |
|
63353 | 767 |
assumes "cauchy Y" |
51523 | 768 |
shows "x < Real Y \<Longrightarrow> \<exists>n. x < of_rat (Y n)" |
63353 | 769 |
apply (erule contrapos_pp) |
770 |
apply (simp add: not_less) |
|
771 |
apply (erule Real_leI [OF assms]) |
|
772 |
done |
|
51523 | 773 |
|
63353 | 774 |
lemma of_nat_less_two_power [simp]: "of_nat n < (2::'a::linordered_idom) ^ n" |
775 |
apply (induct n) |
|
776 |
apply simp |
|
777 |
apply (metis add_le_less_mono mult_2 of_nat_Suc one_le_numeral one_le_power power_Suc) |
|
778 |
done |
|
51523 | 779 |
|
780 |
lemma complete_real: |
|
781 |
fixes S :: "real set" |
|
782 |
assumes "\<exists>x. x \<in> S" and "\<exists>z. \<forall>x\<in>S. x \<le> z" |
|
783 |
shows "\<exists>y. (\<forall>x\<in>S. x \<le> y) \<and> (\<forall>z. (\<forall>x\<in>S. x \<le> z) \<longrightarrow> y \<le> z)" |
|
784 |
proof - |
|
785 |
obtain x where x: "x \<in> S" using assms(1) .. |
|
786 |
obtain z where z: "\<forall>x\<in>S. x \<le> z" using assms(2) .. |
|
787 |
||
63040 | 788 |
define P where "P x \<longleftrightarrow> (\<forall>y\<in>S. y \<le> of_rat x)" for x |
51523 | 789 |
obtain a where a: "\<not> P a" |
790 |
proof |
|
61942 | 791 |
have "of_int \<lfloor>x - 1\<rfloor> \<le> x - 1" by (rule of_int_floor_le) |
51523 | 792 |
also have "x - 1 < x" by simp |
61942 | 793 |
finally have "of_int \<lfloor>x - 1\<rfloor> < x" . |
63353 | 794 |
then have "\<not> x \<le> of_int \<lfloor>x - 1\<rfloor>" by (simp only: not_le) |
61942 | 795 |
then show "\<not> P (of_int \<lfloor>x - 1\<rfloor>)" |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
796 |
unfolding P_def of_rat_of_int_eq using x by blast |
51523 | 797 |
qed |
798 |
obtain b where b: "P b" |
|
799 |
proof |
|
61942 | 800 |
show "P (of_int \<lceil>z\<rceil>)" |
51523 | 801 |
unfolding P_def of_rat_of_int_eq |
802 |
proof |
|
803 |
fix y assume "y \<in> S" |
|
63353 | 804 |
then have "y \<le> z" using z by simp |
61942 | 805 |
also have "z \<le> of_int \<lceil>z\<rceil>" by (rule le_of_int_ceiling) |
806 |
finally show "y \<le> of_int \<lceil>z\<rceil>" . |
|
51523 | 807 |
qed |
808 |
qed |
|
809 |
||
63040 | 810 |
define avg where "avg x y = x/2 + y/2" for x y :: rat |
811 |
define bisect where "bisect = (\<lambda>(x, y). if P (avg x y) then (x, avg x y) else (avg x y, y))" |
|
812 |
define A where "A n = fst ((bisect ^^ n) (a, b))" for n |
|
813 |
define B where "B n = snd ((bisect ^^ n) (a, b))" for n |
|
814 |
define C where "C n = avg (A n) (B n)" for n |
|
51523 | 815 |
have A_0 [simp]: "A 0 = a" unfolding A_def by simp |
816 |
have B_0 [simp]: "B 0 = b" unfolding B_def by simp |
|
817 |
have A_Suc [simp]: "\<And>n. A (Suc n) = (if P (C n) then A n else C n)" |
|
818 |
unfolding A_def B_def C_def bisect_def split_def by simp |
|
819 |
have B_Suc [simp]: "\<And>n. B (Suc n) = (if P (C n) then C n else B n)" |
|
820 |
unfolding A_def B_def C_def bisect_def split_def by simp |
|
821 |
||
63353 | 822 |
have width: "B n - A n = (b - a) / 2^n" for n |
823 |
apply (induct n) |
|
824 |
apply (simp_all add: eq_divide_eq) |
|
825 |
apply (simp_all add: C_def avg_def algebra_simps) |
|
51523 | 826 |
done |
827 |
||
63353 | 828 |
have twos: "0 < r \<Longrightarrow> \<exists>n. y / 2 ^ n < r" for y r :: rat |
51523 | 829 |
apply (simp add: divide_less_eq) |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57447
diff
changeset
|
830 |
apply (subst mult.commute) |
51523 | 831 |
apply (frule_tac y=y in ex_less_of_nat_mult) |
832 |
apply clarify |
|
833 |
apply (rule_tac x=n in exI) |
|
834 |
apply (erule less_trans) |
|
835 |
apply (rule mult_strict_right_mono) |
|
836 |
apply (rule le_less_trans [OF _ of_nat_less_two_power]) |
|
837 |
apply simp |
|
838 |
apply assumption |
|
839 |
done |
|
840 |
||
63353 | 841 |
have PA: "\<not> P (A n)" for n by (induct n) (simp_all add: a) |
842 |
have PB: "P (B n)" for n by (induct n) (simp_all add: b) |
|
51523 | 843 |
have ab: "a < b" |
844 |
using a b unfolding P_def |
|
845 |
apply (clarsimp simp add: not_le) |
|
846 |
apply (drule (1) bspec) |
|
847 |
apply (drule (1) less_le_trans) |
|
848 |
apply (simp add: of_rat_less) |
|
849 |
done |
|
63353 | 850 |
have AB: "A n < B n" for n by (induct n) (simp_all add: ab C_def avg_def) |
51523 | 851 |
have A_mono: "\<And>i j. i \<le> j \<Longrightarrow> A i \<le> A j" |
852 |
apply (auto simp add: le_less [where 'a=nat]) |
|
853 |
apply (erule less_Suc_induct) |
|
854 |
apply (clarsimp simp add: C_def avg_def) |
|
855 |
apply (simp add: add_divide_distrib [symmetric]) |
|
856 |
apply (rule AB [THEN less_imp_le]) |
|
857 |
apply simp |
|
858 |
done |
|
859 |
have B_mono: "\<And>i j. i \<le> j \<Longrightarrow> B j \<le> B i" |
|
860 |
apply (auto simp add: le_less [where 'a=nat]) |
|
861 |
apply (erule less_Suc_induct) |
|
862 |
apply (clarsimp simp add: C_def avg_def) |
|
863 |
apply (simp add: add_divide_distrib [symmetric]) |
|
864 |
apply (rule AB [THEN less_imp_le]) |
|
865 |
apply simp |
|
866 |
done |
|
63353 | 867 |
have cauchy_lemma: "\<And>X. \<forall>n. \<forall>i\<ge>n. A n \<le> X i \<and> X i \<le> B n \<Longrightarrow> cauchy X" |
51523 | 868 |
apply (rule cauchyI) |
869 |
apply (drule twos [where y="b - a"]) |
|
870 |
apply (erule exE) |
|
871 |
apply (rule_tac x=n in exI, clarify, rename_tac i j) |
|
872 |
apply (rule_tac y="B n - A n" in le_less_trans) defer |
|
873 |
apply (simp add: width) |
|
874 |
apply (drule_tac x=n in spec) |
|
875 |
apply (frule_tac x=i in spec, drule (1) mp) |
|
876 |
apply (frule_tac x=j in spec, drule (1) mp) |
|
877 |
apply (frule A_mono, drule B_mono) |
|
878 |
apply (frule A_mono, drule B_mono) |
|
879 |
apply arith |
|
880 |
done |
|
881 |
have "cauchy A" |
|
882 |
apply (rule cauchy_lemma [rule_format]) |
|
883 |
apply (simp add: A_mono) |
|
884 |
apply (erule order_trans [OF less_imp_le [OF AB] B_mono]) |
|
885 |
done |
|
886 |
have "cauchy B" |
|
887 |
apply (rule cauchy_lemma [rule_format]) |
|
888 |
apply (simp add: B_mono) |
|
889 |
apply (erule order_trans [OF A_mono less_imp_le [OF AB]]) |
|
890 |
done |
|
891 |
have 1: "\<forall>x\<in>S. x \<le> Real B" |
|
892 |
proof |
|
63353 | 893 |
fix x |
894 |
assume "x \<in> S" |
|
51523 | 895 |
then show "x \<le> Real B" |
60758 | 896 |
using PB [unfolded P_def] \<open>cauchy B\<close> |
51523 | 897 |
by (simp add: le_RealI) |
898 |
qed |
|
899 |
have 2: "\<forall>z. (\<forall>x\<in>S. x \<le> z) \<longrightarrow> Real A \<le> z" |
|
900 |
apply clarify |
|
901 |
apply (erule contrapos_pp) |
|
902 |
apply (simp add: not_le) |
|
60758 | 903 |
apply (drule less_RealD [OF \<open>cauchy A\<close>], clarify) |
51523 | 904 |
apply (subgoal_tac "\<not> P (A n)") |
905 |
apply (simp add: P_def not_le, clarify) |
|
906 |
apply (erule rev_bexI) |
|
907 |
apply (erule (1) less_trans) |
|
908 |
apply (simp add: PA) |
|
909 |
done |
|
910 |
have "vanishes (\<lambda>n. (b - a) / 2 ^ n)" |
|
911 |
proof (rule vanishesI) |
|
63353 | 912 |
fix r :: rat |
913 |
assume "0 < r" |
|
51523 | 914 |
then obtain k where k: "\<bar>b - a\<bar> / 2 ^ k < r" |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
915 |
using twos by blast |
51523 | 916 |
have "\<forall>n\<ge>k. \<bar>(b - a) / 2 ^ n\<bar> < r" |
63353 | 917 |
proof clarify |
918 |
fix n |
|
919 |
assume n: "k \<le> n" |
|
51523 | 920 |
have "\<bar>(b - a) / 2 ^ n\<bar> = \<bar>b - a\<bar> / 2 ^ n" |
921 |
by simp |
|
922 |
also have "\<dots> \<le> \<bar>b - a\<bar> / 2 ^ k" |
|
56544 | 923 |
using n by (simp add: divide_left_mono) |
51523 | 924 |
also note k |
925 |
finally show "\<bar>(b - a) / 2 ^ n\<bar> < r" . |
|
926 |
qed |
|
63353 | 927 |
then show "\<exists>k. \<forall>n\<ge>k. \<bar>(b - a) / 2 ^ n\<bar> < r" .. |
51523 | 928 |
qed |
63353 | 929 |
then have 3: "Real B = Real A" |
60758 | 930 |
by (simp add: eq_Real \<open>cauchy A\<close> \<open>cauchy B\<close> width) |
51523 | 931 |
show "\<exists>y. (\<forall>x\<in>S. x \<le> y) \<and> (\<forall>z. (\<forall>x\<in>S. x \<le> z) \<longrightarrow> y \<le> z)" |
63353 | 932 |
apply (rule exI [where x = "Real B"]) |
933 |
using 1 2 3 |
|
934 |
apply simp |
|
935 |
done |
|
51523 | 936 |
qed |
937 |
||
51775
408d937c9486
revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents:
51773
diff
changeset
|
938 |
instantiation real :: linear_continuum |
51523 | 939 |
begin |
940 |
||
63353 | 941 |
subsection \<open>Supremum of a set of reals\<close> |
51523 | 942 |
|
54281 | 943 |
definition "Sup X = (LEAST z::real. \<forall>x\<in>X. x \<le> z)" |
63353 | 944 |
definition "Inf X = - Sup (uminus ` X)" for X :: "real set" |
51523 | 945 |
|
946 |
instance |
|
947 |
proof |
|
63353 | 948 |
show Sup_upper: "x \<le> Sup X" if "x \<in> X" "bdd_above X" for x :: real and X :: "real set" |
949 |
proof - |
|
950 |
from that obtain s where s: "\<forall>y\<in>X. y \<le> s" "\<And>z. \<forall>y\<in>X. y \<le> z \<Longrightarrow> s \<le> z" |
|
54258
adfc759263ab
use bdd_above and bdd_below for conditionally complete lattices
hoelzl
parents:
54230
diff
changeset
|
951 |
using complete_real[of X] unfolding bdd_above_def by blast |
63353 | 952 |
then show ?thesis unfolding Sup_real_def by (rule LeastI2_order) (auto simp: that) |
953 |
qed |
|
954 |
show Sup_least: "Sup X \<le> z" if "X \<noteq> {}" and z: "\<And>x. x \<in> X \<Longrightarrow> x \<le> z" |
|
955 |
for z :: real and X :: "real set" |
|
956 |
proof - |
|
957 |
from that obtain s where s: "\<forall>y\<in>X. y \<le> s" "\<And>z. \<forall>y\<in>X. y \<le> z \<Longrightarrow> s \<le> z" |
|
958 |
using complete_real [of X] by blast |
|
51523 | 959 |
then have "Sup X = s" |
61284
2314c2f62eb1
real_of_nat_Suc is now a simprule
paulson <lp15@cam.ac.uk>
parents:
61204
diff
changeset
|
960 |
unfolding Sup_real_def by (best intro: Least_equality) |
63353 | 961 |
also from s z have "\<dots> \<le> z" |
51523 | 962 |
by blast |
63353 | 963 |
finally show ?thesis . |
964 |
qed |
|
965 |
show "Inf X \<le> x" if "x \<in> X" "bdd_below X" for x :: real and X :: "real set" |
|
966 |
using Sup_upper [of "-x" "uminus ` X"] by (auto simp: Inf_real_def that) |
|
967 |
show "z \<le> Inf X" if "X \<noteq> {}" "\<And>x. x \<in> X \<Longrightarrow> z \<le> x" for z :: real and X :: "real set" |
|
968 |
using Sup_least [of "uminus ` X" "- z"] by (force simp: Inf_real_def that) |
|
51775
408d937c9486
revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents:
51773
diff
changeset
|
969 |
show "\<exists>a b::real. a \<noteq> b" |
408d937c9486
revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
hoelzl
parents:
51773
diff
changeset
|
970 |
using zero_neq_one by blast |
51523 | 971 |
qed |
63353 | 972 |
|
51523 | 973 |
end |
974 |
||
63353 | 975 |
|
60758 | 976 |
subsection \<open>Hiding implementation details\<close> |
51523 | 977 |
|
978 |
hide_const (open) vanishes cauchy positive Real |
|
979 |
||
980 |
declare Real_induct [induct del] |
|
981 |
declare Abs_real_induct [induct del] |
|
982 |
declare Abs_real_cases [cases del] |
|
983 |
||
53652
18fbca265e2e
use lifting_forget for deregistering numeric types as a quotient type
kuncar
parents:
53374
diff
changeset
|
984 |
lifting_update real.lifting |
18fbca265e2e
use lifting_forget for deregistering numeric types as a quotient type
kuncar
parents:
53374
diff
changeset
|
985 |
lifting_forget real.lifting |
61284
2314c2f62eb1
real_of_nat_Suc is now a simprule
paulson <lp15@cam.ac.uk>
parents:
61204
diff
changeset
|
986 |
|
63353 | 987 |
|
988 |
subsection \<open>More Lemmas\<close> |
|
51523 | 989 |
|
60758 | 990 |
text \<open>BH: These lemmas should not be necessary; they should be |
63353 | 991 |
covered by existing simp rules and simplification procedures.\<close> |
51523 | 992 |
|
63353 | 993 |
lemma real_mult_less_iff1 [simp]: "0 < z \<Longrightarrow> x * z < y * z \<longleftrightarrow> x < y" for x y z :: real |
994 |
by simp (* solved by linordered_ring_less_cancel_factor simproc *) |
|
51523 | 995 |
|
63353 | 996 |
lemma real_mult_le_cancel_iff1 [simp]: "0 < z \<Longrightarrow> x * z \<le> y * z \<longleftrightarrow> x \<le> y" for x y z :: real |
997 |
by simp (* solved by linordered_ring_le_cancel_factor simproc *) |
|
51523 | 998 |
|
63353 | 999 |
lemma real_mult_le_cancel_iff2 [simp]: "0 < z \<Longrightarrow> z * x \<le> z * y \<longleftrightarrow> x \<le> y" for x y z :: real |
1000 |
by simp (* solved by linordered_ring_le_cancel_factor simproc *) |
|
51523 | 1001 |
|
1002 |
||
60758 | 1003 |
subsection \<open>Embedding numbers into the Reals\<close> |
51523 | 1004 |
|
63353 | 1005 |
abbreviation real_of_nat :: "nat \<Rightarrow> real" |
1006 |
where "real_of_nat \<equiv> of_nat" |
|
51523 | 1007 |
|
63353 | 1008 |
abbreviation real :: "nat \<Rightarrow> real" |
1009 |
where "real \<equiv> of_nat" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1010 |
|
63353 | 1011 |
abbreviation real_of_int :: "int \<Rightarrow> real" |
1012 |
where "real_of_int \<equiv> of_int" |
|
51523 | 1013 |
|
63353 | 1014 |
abbreviation real_of_rat :: "rat \<Rightarrow> real" |
1015 |
where "real_of_rat \<equiv> of_rat" |
|
51523 | 1016 |
|
1017 |
declare [[coercion_enabled]] |
|
59000 | 1018 |
|
1019 |
declare [[coercion "of_nat :: nat \<Rightarrow> int"]] |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1020 |
declare [[coercion "of_nat :: nat \<Rightarrow> real"]] |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1021 |
declare [[coercion "of_int :: int \<Rightarrow> real"]] |
59000 | 1022 |
|
1023 |
(* We do not add rat to the coerced types, this has often unpleasant side effects when writing |
|
1024 |
inverse (Suc n) which sometimes gets two coercions: of_rat (inverse (of_nat (Suc n))) *) |
|
51523 | 1025 |
|
1026 |
declare [[coercion_map map]] |
|
59000 | 1027 |
declare [[coercion_map "\<lambda>f g h x. g (h (f x))"]] |
1028 |
declare [[coercion_map "\<lambda>f g (x,y). (f x, g y)"]] |
|
51523 | 1029 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1030 |
declare of_int_eq_0_iff [algebra, presburger] |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1031 |
declare of_int_eq_1_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1032 |
declare of_int_eq_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1033 |
declare of_int_less_0_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1034 |
declare of_int_less_1_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1035 |
declare of_int_less_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1036 |
declare of_int_le_0_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1037 |
declare of_int_le_1_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1038 |
declare of_int_le_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1039 |
declare of_int_0_less_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1040 |
declare of_int_0_le_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1041 |
declare of_int_1_less_iff [algebra, presburger] |
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1042 |
declare of_int_1_le_iff [algebra, presburger] |
51523 | 1043 |
|
63353 | 1044 |
lemma int_less_real_le: "n < m \<longleftrightarrow> real_of_int n + 1 \<le> real_of_int m" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1045 |
proof - |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1046 |
have "(0::real) \<le> 1" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1047 |
by (metis less_eq_real_def zero_less_one) |
63353 | 1048 |
then show ?thesis |
61694
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents:
61649
diff
changeset
|
1049 |
by (metis floor_of_int less_floor_iff) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1050 |
qed |
51523 | 1051 |
|
63353 | 1052 |
lemma int_le_real_less: "n \<le> m \<longleftrightarrow> real_of_int n < real_of_int m + 1" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1053 |
by (meson int_less_real_le not_le) |
51523 | 1054 |
|
63353 | 1055 |
lemma real_of_int_div_aux: |
1056 |
"(real_of_int x) / (real_of_int d) = |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1057 |
real_of_int (x div d) + (real_of_int (x mod d)) / (real_of_int d)" |
51523 | 1058 |
proof - |
1059 |
have "x = (x div d) * d + x mod d" |
|
1060 |
by auto |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1061 |
then have "real_of_int x = real_of_int (x div d) * real_of_int d + real_of_int(x mod d)" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1062 |
by (metis of_int_add of_int_mult) |
63353 | 1063 |
then have "real_of_int x / real_of_int d = \<dots> / real_of_int d" |
51523 | 1064 |
by simp |
1065 |
then show ?thesis |
|
1066 |
by (auto simp add: add_divide_distrib algebra_simps) |
|
1067 |
qed |
|
1068 |
||
58834 | 1069 |
lemma real_of_int_div: |
63353 | 1070 |
"d dvd n \<Longrightarrow> real_of_int (n div d) = real_of_int n / real_of_int d" for d n :: int |
58834 | 1071 |
by (simp add: real_of_int_div_aux) |
51523 | 1072 |
|
63353 | 1073 |
lemma real_of_int_div2: "0 \<le> real_of_int n / real_of_int x - real_of_int (n div x)" |
1074 |
apply (cases "x = 0") |
|
1075 |
apply simp |
|
1076 |
apply (cases "0 < x") |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1077 |
apply (metis add.left_neutral floor_correct floor_divide_of_int_eq le_diff_eq) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1078 |
apply (metis add.left_neutral floor_correct floor_divide_of_int_eq le_diff_eq) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1079 |
done |
51523 | 1080 |
|
63353 | 1081 |
lemma real_of_int_div3: "real_of_int n / real_of_int x - real_of_int (n div x) \<le> 1" |
51523 | 1082 |
apply (simp add: algebra_simps) |
1083 |
apply (subst real_of_int_div_aux) |
|
1084 |
apply (auto simp add: divide_le_eq intro: order_less_imp_le) |
|
63353 | 1085 |
done |
51523 | 1086 |
|
63353 | 1087 |
lemma real_of_int_div4: "real_of_int (n div x) \<le> real_of_int n / real_of_int x" |
1088 |
using real_of_int_div2 [of n x] by simp |
|
51523 | 1089 |
|
1090 |
||
63353 | 1091 |
subsection \<open>Embedding the Naturals into the Reals\<close> |
51523 | 1092 |
|
63353 | 1093 |
lemma real_of_card: "real (card A) = setsum (\<lambda>x. 1) A" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1094 |
by simp |
51523 | 1095 |
|
63353 | 1096 |
lemma nat_less_real_le: "n < m \<longleftrightarrow> real n + 1 \<le> real m" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1097 |
by (metis discrete of_nat_1 of_nat_add of_nat_le_iff) |
51523 | 1098 |
|
63353 | 1099 |
lemma nat_le_real_less: "n \<le> m \<longleftrightarrow> real n < real m + 1" for m n :: nat |
61284
2314c2f62eb1
real_of_nat_Suc is now a simprule
paulson <lp15@cam.ac.uk>
parents:
61204
diff
changeset
|
1100 |
by (meson nat_less_real_le not_le) |
51523 | 1101 |
|
63353 | 1102 |
lemma real_of_nat_div_aux: "real x / real d = real (x div d) + real (x mod d) / real d" |
51523 | 1103 |
proof - |
1104 |
have "x = (x div d) * d + x mod d" |
|
1105 |
by auto |
|
1106 |
then have "real x = real (x div d) * real d + real(x mod d)" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1107 |
by (metis of_nat_add of_nat_mult) |
51523 | 1108 |
then have "real x / real d = \<dots> / real d" |
1109 |
by simp |
|
1110 |
then show ?thesis |
|
1111 |
by (auto simp add: add_divide_distrib algebra_simps) |
|
1112 |
qed |
|
1113 |
||
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1114 |
lemma real_of_nat_div: "d dvd n \<Longrightarrow> real(n div d) = real n / real d" |
63353 | 1115 |
by (subst real_of_nat_div_aux) (auto simp add: dvd_eq_mod_eq_0 [symmetric]) |
51523 | 1116 |
|
63353 | 1117 |
lemma real_of_nat_div2: "0 \<le> real n / real x - real (n div x)" for n x :: nat |
1118 |
apply (simp add: algebra_simps) |
|
1119 |
apply (subst real_of_nat_div_aux) |
|
1120 |
apply simp |
|
1121 |
done |
|
51523 | 1122 |
|
63353 | 1123 |
lemma real_of_nat_div3: "real n / real x - real (n div x) \<le> 1" for n x :: nat |
1124 |
apply (cases "x = 0") |
|
1125 |
apply simp |
|
1126 |
apply (simp add: algebra_simps) |
|
1127 |
apply (subst real_of_nat_div_aux) |
|
1128 |
apply simp |
|
1129 |
done |
|
51523 | 1130 |
|
63353 | 1131 |
lemma real_of_nat_div4: "real (n div x) \<le> real n / real x" for n x :: nat |
1132 |
using real_of_nat_div2 [of n x] by simp |
|
1133 |
||
51523 | 1134 |
|
60758 | 1135 |
subsection \<open>The Archimedean Property of the Reals\<close> |
51523 | 1136 |
|
62623
dbc62f86a1a9
rationalisation of theorem names esp about "real Archimedian" etc.
paulson <lp15@cam.ac.uk>
parents:
62398
diff
changeset
|
1137 |
lemma real_arch_inverse: "0 < e \<longleftrightarrow> (\<exists>n::nat. n \<noteq> 0 \<and> 0 < inverse (real n) \<and> inverse (real n) < e)" |
dbc62f86a1a9
rationalisation of theorem names esp about "real Archimedian" etc.
paulson <lp15@cam.ac.uk>
parents:
62398
diff
changeset
|
1138 |
using reals_Archimedean[of e] less_trans[of 0 "1 / real n" e for n::nat] |
dbc62f86a1a9
rationalisation of theorem names esp about "real Archimedian" etc.
paulson <lp15@cam.ac.uk>
parents:
62398
diff
changeset
|
1139 |
by (auto simp add: field_simps cong: conj_cong simp del: of_nat_Suc) |
51523 | 1140 |
|
1141 |
lemma reals_Archimedean3: |
|
1142 |
assumes x_greater_zero: "0 < x" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1143 |
shows "\<forall>y. \<exists>n. y < real n * x" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1144 |
using \<open>0 < x\<close> by (auto intro: ex_less_of_nat_mult) |
51523 | 1145 |
|
62397
5ae24f33d343
Substantial new material for multivariate analysis. Also removal of some duplicates.
paulson <lp15@cam.ac.uk>
parents:
62348
diff
changeset
|
1146 |
lemma real_archimedian_rdiv_eq_0: |
5ae24f33d343
Substantial new material for multivariate analysis. Also removal of some duplicates.
paulson <lp15@cam.ac.uk>
parents:
62348
diff
changeset
|
1147 |
assumes x0: "x \<ge> 0" |
63353 | 1148 |
and c: "c \<ge> 0" |
1149 |
and xc: "\<And>m::nat. m > 0 \<Longrightarrow> real m * x \<le> c" |
|
1150 |
shows "x = 0" |
|
1151 |
by (metis reals_Archimedean3 dual_order.order_iff_strict le0 le_less_trans not_le x0 xc) |
|
62397
5ae24f33d343
Substantial new material for multivariate analysis. Also removal of some duplicates.
paulson <lp15@cam.ac.uk>
parents:
62348
diff
changeset
|
1152 |
|
51523 | 1153 |
|
63353 | 1154 |
subsection \<open>Rationals\<close> |
51523 | 1155 |
|
63353 | 1156 |
lemma Rats_eq_int_div_int: "\<rat> = {real_of_int i / real_of_int j | i j. j \<noteq> 0}" (is "_ = ?S") |
51523 | 1157 |
proof |
1158 |
show "\<rat> \<subseteq> ?S" |
|
1159 |
proof |
|
63353 | 1160 |
fix x :: real |
1161 |
assume "x \<in> \<rat>" |
|
1162 |
then obtain r where "x = of_rat r" |
|
1163 |
unfolding Rats_def .. |
|
1164 |
have "of_rat r \<in> ?S" |
|
1165 |
by (cases r) (auto simp add: of_rat_rat) |
|
1166 |
then show "x \<in> ?S" |
|
1167 |
using \<open>x = of_rat r\<close> by simp |
|
51523 | 1168 |
qed |
1169 |
next |
|
1170 |
show "?S \<subseteq> \<rat>" |
|
63353 | 1171 |
proof (auto simp: Rats_def) |
1172 |
fix i j :: int |
|
1173 |
assume "j \<noteq> 0" |
|
1174 |
then have "real_of_int i / real_of_int j = of_rat (Fract i j)" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1175 |
by (simp add: of_rat_rat) |
63353 | 1176 |
then show "real_of_int i / real_of_int j \<in> range of_rat" |
1177 |
by blast |
|
51523 | 1178 |
qed |
1179 |
qed |
|
1180 |
||
63353 | 1181 |
lemma Rats_eq_int_div_nat: "\<rat> = { real_of_int i / real n | i n. n \<noteq> 0}" |
1182 |
proof (auto simp: Rats_eq_int_div_int) |
|
1183 |
fix i j :: int |
|
1184 |
assume "j \<noteq> 0" |
|
1185 |
show "\<exists>(i'::int) (n::nat). real_of_int i / real_of_int j = real_of_int i' / real n \<and> 0 < n" |
|
1186 |
proof (cases "j > 0") |
|
1187 |
case True |
|
1188 |
then have "real_of_int i / real_of_int j = real_of_int i / real (nat j) \<and> 0 < nat j" |
|
1189 |
by simp |
|
1190 |
then show ?thesis by blast |
|
51523 | 1191 |
next |
63353 | 1192 |
case False |
1193 |
with \<open>j \<noteq> 0\<close> |
|
1194 |
have "real_of_int i / real_of_int j = real_of_int (- i) / real (nat (- j)) \<and> 0 < nat (- j)" |
|
1195 |
by simp |
|
1196 |
then show ?thesis by blast |
|
51523 | 1197 |
qed |
1198 |
next |
|
63353 | 1199 |
fix i :: int and n :: nat |
1200 |
assume "0 < n" |
|
1201 |
then have "real_of_int i / real n = real_of_int i / real_of_int(int n) \<and> int n \<noteq> 0" |
|
1202 |
by simp |
|
1203 |
then show "\<exists>i' j. real_of_int i / real n = real_of_int i' / real_of_int j \<and> j \<noteq> 0" |
|
1204 |
by blast |
|
51523 | 1205 |
qed |
1206 |
||
1207 |
lemma Rats_abs_nat_div_natE: |
|
1208 |
assumes "x \<in> \<rat>" |
|
63353 | 1209 |
obtains m n :: nat where "n \<noteq> 0" and "\<bar>x\<bar> = real m / real n" and "gcd m n = 1" |
51523 | 1210 |
proof - |
63353 | 1211 |
from \<open>x \<in> \<rat>\<close> obtain i :: int and n :: nat where "n \<noteq> 0" and "x = real_of_int i / real n" |
1212 |
by (auto simp add: Rats_eq_int_div_nat) |
|
1213 |
then have "\<bar>x\<bar> = real (nat \<bar>i\<bar>) / real n" by simp |
|
51523 | 1214 |
then obtain m :: nat where x_rat: "\<bar>x\<bar> = real m / real n" by blast |
1215 |
let ?gcd = "gcd m n" |
|
63353 | 1216 |
from \<open>n \<noteq> 0\<close> have gcd: "?gcd \<noteq> 0" by simp |
51523 | 1217 |
let ?k = "m div ?gcd" |
1218 |
let ?l = "n div ?gcd" |
|
1219 |
let ?gcd' = "gcd ?k ?l" |
|
63353 | 1220 |
have "?gcd dvd m" .. |
1221 |
then have gcd_k: "?gcd * ?k = m" |
|
51523 | 1222 |
by (rule dvd_mult_div_cancel) |
63353 | 1223 |
have "?gcd dvd n" .. |
1224 |
then have gcd_l: "?gcd * ?l = n" |
|
51523 | 1225 |
by (rule dvd_mult_div_cancel) |
63353 | 1226 |
from \<open>n \<noteq> 0\<close> and gcd_l have "?gcd * ?l \<noteq> 0" by simp |
61284
2314c2f62eb1
real_of_nat_Suc is now a simprule
paulson <lp15@cam.ac.uk>
parents:
61204
diff
changeset
|
1227 |
then have "?l \<noteq> 0" by (blast dest!: mult_not_zero) |
51523 | 1228 |
moreover |
1229 |
have "\<bar>x\<bar> = real ?k / real ?l" |
|
1230 |
proof - |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1231 |
from gcd have "real ?k / real ?l = real (?gcd * ?k) / real (?gcd * ?l)" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1232 |
by (simp add: real_of_nat_div) |
51523 | 1233 |
also from gcd_k and gcd_l have "\<dots> = real m / real n" by simp |
1234 |
also from x_rat have "\<dots> = \<bar>x\<bar>" .. |
|
1235 |
finally show ?thesis .. |
|
1236 |
qed |
|
1237 |
moreover |
|
1238 |
have "?gcd' = 1" |
|
1239 |
proof - |
|
1240 |
have "?gcd * ?gcd' = gcd (?gcd * ?k) (?gcd * ?l)" |
|
1241 |
by (rule gcd_mult_distrib_nat) |
|
1242 |
with gcd_k gcd_l have "?gcd * ?gcd' = ?gcd" by simp |
|
1243 |
with gcd show ?thesis by auto |
|
1244 |
qed |
|
1245 |
ultimately show ?thesis .. |
|
1246 |
qed |
|
1247 |
||
63353 | 1248 |
|
1249 |
subsection \<open>Density of the Rational Reals in the Reals\<close> |
|
51523 | 1250 |
|
63353 | 1251 |
text \<open> |
1252 |
This density proof is due to Stefan Richter and was ported by TN. The |
|
1253 |
original source is \emph{Real Analysis} by H.L. Royden. |
|
1254 |
It employs the Archimedean property of the reals.\<close> |
|
51523 | 1255 |
|
1256 |
lemma Rats_dense_in_real: |
|
1257 |
fixes x :: real |
|
63353 | 1258 |
assumes "x < y" |
1259 |
shows "\<exists>r\<in>\<rat>. x < r \<and> r < y" |
|
51523 | 1260 |
proof - |
63353 | 1261 |
from \<open>x < y\<close> have "0 < y - x" by simp |
1262 |
with reals_Archimedean obtain q :: nat where q: "inverse (real q) < y - x" and "0 < q" |
|
1263 |
by blast |
|
63040 | 1264 |
define p where "p = \<lceil>y * real q\<rceil> - 1" |
1265 |
define r where "r = of_int p / real q" |
|
51523 | 1266 |
from q have "x < y - inverse (real q)" by simp |
1267 |
also have "y - inverse (real q) \<le> r" |
|
1268 |
unfolding r_def p_def |
|
60758 | 1269 |
by (simp add: le_divide_eq left_diff_distrib le_of_int_ceiling \<open>0 < q\<close>) |
51523 | 1270 |
finally have "x < r" . |
1271 |
moreover have "r < y" |
|
1272 |
unfolding r_def p_def |
|
63353 | 1273 |
by (simp add: divide_less_eq diff_less_eq \<open>0 < q\<close> less_ceiling_iff [symmetric]) |
51523 | 1274 |
moreover from r_def have "r \<in> \<rat>" by simp |
61649
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents:
61609
diff
changeset
|
1275 |
ultimately show ?thesis by blast |
51523 | 1276 |
qed |
1277 |
||
57447
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents:
57275
diff
changeset
|
1278 |
lemma of_rat_dense: |
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents:
57275
diff
changeset
|
1279 |
fixes x y :: real |
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents:
57275
diff
changeset
|
1280 |
assumes "x < y" |
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents:
57275
diff
changeset
|
1281 |
shows "\<exists>q :: rat. x < of_rat q \<and> of_rat q < y" |
63353 | 1282 |
using Rats_dense_in_real [OF \<open>x < y\<close>] |
1283 |
by (auto elim: Rats_cases) |
|
51523 | 1284 |
|
1285 |
||
63353 | 1286 |
subsection \<open>Numerals and Arithmetic\<close> |
51523 | 1287 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1288 |
lemma [code_abbrev]: (*FIXME*) |
51523 | 1289 |
"real_of_int (numeral k) = numeral k" |
54489
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54281
diff
changeset
|
1290 |
"real_of_int (- numeral k) = - numeral k" |
51523 | 1291 |
by simp_all |
1292 |
||
60758 | 1293 |
declaration \<open> |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1294 |
K (Lin_Arith.add_inj_thms [@{thm of_nat_le_iff} RS iffD2, @{thm of_nat_eq_iff} RS iffD2] |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1295 |
(* not needed because x < (y::nat) can be rewritten as Suc x <= y: of_nat_less_iff RS iffD2 *) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1296 |
#> Lin_Arith.add_inj_thms [@{thm of_int_le_iff} RS iffD2, @{thm of_nat_eq_iff} RS iffD2] |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1297 |
(* not needed because x < (y::int) can be rewritten as x + 1 <= y: of_int_less_iff RS iffD2 *) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1298 |
#> Lin_Arith.add_simps [@{thm of_nat_0}, @{thm of_nat_Suc}, @{thm of_nat_add}, |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1299 |
@{thm of_nat_mult}, @{thm of_int_0}, @{thm of_int_1}, |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1300 |
@{thm of_int_add}, @{thm of_int_minus}, @{thm of_int_diff}, |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1301 |
@{thm of_int_mult}, @{thm of_int_of_nat_eq}, |
62348 | 1302 |
@{thm of_nat_numeral}, @{thm of_nat_numeral}, @{thm of_int_neg_numeral}] |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1303 |
#> Lin_Arith.add_inj_const (@{const_name of_nat}, @{typ "nat \<Rightarrow> real"}) |
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1304 |
#> Lin_Arith.add_inj_const (@{const_name of_int}, @{typ "int \<Rightarrow> real"})) |
60758 | 1305 |
\<close> |
51523 | 1306 |
|
63353 | 1307 |
|
1308 |
subsection \<open>Simprules combining \<open>x + y\<close> and \<open>0\<close>\<close> (* FIXME ARE THEY NEEDED? *) |
|
51523 | 1309 |
|
63353 | 1310 |
lemma real_add_minus_iff [simp]: "x + - a = 0 \<longleftrightarrow> x = a" for x a :: real |
1311 |
by arith |
|
51523 | 1312 |
|
63353 | 1313 |
lemma real_add_less_0_iff: "x + y < 0 \<longleftrightarrow> y < - x" for x y :: real |
1314 |
by auto |
|
51523 | 1315 |
|
63353 | 1316 |
lemma real_0_less_add_iff: "0 < x + y \<longleftrightarrow> - x < y" for x y :: real |
1317 |
by auto |
|
51523 | 1318 |
|
63353 | 1319 |
lemma real_add_le_0_iff: "x + y \<le> 0 \<longleftrightarrow> y \<le> - x" for x y :: real |
1320 |
by auto |
|
51523 | 1321 |
|
63353 | 1322 |
lemma real_0_le_add_iff: "0 \<le> x + y \<longleftrightarrow> - x \<le> y" for x y :: real |
1323 |
by auto |
|
1324 |
||
51523 | 1325 |
|
60758 | 1326 |
subsection \<open>Lemmas about powers\<close> |
51523 | 1327 |
|
1328 |
lemma two_realpow_ge_one: "(1::real) \<le> 2 ^ n" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1329 |
by simp |
51523 | 1330 |
|
63353 | 1331 |
(* FIXME: declare this [simp] for all types, or not at all *) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1332 |
declare sum_squares_eq_zero_iff [simp] sum_power2_eq_zero_iff [simp] |
51523 | 1333 |
|
63353 | 1334 |
lemma real_minus_mult_self_le [simp]: "- (u * u) \<le> x * x" for u x :: real |
1335 |
by (rule order_trans [where y = 0]) auto |
|
51523 | 1336 |
|
63353 | 1337 |
lemma realpow_square_minus_le [simp]: "- u\<^sup>2 \<le> x\<^sup>2" for u x :: real |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1338 |
by (auto simp add: power2_eq_square) |
51523 | 1339 |
|
63353 | 1340 |
lemma numeral_power_eq_real_of_int_cancel_iff [simp]: |
1341 |
"numeral x ^ n = real_of_int y \<longleftrightarrow> numeral x ^ n = y" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1342 |
by (metis of_int_eq_iff of_int_numeral of_int_power) |
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1343 |
|
63353 | 1344 |
lemma real_of_int_eq_numeral_power_cancel_iff [simp]: |
1345 |
"real_of_int y = numeral x ^ n \<longleftrightarrow> y = numeral x ^ n" |
|
1346 |
using numeral_power_eq_real_of_int_cancel_iff [of x n y] by metis |
|
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1347 |
|
63353 | 1348 |
lemma numeral_power_eq_real_of_nat_cancel_iff [simp]: |
1349 |
"numeral x ^ n = real y \<longleftrightarrow> numeral x ^ n = y" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1350 |
using of_nat_eq_iff by fastforce |
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1351 |
|
63353 | 1352 |
lemma real_of_nat_eq_numeral_power_cancel_iff [simp]: |
1353 |
"real y = numeral x ^ n \<longleftrightarrow> y = numeral x ^ n" |
|
1354 |
using numeral_power_eq_real_of_nat_cancel_iff [of x n y] by metis |
|
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1355 |
|
63353 | 1356 |
lemma numeral_power_le_real_of_nat_cancel_iff [simp]: |
1357 |
"(numeral x :: real) ^ n \<le> real a \<longleftrightarrow> (numeral x::nat) ^ n \<le> a" |
|
1358 |
by (metis of_nat_le_iff of_nat_numeral of_nat_power) |
|
51523 | 1359 |
|
63353 | 1360 |
lemma real_of_nat_le_numeral_power_cancel_iff [simp]: |
51523 | 1361 |
"real a \<le> (numeral x::real) ^ n \<longleftrightarrow> a \<le> (numeral x::nat) ^ n" |
63353 | 1362 |
by (metis of_nat_le_iff of_nat_numeral of_nat_power) |
51523 | 1363 |
|
63353 | 1364 |
lemma numeral_power_le_real_of_int_cancel_iff [simp]: |
1365 |
"(numeral x::real) ^ n \<le> real_of_int a \<longleftrightarrow> (numeral x::int) ^ n \<le> a" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1366 |
by (metis ceiling_le_iff ceiling_of_int of_int_numeral of_int_power) |
51523 | 1367 |
|
63353 | 1368 |
lemma real_of_int_le_numeral_power_cancel_iff [simp]: |
1369 |
"real_of_int a \<le> (numeral x::real) ^ n \<longleftrightarrow> a \<le> (numeral x::int) ^ n" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1370 |
by (metis floor_of_int le_floor_iff of_int_numeral of_int_power) |
51523 | 1371 |
|
63353 | 1372 |
lemma numeral_power_less_real_of_nat_cancel_iff [simp]: |
1373 |
"(numeral x::real) ^ n < real a \<longleftrightarrow> (numeral x::nat) ^ n < a" |
|
1374 |
by (metis of_nat_less_iff of_nat_numeral of_nat_power) |
|
1375 |
||
1376 |
lemma real_of_nat_less_numeral_power_cancel_iff [simp]: |
|
1377 |
"real a < (numeral x::real) ^ n \<longleftrightarrow> a < (numeral x::nat) ^ n" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1378 |
by (metis of_nat_less_iff of_nat_numeral of_nat_power) |
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1379 |
|
63353 | 1380 |
lemma numeral_power_less_real_of_int_cancel_iff [simp]: |
1381 |
"(numeral x::real) ^ n < real_of_int a \<longleftrightarrow> (numeral x::int) ^ n < a" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1382 |
by (meson not_less real_of_int_le_numeral_power_cancel_iff) |
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1383 |
|
63353 | 1384 |
lemma real_of_int_less_numeral_power_cancel_iff [simp]: |
1385 |
"real_of_int a < (numeral x::real) ^ n \<longleftrightarrow> a < (numeral x::int) ^ n" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1386 |
by (meson not_less numeral_power_le_real_of_int_cancel_iff) |
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1387 |
|
63353 | 1388 |
lemma neg_numeral_power_le_real_of_int_cancel_iff [simp]: |
1389 |
"(- numeral x::real) ^ n \<le> real_of_int a \<longleftrightarrow> (- numeral x::int) ^ n \<le> a" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1390 |
by (metis of_int_le_iff of_int_neg_numeral of_int_power) |
51523 | 1391 |
|
63353 | 1392 |
lemma real_of_int_le_neg_numeral_power_cancel_iff [simp]: |
1393 |
"real_of_int a \<le> (- numeral x::real) ^ n \<longleftrightarrow> a \<le> (- numeral x::int) ^ n" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1394 |
by (metis of_int_le_iff of_int_neg_numeral of_int_power) |
51523 | 1395 |
|
56889
48a745e1bde7
avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
hoelzl
parents:
56571
diff
changeset
|
1396 |
|
63353 | 1397 |
subsection \<open>Density of the Reals\<close> |
1398 |
||
1399 |
lemma real_lbound_gt_zero: "0 < d1 \<Longrightarrow> 0 < d2 \<Longrightarrow> \<exists>e. 0 < e \<and> e < d1 \<and> e < d2" for d1 d2 :: real |
|
1400 |
by (rule exI [where x = "min d1 d2 / 2"]) (simp add: min_def) |
|
51523 | 1401 |
|
63353 | 1402 |
text \<open>Similar results are proved in @{theory Fields}\<close> |
1403 |
lemma real_less_half_sum: "x < y \<Longrightarrow> x < (x + y) / 2" for x y :: real |
|
1404 |
by auto |
|
1405 |
||
1406 |
lemma real_gt_half_sum: "x < y \<Longrightarrow> (x + y) / 2 < y" for x y :: real |
|
1407 |
by auto |
|
1408 |
||
1409 |
lemma real_sum_of_halves: "x / 2 + x / 2 = x" for x :: real |
|
1410 |
by simp |
|
51523 | 1411 |
|
1412 |
||
63353 | 1413 |
subsection \<open>Floor and Ceiling Functions from the Reals to the Integers\<close> |
51523 | 1414 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1415 |
(* FIXME: theorems for negative numerals. Many duplicates, e.g. from Archimedean_Field.thy. *) |
51523 | 1416 |
|
63353 | 1417 |
lemma real_of_nat_less_numeral_iff [simp]: "real n < numeral w \<longleftrightarrow> n < numeral w" for n :: nat |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1418 |
by (metis of_nat_less_iff of_nat_numeral) |
56889
48a745e1bde7
avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
hoelzl
parents:
56571
diff
changeset
|
1419 |
|
63353 | 1420 |
lemma numeral_less_real_of_nat_iff [simp]: "numeral w < real n \<longleftrightarrow> numeral w < n" for n :: nat |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1421 |
by (metis of_nat_less_iff of_nat_numeral) |
56889
48a745e1bde7
avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
hoelzl
parents:
56571
diff
changeset
|
1422 |
|
63353 | 1423 |
lemma numeral_le_real_of_nat_iff [simp]: "numeral n \<le> real m \<longleftrightarrow> numeral n \<le> m" for m :: nat |
1424 |
by (metis not_le real_of_nat_less_numeral_iff) |
|
59587
8ea7b22525cb
Removed the obsolete functions "natfloor" and "natceiling"
nipkow
parents:
59000
diff
changeset
|
1425 |
|
63353 | 1426 |
declare of_int_floor_le [simp] (* FIXME duplicate!? *) |
51523 | 1427 |
|
63353 | 1428 |
lemma of_int_floor_cancel [simp]: "of_int \<lfloor>x\<rfloor> = x \<longleftrightarrow> (\<exists>n::int. x = of_int n)" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1429 |
by (metis floor_of_int) |
51523 | 1430 |
|
63353 | 1431 |
lemma floor_eq: "real_of_int n < x \<Longrightarrow> x < real_of_int n + 1 \<Longrightarrow> \<lfloor>x\<rfloor> = n" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1432 |
by linarith |
51523 | 1433 |
|
63353 | 1434 |
lemma floor_eq2: "real_of_int n \<le> x \<Longrightarrow> x < real_of_int n + 1 \<Longrightarrow> \<lfloor>x\<rfloor> = n" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1435 |
by linarith |
51523 | 1436 |
|
63353 | 1437 |
lemma floor_eq3: "real n < x \<Longrightarrow> x < real (Suc n) \<Longrightarrow> nat \<lfloor>x\<rfloor> = n" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1438 |
by linarith |
51523 | 1439 |
|
63353 | 1440 |
lemma floor_eq4: "real n \<le> x \<Longrightarrow> x < real (Suc n) \<Longrightarrow> nat \<lfloor>x\<rfloor> = n" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1441 |
by linarith |
51523 | 1442 |
|
61942 | 1443 |
lemma real_of_int_floor_ge_diff_one [simp]: "r - 1 \<le> real_of_int \<lfloor>r\<rfloor>" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1444 |
by linarith |
51523 | 1445 |
|
61942 | 1446 |
lemma real_of_int_floor_gt_diff_one [simp]: "r - 1 < real_of_int \<lfloor>r\<rfloor>" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1447 |
by linarith |
51523 | 1448 |
|
61942 | 1449 |
lemma real_of_int_floor_add_one_ge [simp]: "r \<le> real_of_int \<lfloor>r\<rfloor> + 1" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1450 |
by linarith |
51523 | 1451 |
|
61942 | 1452 |
lemma real_of_int_floor_add_one_gt [simp]: "r < real_of_int \<lfloor>r\<rfloor> + 1" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1453 |
by linarith |
51523 | 1454 |
|
61942 | 1455 |
lemma floor_eq_iff: "\<lfloor>x\<rfloor> = b \<longleftrightarrow> of_int b \<le> x \<and> x < of_int (b + 1)" |
1456 |
by (simp add: floor_unique_iff) |
|
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1457 |
|
61942 | 1458 |
lemma floor_add2[simp]: "\<lfloor>of_int a + x\<rfloor> = a + \<lfloor>x\<rfloor>" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1459 |
by (simp add: add.commute) |
51523 | 1460 |
|
63353 | 1461 |
lemma floor_divide_real_eq_div: |
1462 |
assumes "0 \<le> b" |
|
1463 |
shows "\<lfloor>a / real_of_int b\<rfloor> = \<lfloor>a\<rfloor> div b" |
|
1464 |
proof (cases "b = 0") |
|
1465 |
case True |
|
1466 |
then show ?thesis by simp |
|
1467 |
next |
|
1468 |
case False |
|
1469 |
with assms have b: "b > 0" by simp |
|
1470 |
have "j = i div b" |
|
1471 |
if "real_of_int i \<le> a" "a < 1 + real_of_int i" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1472 |
"real_of_int j * real_of_int b \<le> a" "a < real_of_int b + real_of_int j * real_of_int b" |
63353 | 1473 |
for i j :: int |
1474 |
proof - |
|
1475 |
from that have "i < b + j * b" |
|
1476 |
by (metis le_less_trans of_int_add of_int_less_iff of_int_mult) |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1477 |
moreover have "j * b < 1 + i" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1478 |
proof - |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1479 |
have "real_of_int (j * b) < real_of_int i + 1" |
61799 | 1480 |
using \<open>a < 1 + real_of_int i\<close> \<open>real_of_int j * real_of_int b \<le> a\<close> by force |
63353 | 1481 |
then show "j * b < 1 + i" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1482 |
by linarith |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1483 |
qed |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1484 |
ultimately have "(j - i div b) * b \<le> i mod b" "i mod b < ((j - i div b) + 1) * b" |
58788
d17b3844b726
generalize natfloor_div_nat, add floor variant: floor_divide_real_eq_div
hoelzl
parents:
58134
diff
changeset
|
1485 |
by (auto simp: field_simps) |
d17b3844b726
generalize natfloor_div_nat, add floor variant: floor_divide_real_eq_div
hoelzl
parents:
58134
diff
changeset
|
1486 |
then have "(j - i div b) * b < 1 * b" "0 * b < ((j - i div b) + 1) * b" |
63353 | 1487 |
using pos_mod_bound [OF b, of i] pos_mod_sign [OF b, of i] |
1488 |
by linarith+ |
|
1489 |
then show ?thesis |
|
1490 |
using b unfolding mult_less_cancel_right by auto |
|
1491 |
qed |
|
1492 |
with b show ?thesis |
|
58788
d17b3844b726
generalize natfloor_div_nat, add floor variant: floor_divide_real_eq_div
hoelzl
parents:
58134
diff
changeset
|
1493 |
by (auto split: floor_split simp: field_simps) |
63353 | 1494 |
qed |
58788
d17b3844b726
generalize natfloor_div_nat, add floor variant: floor_divide_real_eq_div
hoelzl
parents:
58134
diff
changeset
|
1495 |
|
63353 | 1496 |
lemma floor_divide_eq_div_numeral [simp]: "\<lfloor>numeral a / numeral b::real\<rfloor> = numeral a div numeral b" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1497 |
by (metis floor_divide_of_int_eq of_int_numeral) |
58097
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1498 |
|
63353 | 1499 |
lemma floor_minus_divide_eq_div_numeral [simp]: |
1500 |
"\<lfloor>- (numeral a / numeral b)::real\<rfloor> = - numeral a div numeral b" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1501 |
by (metis divide_minus_left floor_divide_of_int_eq of_int_neg_numeral of_int_numeral) |
51523 | 1502 |
|
63353 | 1503 |
lemma of_int_ceiling_cancel [simp]: "of_int \<lceil>x\<rceil> = x \<longleftrightarrow> (\<exists>n::int. x = of_int n)" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1504 |
using ceiling_of_int by metis |
51523 | 1505 |
|
63353 | 1506 |
lemma ceiling_eq: "of_int n < x \<Longrightarrow> x \<le> of_int n + 1 \<Longrightarrow> \<lceil>x\<rceil> = n + 1" |
61694
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents:
61649
diff
changeset
|
1507 |
by (simp add: ceiling_unique) |
51523 | 1508 |
|
61942 | 1509 |
lemma of_int_ceiling_diff_one_le [simp]: "of_int \<lceil>r\<rceil> - 1 \<le> r" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1510 |
by linarith |
51523 | 1511 |
|
61942 | 1512 |
lemma of_int_ceiling_le_add_one [simp]: "of_int \<lceil>r\<rceil> \<le> r + 1" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1513 |
by linarith |
51523 | 1514 |
|
63353 | 1515 |
lemma ceiling_le: "x \<le> of_int a \<Longrightarrow> \<lceil>x\<rceil> \<le> a" |
61694
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents:
61649
diff
changeset
|
1516 |
by (simp add: ceiling_le_iff) |
51523 | 1517 |
|
61694
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
paulson <lp15@cam.ac.uk>
parents:
61649
diff
changeset
|
1518 |
lemma ceiling_divide_eq_div: "\<lceil>of_int a / of_int b\<rceil> = - (- a div b)" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1519 |
by (metis ceiling_def floor_divide_of_int_eq minus_divide_left of_int_minus) |
58097
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1520 |
|
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1521 |
lemma ceiling_divide_eq_div_numeral [simp]: |
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1522 |
"\<lceil>numeral a / numeral b :: real\<rceil> = - (- numeral a div numeral b)" |
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1523 |
using ceiling_divide_eq_div[of "numeral a" "numeral b"] by simp |
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1524 |
|
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1525 |
lemma ceiling_minus_divide_eq_div_numeral [simp]: |
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1526 |
"\<lceil>- (numeral a / numeral b :: real)\<rceil> = - (numeral a div numeral b)" |
cfd3cff9387b
add simp rules for divisions of numerals in floor and ceiling.
hoelzl
parents:
58061
diff
changeset
|
1527 |
using ceiling_divide_eq_div[of "- numeral a" "numeral b"] by simp |
51523 | 1528 |
|
63353 | 1529 |
text \<open> |
1530 |
The following lemmas are remnants of the erstwhile functions natfloor |
|
1531 |
and natceiling. |
|
1532 |
\<close> |
|
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1533 |
|
63353 | 1534 |
lemma nat_floor_neg: "x \<le> 0 \<Longrightarrow> nat \<lfloor>x\<rfloor> = 0" for x :: real |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1535 |
by linarith |
51523 | 1536 |
|
63353 | 1537 |
lemma le_nat_floor: "real x \<le> a \<Longrightarrow> x \<le> nat \<lfloor>a\<rfloor>" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1538 |
by linarith |
51523 | 1539 |
|
61942 | 1540 |
lemma le_mult_nat_floor: "nat \<lfloor>a\<rfloor> * nat \<lfloor>b\<rfloor> \<le> nat \<lfloor>a * b\<rfloor>" |
63353 | 1541 |
by (cases "0 \<le> a \<and> 0 \<le> b") |
59587
8ea7b22525cb
Removed the obsolete functions "natfloor" and "natceiling"
nipkow
parents:
59000
diff
changeset
|
1542 |
(auto simp add: nat_mult_distrib[symmetric] nat_mono le_mult_floor) |
51523 | 1543 |
|
63353 | 1544 |
lemma nat_ceiling_le_eq [simp]: "nat \<lceil>x\<rceil> \<le> a \<longleftrightarrow> x \<le> real a" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1545 |
by linarith |
51523 | 1546 |
|
63353 | 1547 |
lemma real_nat_ceiling_ge: "x \<le> real (nat \<lceil>x\<rceil>)" |
58040
9a867afaab5a
better linarith support for floor, ceiling, natfloor, and natceiling
hoelzl
parents:
57514
diff
changeset
|
1548 |
by linarith |
51523 | 1549 |
|
63353 | 1550 |
lemma Rats_no_top_le: "\<exists>q \<in> \<rat>. x \<le> q" for x :: real |
61942 | 1551 |
by (auto intro!: bexI[of _ "of_nat (nat \<lceil>x\<rceil>)"]) linarith |
57275
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
hoelzl
parents:
56889
diff
changeset
|
1552 |
|
63353 | 1553 |
lemma Rats_no_bot_less: "\<exists>q \<in> \<rat>. q < x" for x :: real |
61942 | 1554 |
apply (auto intro!: bexI[of _ "of_int (\<lfloor>x\<rfloor> - 1)"]) |
57447
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents:
57275
diff
changeset
|
1555 |
apply (rule less_le_trans[OF _ of_int_floor_le]) |
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents:
57275
diff
changeset
|
1556 |
apply simp |
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents:
57275
diff
changeset
|
1557 |
done |
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
hoelzl
parents:
57275
diff
changeset
|
1558 |
|
63353 | 1559 |
|
60758 | 1560 |
subsection \<open>Exponentiation with floor\<close> |
51523 | 1561 |
|
1562 |
lemma floor_power: |
|
61942 | 1563 |
assumes "x = of_int \<lfloor>x\<rfloor>" |
1564 |
shows "\<lfloor>x ^ n\<rfloor> = \<lfloor>x\<rfloor> ^ n" |
|
51523 | 1565 |
proof - |
61942 | 1566 |
have "x ^ n = of_int (\<lfloor>x\<rfloor> ^ n)" |
51523 | 1567 |
using assms by (induct n arbitrary: x) simp_all |
62626
de25474ce728
Contractible sets. Also removal of obsolete theorems and refactoring
paulson <lp15@cam.ac.uk>
parents:
62623
diff
changeset
|
1568 |
then show ?thesis by (metis floor_of_int) |
51523 | 1569 |
qed |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61284
diff
changeset
|
1570 |
|
63353 | 1571 |
lemma floor_numeral_power [simp]: "\<lfloor>numeral x ^ n\<rfloor> = numeral x ^ n" |
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1572 |
by (metis floor_of_int of_int_numeral of_int_power) |
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1573 |
|
63353 | 1574 |
lemma ceiling_numeral_power [simp]: "\<lceil>numeral x ^ n\<rceil> = numeral x ^ n" |
58983
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1575 |
by (metis ceiling_of_int of_int_numeral of_int_power) |
9c390032e4eb
cancel real of power of numeral also for equality and strict inequality;
immler
parents:
58889
diff
changeset
|
1576 |
|
63353 | 1577 |
|
60758 | 1578 |
subsection \<open>Implementation of rational real numbers\<close> |
51523 | 1579 |
|
60758 | 1580 |
text \<open>Formal constructor\<close> |
51523 | 1581 |
|
63353 | 1582 |
definition Ratreal :: "rat \<Rightarrow> real" |
1583 |
where [code_abbrev, simp]: "Ratreal = of_rat" |
|
51523 | 1584 |
|
1585 |
code_datatype Ratreal |
|
1586 |
||
1587 |
||
60758 | 1588 |
text \<open>Numerals\<close> |
51523 | 1589 |
|
63353 | 1590 |
lemma [code_abbrev]: "(of_rat (of_int a) :: real) = of_int a" |
51523 | 1591 |
by simp |
1592 |
||
63353 | 1593 |
lemma [code_abbrev]: "(of_rat 0 :: real) = 0" |
51523 | 1594 |
by simp |
1595 |
||
63353 | 1596 |
lemma [code_abbrev]: "(of_rat 1 :: real) = 1" |
51523 | 1597 |
by simp |
1598 |
||
63353 | 1599 |
lemma [code_abbrev]: "(of_rat (- 1) :: real) = - 1" |
58134
b563ec62d04e
more convenient printing of real numbers after evaluation
haftmann
parents:
58097
diff
changeset
|
1600 |
by simp |
b563ec62d04e
more convenient printing of real numbers after evaluation
haftmann
parents:
58097
diff
changeset
|
1601 |
|
63353 | 1602 |
lemma [code_abbrev]: "(of_rat (numeral k) :: real) = numeral k" |
51523 | 1603 |
by simp |
1604 |
||
63353 | 1605 |
lemma [code_abbrev]: "(of_rat (- numeral k) :: real) = - numeral k" |
51523 | 1606 |
by simp |
1607 |
||
1608 |
lemma [code_post]: |
|
1609 |
"(of_rat (1 / numeral k) :: real) = 1 / numeral k" |
|
58134
b563ec62d04e
more convenient printing of real numbers after evaluation
haftmann
parents:
58097
diff
changeset
|
1610 |
"(of_rat (numeral k / numeral l) :: real) = numeral k / numeral l" |
b563ec62d04e
more convenient printing of real numbers after evaluation
haftmann
parents:
58097
diff
changeset
|
1611 |
"(of_rat (- (1 / numeral k)) :: real) = - (1 / numeral k)" |
b563ec62d04e
more convenient printing of real numbers after evaluation
haftmann
parents:
58097
diff
changeset
|
1612 |
"(of_rat (- (numeral k / numeral l)) :: real) = - (numeral k / numeral l)" |
54489
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54281
diff
changeset
|
1613 |
by (simp_all add: of_rat_divide of_rat_minus) |
51523 | 1614 |
|
1615 |
||
60758 | 1616 |
text \<open>Operations\<close> |
51523 | 1617 |
|
63353 | 1618 |
lemma zero_real_code [code]: "0 = Ratreal 0" |
51523 | 1619 |
by simp |
1620 |
||
63353 | 1621 |
lemma one_real_code [code]: "1 = Ratreal 1" |
51523 | 1622 |
by simp |
1623 |
||
1624 |
instantiation real :: equal |
|
1625 |
begin |
|
1626 |
||
63353 | 1627 |
definition "HOL.equal x y \<longleftrightarrow> x - y = 0" for x :: real |
51523 | 1628 |
|
63353 | 1629 |
instance by standard (simp add: equal_real_def) |
51523 | 1630 |
|
63353 | 1631 |
lemma real_equal_code [code]: "HOL.equal (Ratreal x) (Ratreal y) \<longleftrightarrow> HOL.equal x y" |
51523 | 1632 |
by (simp add: equal_real_def equal) |
1633 |
||
63353 | 1634 |
lemma [code nbe]: "HOL.equal x x \<longleftrightarrow> True" for x :: real |
51523 | 1635 |
by (rule equal_refl) |
1636 |
||
1637 |
end |
|
1638 |
||
1639 |
lemma real_less_eq_code [code]: "Ratreal x \<le> Ratreal y \<longleftrightarrow> x \<le> y" |
|
1640 |
by (simp add: of_rat_less_eq) |
|
1641 |
||
1642 |
lemma real_less_code [code]: "Ratreal x < Ratreal y \<longleftrightarrow> x < y" |
|
1643 |
by (simp add: of_rat_less) |
|
1644 |
||
1645 |
lemma real_plus_code [code]: "Ratreal x + Ratreal y = Ratreal (x + y)" |
|
1646 |
by (simp add: of_rat_add) |
|
1647 |
||
1648 |
lemma real_times_code [code]: "Ratreal x * Ratreal y = Ratreal (x * y)" |
|
1649 |
by (simp add: of_rat_mult) |
|
1650 |
||
1651 |
lemma real_uminus_code [code]: "- Ratreal x = Ratreal (- x)" |
|
1652 |
by (simp add: of_rat_minus) |
|
1653 |
||
1654 |
lemma real_minus_code [code]: "Ratreal x - Ratreal y = Ratreal (x - y)" |
|
1655 |
by (simp add: of_rat_diff) |
|
1656 |
||
1657 |
lemma real_inverse_code [code]: "inverse (Ratreal x) = Ratreal (inverse x)" |
|
1658 |
by (simp add: of_rat_inverse) |
|
61284
2314c2f62eb1
real_of_nat_Suc is now a simprule
paulson <lp15@cam.ac.uk>
parents:
61204
diff
changeset
|
1659 |
|
51523 | 1660 |
lemma real_divide_code [code]: "Ratreal x / Ratreal y = Ratreal (x / y)" |
1661 |
by (simp add: of_rat_divide) |
|
1662 |
||
61942 | 1663 |
lemma real_floor_code [code]: "\<lfloor>Ratreal x\<rfloor> = \<lfloor>x\<rfloor>" |
63353 | 1664 |
by (metis Ratreal_def floor_le_iff floor_unique le_floor_iff |
1665 |
of_int_floor_le of_rat_of_int_eq real_less_eq_code) |
|
51523 | 1666 |
|
1667 |
||
60758 | 1668 |
text \<open>Quickcheck\<close> |
51523 | 1669 |
|
1670 |
definition (in term_syntax) |
|
63353 | 1671 |
valterm_ratreal :: "rat \<times> (unit \<Rightarrow> Code_Evaluation.term) \<Rightarrow> real \<times> (unit \<Rightarrow> Code_Evaluation.term)" |
1672 |
where [code_unfold]: "valterm_ratreal k = Code_Evaluation.valtermify Ratreal {\<cdot>} k" |
|
51523 | 1673 |
|
1674 |
notation fcomp (infixl "\<circ>>" 60) |
|
1675 |
notation scomp (infixl "\<circ>\<rightarrow>" 60) |
|
1676 |
||
1677 |
instantiation real :: random |
|
1678 |
begin |
|
1679 |
||
1680 |
definition |
|
1681 |
"Quickcheck_Random.random i = Quickcheck_Random.random i \<circ>\<rightarrow> (\<lambda>r. Pair (valterm_ratreal r))" |
|
1682 |
||
1683 |
instance .. |
|
1684 |
||
1685 |
end |
|
1686 |
||
1687 |
no_notation fcomp (infixl "\<circ>>" 60) |
|
1688 |
no_notation scomp (infixl "\<circ>\<rightarrow>" 60) |
|
1689 |
||
1690 |
instantiation real :: exhaustive |
|
1691 |
begin |
|
1692 |
||
1693 |
definition |
|
63353 | 1694 |
"exhaustive_real f d = Quickcheck_Exhaustive.exhaustive (\<lambda>r. f (Ratreal r)) d" |
51523 | 1695 |
|
1696 |
instance .. |
|
1697 |
||
1698 |
end |
|
1699 |
||
1700 |
instantiation real :: full_exhaustive |
|
1701 |
begin |
|
1702 |
||
1703 |
definition |
|
63353 | 1704 |
"full_exhaustive_real f d = Quickcheck_Exhaustive.full_exhaustive (\<lambda>r. f (valterm_ratreal r)) d" |
51523 | 1705 |
|
1706 |
instance .. |
|
1707 |
||
1708 |
end |
|
1709 |
||
1710 |
instantiation real :: narrowing |
|
1711 |
begin |
|
1712 |
||
1713 |
definition |
|
63353 | 1714 |
"narrowing_real = Quickcheck_Narrowing.apply (Quickcheck_Narrowing.cons Ratreal) narrowing" |
51523 | 1715 |
|
1716 |
instance .. |
|
1717 |
||
1718 |
end |
|
1719 |
||
1720 |
||
60758 | 1721 |
subsection \<open>Setup for Nitpick\<close> |
51523 | 1722 |
|
60758 | 1723 |
declaration \<open> |
51523 | 1724 |
Nitpick_HOL.register_frac_type @{type_name real} |
62079 | 1725 |
[(@{const_name zero_real_inst.zero_real}, @{const_name Nitpick.zero_frac}), |
1726 |
(@{const_name one_real_inst.one_real}, @{const_name Nitpick.one_frac}), |
|
1727 |
(@{const_name plus_real_inst.plus_real}, @{const_name Nitpick.plus_frac}), |
|
1728 |
(@{const_name times_real_inst.times_real}, @{const_name Nitpick.times_frac}), |
|
1729 |
(@{const_name uminus_real_inst.uminus_real}, @{const_name Nitpick.uminus_frac}), |
|
1730 |
(@{const_name inverse_real_inst.inverse_real}, @{const_name Nitpick.inverse_frac}), |
|
1731 |
(@{const_name ord_real_inst.less_real}, @{const_name Nitpick.less_frac}), |
|
1732 |
(@{const_name ord_real_inst.less_eq_real}, @{const_name Nitpick.less_eq_frac})] |
|
60758 | 1733 |
\<close> |
51523 | 1734 |
|
1735 |
lemmas [nitpick_unfold] = inverse_real_inst.inverse_real one_real_inst.one_real |
|
63353 | 1736 |
ord_real_inst.less_real ord_real_inst.less_eq_real plus_real_inst.plus_real |
1737 |
times_real_inst.times_real uminus_real_inst.uminus_real |
|
1738 |
zero_real_inst.zero_real |
|
51523 | 1739 |
|
56078
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
blanchet
parents:
55945
diff
changeset
|
1740 |
|
60758 | 1741 |
subsection \<open>Setup for SMT\<close> |
56078
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
blanchet
parents:
55945
diff
changeset
|
1742 |
|
58061 | 1743 |
ML_file "Tools/SMT/smt_real.ML" |
1744 |
ML_file "Tools/SMT/z3_real.ML" |
|
56078
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
blanchet
parents:
55945
diff
changeset
|
1745 |
|
58061 | 1746 |
lemma [z3_rule]: |
63353 | 1747 |
"0 + x = x" |
56078
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
blanchet
parents:
55945
diff
changeset
|
1748 |
"x + 0 = x" |
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
blanchet
parents:
55945
diff
changeset
|
1749 |
"0 * x = 0" |
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
blanchet
parents:
55945
diff
changeset
|
1750 |
"1 * x = x" |
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
blanchet
parents:
55945
diff
changeset
|
1751 |
"x + y = y + x" |
63353 | 1752 |
for x y :: real |
56078
624faeda77b5
moved 'SMT2' (SMT-LIB-2-based SMT module) into Isabelle
blanchet
parents:
55945
diff
changeset
|
1753 |
by auto |
51523 | 1754 |
|
1755 |
end |