author | haftmann |
Fri, 19 Oct 2007 07:48:25 +0200 | |
changeset 25090 | 4a50b958391a |
parent 25077 | c2ec5e589d78 |
child 25102 | db3e412c4cb1 |
permissions | -rw-r--r-- |
14770 | 1 |
(* Title: HOL/OrderedGroup.thy |
14738 | 2 |
ID: $Id$ |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
3 |
Author: Gertrud Bauer, Steven Obua, Lawrence C Paulson, and Markus Wenzel, |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
4 |
with contributions by Jeremy Avigad |
14738 | 5 |
*) |
6 |
||
7 |
header {* Ordered Groups *} |
|
8 |
||
15131 | 9 |
theory OrderedGroup |
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
10 |
imports Lattices |
19798 | 11 |
uses "~~/src/Provers/Arith/abel_cancel.ML" |
15131 | 12 |
begin |
14738 | 13 |
|
14 |
text {* |
|
15 |
The theory of partially ordered groups is taken from the books: |
|
16 |
\begin{itemize} |
|
17 |
\item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979 |
|
18 |
\item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963 |
|
19 |
\end{itemize} |
|
20 |
Most of the used notions can also be looked up in |
|
21 |
\begin{itemize} |
|
14770 | 22 |
\item \url{http://www.mathworld.com} by Eric Weisstein et. al. |
14738 | 23 |
\item \emph{Algebra I} by van der Waerden, Springer. |
24 |
\end{itemize} |
|
25 |
*} |
|
26 |
||
23085 | 27 |
subsection {* Semigroups and Monoids *} |
14738 | 28 |
|
22390 | 29 |
class semigroup_add = plus + |
25062 | 30 |
assumes add_assoc: "(a + b) + c = a + (b + c)" |
22390 | 31 |
|
32 |
class ab_semigroup_add = semigroup_add + |
|
25062 | 33 |
assumes add_commute: "a + b = b + a" |
34 |
begin |
|
14738 | 35 |
|
25062 | 36 |
lemma add_left_commute: "a + (b + c) = b + (a + c)" |
37 |
by (rule mk_left_commute [of "plus", OF add_assoc add_commute]) |
|
38 |
||
39 |
theorems add_ac = add_assoc add_commute add_left_commute |
|
40 |
||
41 |
end |
|
14738 | 42 |
|
43 |
theorems add_ac = add_assoc add_commute add_left_commute |
|
44 |
||
22390 | 45 |
class semigroup_mult = times + |
25062 | 46 |
assumes mult_assoc: "(a * b) * c = a * (b * c)" |
14738 | 47 |
|
22390 | 48 |
class ab_semigroup_mult = semigroup_mult + |
25062 | 49 |
assumes mult_commute: "a * b = b * a" |
23181 | 50 |
begin |
14738 | 51 |
|
25062 | 52 |
lemma mult_left_commute: "a * (b * c) = b * (a * c)" |
53 |
by (rule mk_left_commute [of "times", OF mult_assoc mult_commute]) |
|
54 |
||
55 |
theorems mult_ac = mult_assoc mult_commute mult_left_commute |
|
23181 | 56 |
|
57 |
end |
|
14738 | 58 |
|
59 |
theorems mult_ac = mult_assoc mult_commute mult_left_commute |
|
60 |
||
23085 | 61 |
class monoid_add = zero + semigroup_add + |
25062 | 62 |
assumes add_0_left [simp]: "0 + a = a" |
63 |
and add_0_right [simp]: "a + 0 = a" |
|
23085 | 64 |
|
22390 | 65 |
class comm_monoid_add = zero + ab_semigroup_add + |
25062 | 66 |
assumes add_0: "0 + a = a" |
67 |
begin |
|
23085 | 68 |
|
25062 | 69 |
subclass monoid_add |
70 |
by unfold_locales (insert add_0, simp_all add: add_commute) |
|
71 |
||
72 |
end |
|
14738 | 73 |
|
22390 | 74 |
class monoid_mult = one + semigroup_mult + |
25062 | 75 |
assumes mult_1_left [simp]: "1 * a = a" |
76 |
assumes mult_1_right [simp]: "a * 1 = a" |
|
14738 | 77 |
|
22390 | 78 |
class comm_monoid_mult = one + ab_semigroup_mult + |
25062 | 79 |
assumes mult_1: "1 * a = a" |
80 |
begin |
|
14738 | 81 |
|
25062 | 82 |
subclass monoid_mult |
83 |
by unfold_locales (insert mult_1, simp_all add: mult_commute) |
|
84 |
||
85 |
end |
|
14738 | 86 |
|
22390 | 87 |
class cancel_semigroup_add = semigroup_add + |
25062 | 88 |
assumes add_left_imp_eq: "a + b = a + c \<Longrightarrow> b = c" |
89 |
assumes add_right_imp_eq: "b + a = c + a \<Longrightarrow> b = c" |
|
14738 | 90 |
|
22390 | 91 |
class cancel_ab_semigroup_add = ab_semigroup_add + |
25062 | 92 |
assumes add_imp_eq: "a + b = a + c \<Longrightarrow> b = c" |
93 |
begin |
|
14738 | 94 |
|
25062 | 95 |
subclass cancel_semigroup_add |
96 |
proof unfold_locales |
|
22390 | 97 |
fix a b c :: 'a |
98 |
assume "a + b = a + c" |
|
99 |
then show "b = c" by (rule add_imp_eq) |
|
100 |
next |
|
14738 | 101 |
fix a b c :: 'a |
102 |
assume "b + a = c + a" |
|
22390 | 103 |
then have "a + b = a + c" by (simp only: add_commute) |
104 |
then show "b = c" by (rule add_imp_eq) |
|
14738 | 105 |
qed |
106 |
||
25062 | 107 |
end context cancel_ab_semigroup_add begin |
108 |
||
23085 | 109 |
lemma add_left_cancel [simp]: |
25062 | 110 |
"a + b = a + c \<longleftrightarrow> b = c" |
23085 | 111 |
by (blast dest: add_left_imp_eq) |
112 |
||
113 |
lemma add_right_cancel [simp]: |
|
25062 | 114 |
"b + a = c + a \<longleftrightarrow> b = c" |
23085 | 115 |
by (blast dest: add_right_imp_eq) |
116 |
||
25062 | 117 |
end |
118 |
||
23085 | 119 |
subsection {* Groups *} |
120 |
||
121 |
class group_add = minus + monoid_add + |
|
25062 | 122 |
assumes left_minus [simp]: "- a + a = 0" |
123 |
assumes diff_minus: "a - b = a + (- b)" |
|
124 |
begin |
|
23085 | 125 |
|
25062 | 126 |
lemma minus_add_cancel: "- a + (a + b) = b" |
127 |
by (simp add: add_assoc[symmetric]) |
|
14738 | 128 |
|
25062 | 129 |
lemma minus_zero [simp]: "- 0 = 0" |
14738 | 130 |
proof - |
25062 | 131 |
have "- 0 = - 0 + (0 + 0)" by (simp only: add_0_right) |
132 |
also have "\<dots> = 0" by (rule minus_add_cancel) |
|
14738 | 133 |
finally show ?thesis . |
134 |
qed |
|
135 |
||
25062 | 136 |
lemma minus_minus [simp]: "- (- a) = a" |
23085 | 137 |
proof - |
25062 | 138 |
have "- (- a) = - (- a) + (- a + a)" by simp |
139 |
also have "\<dots> = a" by (rule minus_add_cancel) |
|
23085 | 140 |
finally show ?thesis . |
141 |
qed |
|
14738 | 142 |
|
25062 | 143 |
lemma right_minus [simp]: "a + - a = 0" |
14738 | 144 |
proof - |
25062 | 145 |
have "a + - a = - (- a) + - a" by simp |
146 |
also have "\<dots> = 0" by (rule left_minus) |
|
14738 | 147 |
finally show ?thesis . |
148 |
qed |
|
149 |
||
25062 | 150 |
lemma right_minus_eq: "a - b = 0 \<longleftrightarrow> a = b" |
14738 | 151 |
proof |
23085 | 152 |
assume "a - b = 0" |
153 |
have "a = (a - b) + b" by (simp add:diff_minus add_assoc) |
|
154 |
also have "\<dots> = b" using `a - b = 0` by simp |
|
155 |
finally show "a = b" . |
|
14738 | 156 |
next |
23085 | 157 |
assume "a = b" thus "a - b = 0" by (simp add: diff_minus) |
14738 | 158 |
qed |
159 |
||
25062 | 160 |
lemma equals_zero_I: |
161 |
assumes "a + b = 0" |
|
162 |
shows "- a = b" |
|
23085 | 163 |
proof - |
25062 | 164 |
have "- a = - a + (a + b)" using assms by simp |
165 |
also have "\<dots> = b" by (simp add: add_assoc[symmetric]) |
|
23085 | 166 |
finally show ?thesis . |
167 |
qed |
|
14738 | 168 |
|
25062 | 169 |
lemma diff_self [simp]: "a - a = 0" |
170 |
by (simp add: diff_minus) |
|
14738 | 171 |
|
25062 | 172 |
lemma diff_0 [simp]: "0 - a = - a" |
173 |
by (simp add: diff_minus) |
|
14738 | 174 |
|
25062 | 175 |
lemma diff_0_right [simp]: "a - 0 = a" |
176 |
by (simp add: diff_minus) |
|
14738 | 177 |
|
25062 | 178 |
lemma diff_minus_eq_add [simp]: "a - - b = a + b" |
179 |
by (simp add: diff_minus) |
|
14738 | 180 |
|
25062 | 181 |
lemma neg_equal_iff_equal [simp]: |
182 |
"- a = - b \<longleftrightarrow> a = b" |
|
14738 | 183 |
proof |
184 |
assume "- a = - b" |
|
185 |
hence "- (- a) = - (- b)" |
|
186 |
by simp |
|
25062 | 187 |
thus "a = b" by simp |
14738 | 188 |
next |
25062 | 189 |
assume "a = b" |
190 |
thus "- a = - b" by simp |
|
14738 | 191 |
qed |
192 |
||
25062 | 193 |
lemma neg_equal_0_iff_equal [simp]: |
194 |
"- a = 0 \<longleftrightarrow> a = 0" |
|
195 |
by (subst neg_equal_iff_equal [symmetric], simp) |
|
14738 | 196 |
|
25062 | 197 |
lemma neg_0_equal_iff_equal [simp]: |
198 |
"0 = - a \<longleftrightarrow> 0 = a" |
|
199 |
by (subst neg_equal_iff_equal [symmetric], simp) |
|
14738 | 200 |
|
201 |
text{*The next two equations can make the simplifier loop!*} |
|
202 |
||
25062 | 203 |
lemma equation_minus_iff: |
204 |
"a = - b \<longleftrightarrow> b = - a" |
|
14738 | 205 |
proof - |
25062 | 206 |
have "- (- a) = - b \<longleftrightarrow> - a = b" by (rule neg_equal_iff_equal) |
207 |
thus ?thesis by (simp add: eq_commute) |
|
208 |
qed |
|
209 |
||
210 |
lemma minus_equation_iff: |
|
211 |
"- a = b \<longleftrightarrow> - b = a" |
|
212 |
proof - |
|
213 |
have "- a = - (- b) \<longleftrightarrow> a = -b" by (rule neg_equal_iff_equal) |
|
14738 | 214 |
thus ?thesis by (simp add: eq_commute) |
215 |
qed |
|
216 |
||
25062 | 217 |
end |
218 |
||
219 |
class ab_group_add = minus + comm_monoid_add + |
|
220 |
assumes ab_left_minus: "- a + a = 0" |
|
221 |
assumes ab_diff_minus: "a - b = a + (- b)" |
|
222 |
||
223 |
subclass (in ab_group_add) group_add |
|
224 |
by unfold_locales (simp_all add: ab_left_minus ab_diff_minus) |
|
225 |
||
226 |
subclass (in ab_group_add) cancel_semigroup_add |
|
227 |
proof unfold_locales |
|
228 |
fix a b c :: 'a |
|
229 |
assume "a + b = a + c" |
|
230 |
then have "- a + a + b = - a + a + c" |
|
231 |
unfolding add_assoc by simp |
|
232 |
then show "b = c" by simp |
|
233 |
next |
|
234 |
fix a b c :: 'a |
|
235 |
assume "b + a = c + a" |
|
236 |
then have "b + (a + - a) = c + (a + - a)" |
|
237 |
unfolding add_assoc [symmetric] by simp |
|
238 |
then show "b = c" by simp |
|
14738 | 239 |
qed |
240 |
||
25062 | 241 |
subclass (in ab_group_add) cancel_ab_semigroup_add |
242 |
proof unfold_locales |
|
243 |
fix a b c :: 'a |
|
244 |
assume "a + b = a + c" |
|
245 |
then have "- a + a + b = - a + a + c" |
|
246 |
unfolding add_assoc by simp |
|
247 |
then show "b = c" by simp |
|
248 |
qed |
|
249 |
||
250 |
context ab_group_add |
|
251 |
begin |
|
14738 | 252 |
|
25062 | 253 |
lemma uminus_add_conv_diff: |
254 |
"- a + b = b - a" |
|
255 |
by (simp add:diff_minus add_commute) |
|
256 |
||
257 |
lemma minus_add_distrib [simp]: |
|
258 |
"- (a + b) = - a + - b" |
|
259 |
by (rule equals_zero_I) (simp add: add_ac) |
|
260 |
||
261 |
lemma minus_diff_eq [simp]: |
|
262 |
"- (a - b) = b - a" |
|
263 |
by (simp add: diff_minus add_commute) |
|
264 |
||
25077 | 265 |
lemma add_diff_eq: "a + (b - c) = (a + b) - c" |
266 |
by (simp add: diff_minus add_ac) |
|
267 |
||
268 |
lemma diff_add_eq: "(a - b) + c = (a + c) - b" |
|
269 |
by (simp add: diff_minus add_ac) |
|
270 |
||
271 |
lemma diff_eq_eq: "a - b = c \<longleftrightarrow> a = c + b" |
|
272 |
by (auto simp add: diff_minus add_assoc) |
|
273 |
||
274 |
lemma eq_diff_eq: "a = c - b \<longleftrightarrow> a + b = c" |
|
275 |
by (auto simp add: diff_minus add_assoc) |
|
276 |
||
277 |
lemma diff_diff_eq: "(a - b) - c = a - (b + c)" |
|
278 |
by (simp add: diff_minus add_ac) |
|
279 |
||
280 |
lemma diff_diff_eq2: "a - (b - c) = (a + c) - b" |
|
281 |
by (simp add: diff_minus add_ac) |
|
282 |
||
283 |
lemma diff_add_cancel: "a - b + b = a" |
|
284 |
by (simp add: diff_minus add_ac) |
|
285 |
||
286 |
lemma add_diff_cancel: "a + b - b = a" |
|
287 |
by (simp add: diff_minus add_ac) |
|
288 |
||
289 |
lemmas compare_rls = |
|
290 |
diff_minus [symmetric] |
|
291 |
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 |
|
292 |
diff_eq_eq eq_diff_eq |
|
293 |
||
294 |
lemma eq_iff_diff_eq_0: "a = b \<longleftrightarrow> a - b = 0" |
|
295 |
by (simp add: compare_rls) |
|
296 |
||
25062 | 297 |
end |
14738 | 298 |
|
299 |
subsection {* (Partially) Ordered Groups *} |
|
300 |
||
22390 | 301 |
class pordered_ab_semigroup_add = order + ab_semigroup_add + |
25062 | 302 |
assumes add_left_mono: "a \<le> b \<Longrightarrow> c + a \<le> c + b" |
303 |
begin |
|
24380
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24286
diff
changeset
|
304 |
|
25062 | 305 |
lemma add_right_mono: |
306 |
"a \<le> b \<Longrightarrow> a + c \<le> b + c" |
|
22390 | 307 |
by (simp add: add_commute [of _ c] add_left_mono) |
14738 | 308 |
|
309 |
text {* non-strict, in both arguments *} |
|
310 |
lemma add_mono: |
|
25062 | 311 |
"a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c \<le> b + d" |
14738 | 312 |
apply (erule add_right_mono [THEN order_trans]) |
313 |
apply (simp add: add_commute add_left_mono) |
|
314 |
done |
|
315 |
||
25062 | 316 |
end |
317 |
||
318 |
class pordered_cancel_ab_semigroup_add = |
|
319 |
pordered_ab_semigroup_add + cancel_ab_semigroup_add |
|
320 |
begin |
|
321 |
||
14738 | 322 |
lemma add_strict_left_mono: |
25062 | 323 |
"a < b \<Longrightarrow> c + a < c + b" |
324 |
by (auto simp add: less_le add_left_mono) |
|
14738 | 325 |
|
326 |
lemma add_strict_right_mono: |
|
25062 | 327 |
"a < b \<Longrightarrow> a + c < b + c" |
328 |
by (simp add: add_commute [of _ c] add_strict_left_mono) |
|
14738 | 329 |
|
330 |
text{*Strict monotonicity in both arguments*} |
|
25062 | 331 |
lemma add_strict_mono: |
332 |
"a < b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d" |
|
333 |
apply (erule add_strict_right_mono [THEN less_trans]) |
|
14738 | 334 |
apply (erule add_strict_left_mono) |
335 |
done |
|
336 |
||
337 |
lemma add_less_le_mono: |
|
25062 | 338 |
"a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c < b + d" |
339 |
apply (erule add_strict_right_mono [THEN less_le_trans]) |
|
340 |
apply (erule add_left_mono) |
|
14738 | 341 |
done |
342 |
||
343 |
lemma add_le_less_mono: |
|
25062 | 344 |
"a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d" |
345 |
apply (erule add_right_mono [THEN le_less_trans]) |
|
14738 | 346 |
apply (erule add_strict_left_mono) |
347 |
done |
|
348 |
||
25062 | 349 |
end |
350 |
||
351 |
class pordered_ab_semigroup_add_imp_le = |
|
352 |
pordered_cancel_ab_semigroup_add + |
|
353 |
assumes add_le_imp_le_left: "c + a \<le> c + b \<Longrightarrow> a \<le> b" |
|
354 |
begin |
|
355 |
||
14738 | 356 |
lemma add_less_imp_less_left: |
25062 | 357 |
assumes less: "c + a < c + b" |
358 |
shows "a < b" |
|
14738 | 359 |
proof - |
360 |
from less have le: "c + a <= c + b" by (simp add: order_le_less) |
|
361 |
have "a <= b" |
|
362 |
apply (insert le) |
|
363 |
apply (drule add_le_imp_le_left) |
|
364 |
by (insert le, drule add_le_imp_le_left, assumption) |
|
365 |
moreover have "a \<noteq> b" |
|
366 |
proof (rule ccontr) |
|
367 |
assume "~(a \<noteq> b)" |
|
368 |
then have "a = b" by simp |
|
369 |
then have "c + a = c + b" by simp |
|
370 |
with less show "False"by simp |
|
371 |
qed |
|
372 |
ultimately show "a < b" by (simp add: order_le_less) |
|
373 |
qed |
|
374 |
||
375 |
lemma add_less_imp_less_right: |
|
25062 | 376 |
"a + c < b + c \<Longrightarrow> a < b" |
14738 | 377 |
apply (rule add_less_imp_less_left [of c]) |
378 |
apply (simp add: add_commute) |
|
379 |
done |
|
380 |
||
381 |
lemma add_less_cancel_left [simp]: |
|
25062 | 382 |
"c + a < c + b \<longleftrightarrow> a < b" |
383 |
by (blast intro: add_less_imp_less_left add_strict_left_mono) |
|
14738 | 384 |
|
385 |
lemma add_less_cancel_right [simp]: |
|
25062 | 386 |
"a + c < b + c \<longleftrightarrow> a < b" |
387 |
by (blast intro: add_less_imp_less_right add_strict_right_mono) |
|
14738 | 388 |
|
389 |
lemma add_le_cancel_left [simp]: |
|
25062 | 390 |
"c + a \<le> c + b \<longleftrightarrow> a \<le> b" |
391 |
by (auto, drule add_le_imp_le_left, simp_all add: add_left_mono) |
|
14738 | 392 |
|
393 |
lemma add_le_cancel_right [simp]: |
|
25062 | 394 |
"a + c \<le> b + c \<longleftrightarrow> a \<le> b" |
395 |
by (simp add: add_commute [of a c] add_commute [of b c]) |
|
14738 | 396 |
|
397 |
lemma add_le_imp_le_right: |
|
25062 | 398 |
"a + c \<le> b + c \<Longrightarrow> a \<le> b" |
399 |
by simp |
|
400 |
||
25077 | 401 |
lemma max_add_distrib_left: |
402 |
"max x y + z = max (x + z) (y + z)" |
|
403 |
unfolding max_def by auto |
|
404 |
||
405 |
lemma min_add_distrib_left: |
|
406 |
"min x y + z = min (x + z) (y + z)" |
|
407 |
unfolding min_def by auto |
|
408 |
||
25062 | 409 |
end |
410 |
||
411 |
class pordered_ab_group_add = |
|
412 |
ab_group_add + pordered_ab_semigroup_add |
|
413 |
begin |
|
414 |
||
415 |
subclass pordered_cancel_ab_semigroup_add |
|
416 |
by unfold_locales |
|
417 |
||
418 |
subclass pordered_ab_semigroup_add_imp_le |
|
419 |
proof unfold_locales |
|
420 |
fix a b c :: 'a |
|
421 |
assume "c + a \<le> c + b" |
|
422 |
hence "(-c) + (c + a) \<le> (-c) + (c + b)" by (rule add_left_mono) |
|
423 |
hence "((-c) + c) + a \<le> ((-c) + c) + b" by (simp only: add_assoc) |
|
424 |
thus "a \<le> b" by simp |
|
425 |
qed |
|
426 |
||
427 |
end |
|
428 |
||
25077 | 429 |
context pordered_ab_group_add |
430 |
begin |
|
431 |
||
432 |
lemma max_diff_distrib_left: |
|
433 |
shows "max x y - z = max (x - z) (y - z)" |
|
434 |
by (simp add: diff_minus, rule max_add_distrib_left) |
|
435 |
||
436 |
lemma min_diff_distrib_left: |
|
437 |
shows "min x y - z = min (x - z) (y - z)" |
|
438 |
by (simp add: diff_minus, rule min_add_distrib_left) |
|
439 |
||
440 |
lemma le_imp_neg_le: |
|
441 |
assumes "a \<le> b" |
|
442 |
shows "-b \<le> -a" |
|
443 |
proof - |
|
444 |
have "-a+a \<le> -a+b" |
|
445 |
using `a \<le> b` by (rule add_left_mono) |
|
446 |
hence "0 \<le> -a+b" |
|
447 |
by simp |
|
448 |
hence "0 + (-b) \<le> (-a + b) + (-b)" |
|
449 |
by (rule add_right_mono) |
|
450 |
thus ?thesis |
|
451 |
by (simp add: add_assoc) |
|
452 |
qed |
|
453 |
||
454 |
lemma neg_le_iff_le [simp]: "- b \<le> - a \<longleftrightarrow> a \<le> b" |
|
455 |
proof |
|
456 |
assume "- b \<le> - a" |
|
457 |
hence "- (- a) \<le> - (- b)" |
|
458 |
by (rule le_imp_neg_le) |
|
459 |
thus "a\<le>b" by simp |
|
460 |
next |
|
461 |
assume "a\<le>b" |
|
462 |
thus "-b \<le> -a" by (rule le_imp_neg_le) |
|
463 |
qed |
|
464 |
||
465 |
lemma neg_le_0_iff_le [simp]: "- a \<le> 0 \<longleftrightarrow> 0 \<le> a" |
|
466 |
by (subst neg_le_iff_le [symmetric], simp) |
|
467 |
||
468 |
lemma neg_0_le_iff_le [simp]: "0 \<le> - a \<longleftrightarrow> a \<le> 0" |
|
469 |
by (subst neg_le_iff_le [symmetric], simp) |
|
470 |
||
471 |
lemma neg_less_iff_less [simp]: "- b < - a \<longleftrightarrow> a < b" |
|
472 |
by (force simp add: less_le) |
|
473 |
||
474 |
lemma neg_less_0_iff_less [simp]: "- a < 0 \<longleftrightarrow> 0 < a" |
|
475 |
by (subst neg_less_iff_less [symmetric], simp) |
|
476 |
||
477 |
lemma neg_0_less_iff_less [simp]: "0 < - a \<longleftrightarrow> a < 0" |
|
478 |
by (subst neg_less_iff_less [symmetric], simp) |
|
479 |
||
480 |
text{*The next several equations can make the simplifier loop!*} |
|
481 |
||
482 |
lemma less_minus_iff: "a < - b \<longleftrightarrow> b < - a" |
|
483 |
proof - |
|
484 |
have "(- (-a) < - b) = (b < - a)" by (rule neg_less_iff_less) |
|
485 |
thus ?thesis by simp |
|
486 |
qed |
|
487 |
||
488 |
lemma minus_less_iff: "- a < b \<longleftrightarrow> - b < a" |
|
489 |
proof - |
|
490 |
have "(- a < - (-b)) = (- b < a)" by (rule neg_less_iff_less) |
|
491 |
thus ?thesis by simp |
|
492 |
qed |
|
493 |
||
494 |
lemma le_minus_iff: "a \<le> - b \<longleftrightarrow> b \<le> - a" |
|
495 |
proof - |
|
496 |
have mm: "!! a (b::'a). (-(-a)) < -b \<Longrightarrow> -(-b) < -a" by (simp only: minus_less_iff) |
|
497 |
have "(- (- a) <= -b) = (b <= - a)" |
|
498 |
apply (auto simp only: le_less) |
|
499 |
apply (drule mm) |
|
500 |
apply (simp_all) |
|
501 |
apply (drule mm[simplified], assumption) |
|
502 |
done |
|
503 |
then show ?thesis by simp |
|
504 |
qed |
|
505 |
||
506 |
lemma minus_le_iff: "- a \<le> b \<longleftrightarrow> - b \<le> a" |
|
507 |
by (auto simp add: le_less minus_less_iff) |
|
508 |
||
509 |
lemma less_iff_diff_less_0: "a < b \<longleftrightarrow> a - b < 0" |
|
510 |
proof - |
|
511 |
have "(a < b) = (a + (- b) < b + (-b))" |
|
512 |
by (simp only: add_less_cancel_right) |
|
513 |
also have "... = (a - b < 0)" by (simp add: diff_minus) |
|
514 |
finally show ?thesis . |
|
515 |
qed |
|
516 |
||
517 |
lemma diff_less_eq: "a - b < c \<longleftrightarrow> a < c + b" |
|
518 |
apply (subst less_iff_diff_less_0 [of a]) |
|
519 |
apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst]) |
|
520 |
apply (simp add: diff_minus add_ac) |
|
521 |
done |
|
522 |
||
523 |
lemma less_diff_eq: "a < c - b \<longleftrightarrow> a + b < c" |
|
524 |
apply (subst less_iff_diff_less_0 [of "plus a b"]) |
|
525 |
apply (subst less_iff_diff_less_0 [of a]) |
|
526 |
apply (simp add: diff_minus add_ac) |
|
527 |
done |
|
528 |
||
529 |
lemma diff_le_eq: "a - b \<le> c \<longleftrightarrow> a \<le> c + b" |
|
530 |
by (auto simp add: le_less diff_less_eq diff_add_cancel add_diff_cancel) |
|
531 |
||
532 |
lemma le_diff_eq: "a \<le> c - b \<longleftrightarrow> a + b \<le> c" |
|
533 |
by (auto simp add: le_less less_diff_eq diff_add_cancel add_diff_cancel) |
|
534 |
||
535 |
lemmas compare_rls = |
|
536 |
diff_minus [symmetric] |
|
537 |
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 |
|
538 |
diff_less_eq less_diff_eq diff_le_eq le_diff_eq |
|
539 |
diff_eq_eq eq_diff_eq |
|
540 |
||
541 |
text{*This list of rewrites simplifies (in)equalities by bringing subtractions |
|
542 |
to the top and then moving negative terms to the other side. |
|
543 |
Use with @{text add_ac}*} |
|
544 |
lemmas (in -) compare_rls = |
|
545 |
diff_minus [symmetric] |
|
546 |
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 |
|
547 |
diff_less_eq less_diff_eq diff_le_eq le_diff_eq |
|
548 |
diff_eq_eq eq_diff_eq |
|
549 |
||
550 |
lemma le_iff_diff_le_0: "a \<le> b \<longleftrightarrow> a - b \<le> 0" |
|
551 |
by (simp add: compare_rls) |
|
552 |
||
553 |
end |
|
554 |
||
25062 | 555 |
class ordered_ab_semigroup_add = |
556 |
linorder + pordered_ab_semigroup_add |
|
557 |
||
558 |
class ordered_cancel_ab_semigroup_add = |
|
559 |
linorder + pordered_cancel_ab_semigroup_add |
|
560 |
||
561 |
subclass (in ordered_cancel_ab_semigroup_add) ordered_ab_semigroup_add |
|
562 |
by unfold_locales |
|
563 |
||
564 |
subclass (in ordered_cancel_ab_semigroup_add) pordered_ab_semigroup_add_imp_le |
|
565 |
proof unfold_locales |
|
566 |
fix a b c :: 'a |
|
567 |
assume le: "c + a <= c + b" |
|
568 |
show "a <= b" |
|
569 |
proof (rule ccontr) |
|
570 |
assume w: "~ a \<le> b" |
|
571 |
hence "b <= a" by (simp add: linorder_not_le) |
|
572 |
hence le2: "c + b <= c + a" by (rule add_left_mono) |
|
573 |
have "a = b" |
|
574 |
apply (insert le) |
|
575 |
apply (insert le2) |
|
576 |
apply (drule antisym, simp_all) |
|
577 |
done |
|
578 |
with w show False |
|
579 |
by (simp add: linorder_not_le [symmetric]) |
|
580 |
qed |
|
581 |
qed |
|
582 |
||
25077 | 583 |
-- {* FIXME localize the following *} |
14738 | 584 |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
585 |
lemma add_increasing: |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
586 |
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
587 |
shows "[|0\<le>a; b\<le>c|] ==> b \<le> a + c" |
14738 | 588 |
by (insert add_mono [of 0 a b c], simp) |
589 |
||
15539 | 590 |
lemma add_increasing2: |
591 |
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" |
|
592 |
shows "[|0\<le>c; b\<le>a|] ==> b \<le> a + c" |
|
593 |
by (simp add:add_increasing add_commute[of a]) |
|
594 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
595 |
lemma add_strict_increasing: |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
596 |
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
597 |
shows "[|0<a; b\<le>c|] ==> b < a + c" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
598 |
by (insert add_less_le_mono [of 0 a b c], simp) |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
599 |
|
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
600 |
lemma add_strict_increasing2: |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
601 |
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
602 |
shows "[|0\<le>a; b<c|] ==> b < a + c" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
603 |
by (insert add_le_less_mono [of 0 a b c], simp) |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
604 |
|
14738 | 605 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
606 |
subsection {* Support for reasoning about signs *} |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
607 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
608 |
lemma add_pos_pos: "0 < |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
609 |
(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
610 |
==> 0 < y ==> 0 < x + y" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
611 |
apply (subgoal_tac "0 + 0 < x + y") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
612 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
613 |
apply (erule add_less_le_mono) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
614 |
apply (erule order_less_imp_le) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
615 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
616 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
617 |
lemma add_pos_nonneg: "0 < |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
618 |
(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
619 |
==> 0 <= y ==> 0 < x + y" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
620 |
apply (subgoal_tac "0 + 0 < x + y") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
621 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
622 |
apply (erule add_less_le_mono, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
623 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
624 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
625 |
lemma add_nonneg_pos: "0 <= |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
626 |
(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
627 |
==> 0 < y ==> 0 < x + y" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
628 |
apply (subgoal_tac "0 + 0 < x + y") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
629 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
630 |
apply (erule add_le_less_mono, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
631 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
632 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
633 |
lemma add_nonneg_nonneg: "0 <= |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
634 |
(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
635 |
==> 0 <= y ==> 0 <= x + y" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
636 |
apply (subgoal_tac "0 + 0 <= x + y") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
637 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
638 |
apply (erule add_mono, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
639 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
640 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
641 |
lemma add_neg_neg: "(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
642 |
< 0 ==> y < 0 ==> x + y < 0" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
643 |
apply (subgoal_tac "x + y < 0 + 0") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
644 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
645 |
apply (erule add_less_le_mono) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
646 |
apply (erule order_less_imp_le) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
647 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
648 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
649 |
lemma add_neg_nonpos: |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
650 |
"(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) < 0 |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
651 |
==> y <= 0 ==> x + y < 0" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
652 |
apply (subgoal_tac "x + y < 0 + 0") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
653 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
654 |
apply (erule add_less_le_mono, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
655 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
656 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
657 |
lemma add_nonpos_neg: |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
658 |
"(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) <= 0 |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
659 |
==> y < 0 ==> x + y < 0" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
660 |
apply (subgoal_tac "x + y < 0 + 0") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
661 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
662 |
apply (erule add_le_less_mono, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
663 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
664 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
665 |
lemma add_nonpos_nonpos: |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
666 |
"(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) <= 0 |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
667 |
==> y <= 0 ==> x + y <= 0" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
668 |
apply (subgoal_tac "x + y <= 0 + 0") |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
669 |
apply simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
670 |
apply (erule add_mono, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
671 |
done |
14738 | 672 |
|
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
673 |
|
14738 | 674 |
subsection {* Lattice Ordered (Abelian) Groups *} |
675 |
||
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
676 |
class lordered_ab_group_meet = pordered_ab_group_add + lower_semilattice |
25090 | 677 |
begin |
14738 | 678 |
|
25090 | 679 |
lemma add_inf_distrib_left: |
680 |
"a + inf b c = inf (a + b) (a + c)" |
|
681 |
apply (rule antisym) |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
682 |
apply (simp_all add: le_infI) |
25090 | 683 |
apply (rule add_le_imp_le_left [of "uminus a"]) |
684 |
apply (simp only: add_assoc [symmetric], simp) |
|
21312 | 685 |
apply rule |
686 |
apply (rule add_le_imp_le_left[of "a"], simp only: add_assoc[symmetric], simp)+ |
|
14738 | 687 |
done |
688 |
||
25090 | 689 |
lemma add_inf_distrib_right: |
690 |
"inf a b + c = inf (a + c) (b + c)" |
|
691 |
proof - |
|
692 |
have "c + inf a b = inf (c+a) (c+b)" by (simp add: add_inf_distrib_left) |
|
693 |
thus ?thesis by (simp add: add_commute) |
|
694 |
qed |
|
695 |
||
696 |
end |
|
697 |
||
698 |
class lordered_ab_group_join = pordered_ab_group_add + upper_semilattice |
|
699 |
begin |
|
700 |
||
701 |
lemma add_sup_distrib_left: |
|
702 |
"a + sup b c = sup (a + b) (a + c)" |
|
703 |
apply (rule antisym) |
|
704 |
apply (rule add_le_imp_le_left [of "uminus a"]) |
|
14738 | 705 |
apply (simp only: add_assoc[symmetric], simp) |
21312 | 706 |
apply rule |
707 |
apply (rule add_le_imp_le_left [of "a"], simp only: add_assoc[symmetric], simp)+ |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
708 |
apply (rule le_supI) |
21312 | 709 |
apply (simp_all) |
14738 | 710 |
done |
711 |
||
25090 | 712 |
lemma add_sup_distrib_right: |
713 |
"sup a b + c = sup (a+c) (b+c)" |
|
14738 | 714 |
proof - |
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
715 |
have "c + sup a b = sup (c+a) (c+b)" by (simp add: add_sup_distrib_left) |
14738 | 716 |
thus ?thesis by (simp add: add_commute) |
717 |
qed |
|
718 |
||
25090 | 719 |
end |
720 |
||
721 |
class lordered_ab_group = pordered_ab_group_add + lattice |
|
722 |
begin |
|
723 |
||
724 |
subclass lordered_ab_group_meet by unfold_locales |
|
725 |
subclass lordered_ab_group_join by unfold_locales |
|
726 |
||
727 |
end |
|
728 |
||
729 |
context lordered_ab_group |
|
730 |
begin |
|
731 |
||
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
732 |
lemmas add_sup_inf_distribs = add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left |
14738 | 733 |
|
25090 | 734 |
lemma inf_eq_neg_sup: "inf a b = - sup (-a) (-b)" |
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
735 |
proof (rule inf_unique) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
736 |
fix a b :: 'a |
25090 | 737 |
show "- sup (-a) (-b) \<le> a" |
738 |
by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"]) |
|
739 |
(simp, simp add: add_sup_distrib_left) |
|
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
740 |
next |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
741 |
fix a b :: 'a |
25090 | 742 |
show "- sup (-a) (-b) \<le> b" |
743 |
by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"]) |
|
744 |
(simp, simp add: add_sup_distrib_left) |
|
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
745 |
next |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
746 |
fix a b c :: 'a |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
747 |
assume "a \<le> b" "a \<le> c" |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
748 |
then show "a \<le> - sup (-b) (-c)" by (subst neg_le_iff_le [symmetric]) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
749 |
(simp add: le_supI) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
750 |
qed |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
751 |
|
25090 | 752 |
lemma sup_eq_neg_inf: "sup a b = - inf (-a) (-b)" |
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
753 |
proof (rule sup_unique) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
754 |
fix a b :: 'a |
25090 | 755 |
show "a \<le> - inf (-a) (-b)" |
756 |
by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"]) |
|
757 |
(simp, simp add: add_inf_distrib_left) |
|
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
758 |
next |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
759 |
fix a b :: 'a |
25090 | 760 |
show "b \<le> - inf (-a) (-b)" |
761 |
by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"]) |
|
762 |
(simp, simp add: add_inf_distrib_left) |
|
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
763 |
next |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
764 |
fix a b c :: 'a |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
765 |
assume "a \<le> c" "b \<le> c" |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
766 |
then show "- inf (-a) (-b) \<le> c" by (subst neg_le_iff_le [symmetric]) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
767 |
(simp add: le_infI) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
768 |
qed |
14738 | 769 |
|
25090 | 770 |
lemma add_eq_inf_sup: "a + b = sup a b + inf a b" |
14738 | 771 |
proof - |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
772 |
have "0 = - inf 0 (a-b) + inf (a-b) 0" by (simp add: inf_commute) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
773 |
hence "0 = sup 0 (b-a) + inf (a-b) 0" by (simp add: inf_eq_neg_sup) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
774 |
hence "0 = (-a + sup a b) + (inf a b + (-b))" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
775 |
apply (simp add: add_sup_distrib_left add_inf_distrib_right) |
14738 | 776 |
by (simp add: diff_minus add_commute) |
777 |
thus ?thesis |
|
778 |
apply (simp add: compare_rls) |
|
25090 | 779 |
apply (subst add_left_cancel [symmetric, of "plus a b" "plus (sup a b) (inf a b)" "uminus a"]) |
14738 | 780 |
apply (simp only: add_assoc, simp add: add_assoc[symmetric]) |
781 |
done |
|
782 |
qed |
|
783 |
||
784 |
subsection {* Positive Part, Negative Part, Absolute Value *} |
|
785 |
||
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
786 |
definition |
25090 | 787 |
nprt :: "'a \<Rightarrow> 'a" where |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
788 |
"nprt x = inf x 0" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
789 |
|
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
790 |
definition |
25090 | 791 |
pprt :: "'a \<Rightarrow> 'a" where |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
792 |
"pprt x = sup x 0" |
14738 | 793 |
|
794 |
lemma prts: "a = pprt a + nprt a" |
|
25090 | 795 |
by (simp add: pprt_def nprt_def add_eq_inf_sup[symmetric]) |
14738 | 796 |
|
797 |
lemma zero_le_pprt[simp]: "0 \<le> pprt a" |
|
25090 | 798 |
by (simp add: pprt_def) |
14738 | 799 |
|
800 |
lemma nprt_le_zero[simp]: "nprt a \<le> 0" |
|
25090 | 801 |
by (simp add: nprt_def) |
14738 | 802 |
|
25090 | 803 |
lemma le_eq_neg: "a \<le> - b \<longleftrightarrow> a + b \<le> 0" (is "?l = ?r") |
14738 | 804 |
proof - |
805 |
have a: "?l \<longrightarrow> ?r" |
|
806 |
apply (auto) |
|
25090 | 807 |
apply (rule add_le_imp_le_right[of _ "uminus b" _]) |
14738 | 808 |
apply (simp add: add_assoc) |
809 |
done |
|
810 |
have b: "?r \<longrightarrow> ?l" |
|
811 |
apply (auto) |
|
812 |
apply (rule add_le_imp_le_right[of _ "b" _]) |
|
813 |
apply (simp) |
|
814 |
done |
|
815 |
from a b show ?thesis by blast |
|
816 |
qed |
|
817 |
||
15580 | 818 |
lemma pprt_0[simp]: "pprt 0 = 0" by (simp add: pprt_def) |
819 |
lemma nprt_0[simp]: "nprt 0 = 0" by (simp add: nprt_def) |
|
820 |
||
25090 | 821 |
lemma pprt_eq_id [simp, noatp]: "0 \<le> x \<Longrightarrow> pprt x = x" |
822 |
by (simp add: pprt_def le_iff_sup sup_ACI) |
|
15580 | 823 |
|
25090 | 824 |
lemma nprt_eq_id [simp, noatp]: "x \<le> 0 \<Longrightarrow> nprt x = x" |
825 |
by (simp add: nprt_def le_iff_inf inf_ACI) |
|
15580 | 826 |
|
25090 | 827 |
lemma pprt_eq_0 [simp, noatp]: "x \<le> 0 \<Longrightarrow> pprt x = 0" |
828 |
by (simp add: pprt_def le_iff_sup sup_ACI) |
|
15580 | 829 |
|
25090 | 830 |
lemma nprt_eq_0 [simp, noatp]: "0 \<le> x \<Longrightarrow> nprt x = 0" |
831 |
by (simp add: nprt_def le_iff_inf inf_ACI) |
|
15580 | 832 |
|
25090 | 833 |
lemma sup_0_imp_0: "sup a (- a) = 0 \<Longrightarrow> a = 0" |
14738 | 834 |
proof - |
835 |
{ |
|
836 |
fix a::'a |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
837 |
assume hyp: "sup a (-a) = 0" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
838 |
hence "sup a (-a) + a = a" by (simp) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
839 |
hence "sup (a+a) 0 = a" by (simp add: add_sup_distrib_right) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
840 |
hence "sup (a+a) 0 <= a" by (simp) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
841 |
hence "0 <= a" by (blast intro: order_trans inf_sup_ord) |
14738 | 842 |
} |
843 |
note p = this |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
844 |
assume hyp:"sup a (-a) = 0" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
845 |
hence hyp2:"sup (-a) (-(-a)) = 0" by (simp add: sup_commute) |
14738 | 846 |
from p[OF hyp] p[OF hyp2] show "a = 0" by simp |
847 |
qed |
|
848 |
||
25090 | 849 |
lemma inf_0_imp_0: "inf a (-a) = 0 \<Longrightarrow> a = 0" |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
850 |
apply (simp add: inf_eq_neg_sup) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
851 |
apply (simp add: sup_commute) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
852 |
apply (erule sup_0_imp_0) |
15481 | 853 |
done |
14738 | 854 |
|
25090 | 855 |
lemma inf_0_eq_0 [simp, noatp]: "inf a (- a) = 0 \<longleftrightarrow> a = 0" |
856 |
by (rule, erule inf_0_imp_0) simp |
|
14738 | 857 |
|
25090 | 858 |
lemma sup_0_eq_0 [simp, noatp]: "sup a (- a) = 0 \<longleftrightarrow> a = 0" |
859 |
by (rule, erule sup_0_imp_0) simp |
|
14738 | 860 |
|
25090 | 861 |
lemma zero_le_double_add_iff_zero_le_single_add [simp]: |
862 |
"0 \<le> a + a \<longleftrightarrow> 0 \<le> a" |
|
14738 | 863 |
proof |
864 |
assume "0 <= a + a" |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
865 |
hence a:"inf (a+a) 0 = 0" by (simp add: le_iff_inf inf_commute) |
25090 | 866 |
have "(inf a 0)+(inf a 0) = inf (inf (a+a) 0) a" (is "?l=_") |
867 |
by (simp add: add_sup_inf_distribs inf_ACI) |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
868 |
hence "?l = 0 + inf a 0" by (simp add: a, simp add: inf_commute) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
869 |
hence "inf a 0 = 0" by (simp only: add_right_cancel) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
870 |
then show "0 <= a" by (simp add: le_iff_inf inf_commute) |
14738 | 871 |
next |
872 |
assume a: "0 <= a" |
|
873 |
show "0 <= a + a" by (simp add: add_mono[OF a a, simplified]) |
|
874 |
qed |
|
875 |
||
25090 | 876 |
lemma double_zero: "a + a = 0 \<longleftrightarrow> a = 0" |
877 |
proof |
|
878 |
assume assm: "a + a = 0" |
|
879 |
then have "a + a + - a = - a" by simp |
|
880 |
then have "a + (a + - a) = - a" by (simp only: add_assoc) |
|
881 |
then have a: "- a = a" by simp (*FIXME tune proof*) |
|
882 |
show "a = 0" apply rule |
|
883 |
apply (unfold neg_le_iff_le [symmetric, of a]) |
|
884 |
unfolding a apply simp |
|
885 |
unfolding zero_le_double_add_iff_zero_le_single_add [symmetric, of a] |
|
886 |
unfolding assm unfolding le_less apply simp_all done |
|
887 |
next |
|
888 |
assume "a = 0" then show "a + a = 0" by simp |
|
889 |
qed |
|
890 |
||
891 |
lemma zero_less_double_add_iff_zero_less_single_add: |
|
892 |
"0 < a + a \<longleftrightarrow> 0 < a" |
|
893 |
proof (cases "a = 0") |
|
894 |
case True then show ?thesis by auto |
|
895 |
next |
|
896 |
case False then show ?thesis (*FIXME tune proof*) |
|
897 |
unfolding less_le apply simp apply rule |
|
898 |
apply clarify |
|
899 |
apply rule |
|
900 |
apply assumption |
|
901 |
apply (rule notI) |
|
902 |
unfolding double_zero [symmetric, of a] apply simp |
|
903 |
done |
|
904 |
qed |
|
905 |
||
906 |
lemma double_add_le_zero_iff_single_add_le_zero [simp]: |
|
907 |
"a + a \<le> 0 \<longleftrightarrow> a \<le> 0" |
|
14738 | 908 |
proof - |
25090 | 909 |
have "a + a \<le> 0 \<longleftrightarrow> 0 \<le> - (a + a)" by (subst le_minus_iff, simp) |
910 |
moreover have "\<dots> \<longleftrightarrow> a \<le> 0" by (simp add: zero_le_double_add_iff_zero_le_single_add) |
|
14738 | 911 |
ultimately show ?thesis by blast |
912 |
qed |
|
913 |
||
25090 | 914 |
lemma double_add_less_zero_iff_single_less_zero [simp]: |
915 |
"a + a < 0 \<longleftrightarrow> a < 0" |
|
916 |
proof - |
|
917 |
have "a + a < 0 \<longleftrightarrow> 0 < - (a + a)" by (subst less_minus_iff, simp) |
|
918 |
moreover have "\<dots> \<longleftrightarrow> a < 0" by (simp add: zero_less_double_add_iff_zero_less_single_add) |
|
919 |
ultimately show ?thesis by blast |
|
14738 | 920 |
qed |
921 |
||
25090 | 922 |
end |
923 |
||
924 |
lemmas add_sup_inf_distribs = add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left |
|
925 |
||
23879 | 926 |
class lordered_ab_group_abs = lordered_ab_group + abs + |
25090 | 927 |
assumes abs_lattice: "\<bar>x\<bar> = sup x (- x)" |
928 |
begin |
|
14738 | 929 |
|
25090 | 930 |
lemma abs_zero [simp]: "\<bar>0\<bar> = 0" |
931 |
by (simp add: abs_lattice) |
|
14738 | 932 |
|
25090 | 933 |
lemma abs_eq_0 [simp]: "\<bar>a\<bar> = 0 \<longleftrightarrow> a = 0" |
934 |
by (simp add: abs_lattice) |
|
14738 | 935 |
|
25090 | 936 |
lemma abs_0_eq [simp, noatp]: "0 = \<bar>a\<bar> \<longleftrightarrow> a = 0" |
14738 | 937 |
proof - |
938 |
have "(0 = abs a) = (abs a = 0)" by (simp only: eq_ac) |
|
939 |
thus ?thesis by simp |
|
940 |
qed |
|
941 |
||
25090 | 942 |
lemma neg_inf_eq_sup [simp]: "- inf a b = sup (-a) (-b)" |
943 |
by (simp add: inf_eq_neg_sup) |
|
14738 | 944 |
|
25090 | 945 |
lemma neg_sup_eq_inf [simp]: "- sup a b = inf (-a) (-b)" |
946 |
by (simp del: neg_inf_eq_sup add: sup_eq_neg_inf) |
|
14738 | 947 |
|
25090 | 948 |
lemma abs_ge_zero [simp]: "0 \<le> \<bar>a\<bar>" |
14738 | 949 |
proof - |
25090 | 950 |
have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>" by (auto simp add: abs_lattice) |
951 |
show ?thesis by (rule add_mono [OF a b, simplified]) |
|
14738 | 952 |
qed |
953 |
||
25090 | 954 |
lemma abs_le_zero_iff [simp]: "\<bar>a\<bar> \<le> 0 \<longleftrightarrow> a = 0" |
14738 | 955 |
proof |
25090 | 956 |
assume "\<bar>a\<bar> \<le> 0" |
957 |
then have "\<bar>a\<bar> = 0" by (rule antisym) simp |
|
14738 | 958 |
thus "a = 0" by simp |
959 |
next |
|
960 |
assume "a = 0" |
|
25090 | 961 |
thus "\<bar>a\<bar> \<le> 0" by simp |
14738 | 962 |
qed |
963 |
||
25090 | 964 |
lemma zero_less_abs_iff [simp]: "0 < \<bar>a\<bar> \<longleftrightarrow> a \<noteq> 0" |
965 |
by (simp add: less_le) |
|
14738 | 966 |
|
25090 | 967 |
lemma abs_not_less_zero [simp]: "\<not> \<bar>a\<bar> < 0" |
14738 | 968 |
proof - |
25090 | 969 |
have a: "\<And>x y. x \<le> y \<Longrightarrow> \<not> y < x" by auto |
14738 | 970 |
show ?thesis by (simp add: a) |
971 |
qed |
|
972 |
||
25090 | 973 |
lemma abs_ge_self: "a \<le> \<bar>a\<bar>" |
974 |
by (auto simp add: abs_lattice) |
|
14738 | 975 |
|
25090 | 976 |
lemma abs_ge_minus_self: "- a \<le> \<bar>a\<bar>" |
977 |
by (auto simp add: abs_lattice) |
|
14738 | 978 |
|
25090 | 979 |
lemma abs_minus_cancel [simp]: "\<bar>-a\<bar> = \<bar>a\<bar>" |
980 |
by (simp add: abs_lattice sup_commute) |
|
14738 | 981 |
|
25090 | 982 |
lemma abs_idempotent [simp]: "\<bar>\<bar>a\<bar>\<bar> = \<bar>a\<bar>" |
983 |
apply (simp add: abs_lattice [of "abs a"]) |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
984 |
apply (subst sup_absorb1) |
25090 | 985 |
apply (rule order_trans [of _ zero]) |
14738 | 986 |
by auto |
987 |
||
15093
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset
|
988 |
lemma abs_minus_commute: |
25090 | 989 |
"\<bar>a - b\<bar> = \<bar>b - a\<bar>" |
15093
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset
|
990 |
proof - |
25090 | 991 |
have "\<bar>a - b\<bar> = \<bar>- (a - b)\<bar>" by (simp only: abs_minus_cancel) |
992 |
also have "... = \<bar>b - a\<bar>" by simp |
|
15093
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset
|
993 |
finally show ?thesis . |
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset
|
994 |
qed |
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset
|
995 |
|
25090 | 996 |
lemma abs_prts: "\<bar>a\<bar> = pprt a - nprt a" |
997 |
proof - |
|
998 |
have "0 \<le> \<bar>a\<bar>" by simp |
|
999 |
then have "0 \<le> sup a (- a)" unfolding abs_lattice . |
|
1000 |
then have "sup (sup a (- a)) 0 = sup a (- a)" by (rule sup_absorb1) |
|
1001 |
then show ?thesis |
|
1002 |
by (simp add: add_sup_inf_distribs sup_ACI |
|
1003 |
pprt_def nprt_def diff_minus abs_lattice) |
|
1004 |
qed |
|
1005 |
||
1006 |
lemma zero_le_iff_zero_nprt: "0 \<le> a \<longleftrightarrow> nprt a = 0" |
|
1007 |
by (simp add: le_iff_inf nprt_def inf_commute) |
|
1008 |
||
1009 |
lemma le_zero_iff_zero_pprt: "a \<le> 0 \<longleftrightarrow> pprt a = 0" |
|
1010 |
by (simp add: le_iff_sup pprt_def sup_commute) |
|
1011 |
||
1012 |
lemma le_zero_iff_pprt_id: "0 \<le> a \<longleftrightarrow> pprt a = a" |
|
1013 |
by (simp add: le_iff_sup pprt_def sup_commute) |
|
1014 |
||
1015 |
lemma zero_le_iff_nprt_id: "a \<le> 0 \<longleftrightarrow> nprt a = a" |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1016 |
by (simp add: le_iff_inf nprt_def inf_commute) |
14738 | 1017 |
|
25090 | 1018 |
lemma pprt_mono [simp, noatp]: "a \<le> b \<Longrightarrow> pprt a \<le> pprt b" |
1019 |
by (simp add: le_iff_sup pprt_def sup_ACI sup_assoc [symmetric, of a]) |
|
14738 | 1020 |
|
25090 | 1021 |
lemma nprt_mono [simp, noatp]: "a \<le> b \<Longrightarrow> nprt a \<le> nprt b" |
1022 |
by (simp add: le_iff_inf nprt_def inf_ACI inf_assoc [symmetric, of a]) |
|
14738 | 1023 |
|
25090 | 1024 |
lemma pprt_neg: "pprt (- x) = - nprt x" |
19404 | 1025 |
by (simp add: pprt_def nprt_def) |
1026 |
||
25090 | 1027 |
lemma nprt_neg: "nprt (- x) = - pprt x" |
19404 | 1028 |
by (simp add: pprt_def nprt_def) |
1029 |
||
25090 | 1030 |
lemma abs_of_nonneg [simp]: "0 \<le> a \<Longrightarrow> \<bar>a\<bar> = a" |
1031 |
by (simp add: iffD1 [OF zero_le_iff_zero_nprt] |
|
1032 |
iffD1[OF le_zero_iff_pprt_id] abs_prts) |
|
14738 | 1033 |
|
25090 | 1034 |
lemma abs_of_pos: "0 < x \<Longrightarrow> \<bar>x\<bar> = x" |
1035 |
by (rule abs_of_nonneg, rule less_imp_le) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1036 |
|
25090 | 1037 |
lemma abs_of_nonpos [simp]: "a \<le> 0 \<Longrightarrow> \<bar>a\<bar> = - a" |
1038 |
by (simp add: iffD1 [OF le_zero_iff_zero_pprt] |
|
1039 |
iffD1 [OF zero_le_iff_nprt_id] abs_prts) |
|
14738 | 1040 |
|
25090 | 1041 |
lemma abs_of_neg: "x < 0 \<Longrightarrow> \<bar>x\<bar> = - x" |
1042 |
by (rule abs_of_nonpos, rule less_imp_le) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1043 |
|
25090 | 1044 |
lemma abs_leI: "a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" |
1045 |
by (simp add: abs_lattice le_supI) |
|
14738 | 1046 |
|
25090 | 1047 |
lemma le_minus_self_iff: "a \<le> - a \<longleftrightarrow> a \<le> 0" |
14738 | 1048 |
proof - |
25090 | 1049 |
from add_le_cancel_left [of "uminus a" "plus a a" zero] |
1050 |
have "(a <= -a) = (a+a <= 0)" |
|
14738 | 1051 |
by (simp add: add_assoc[symmetric]) |
1052 |
thus ?thesis by simp |
|
1053 |
qed |
|
1054 |
||
25090 | 1055 |
lemma minus_le_self_iff: "- a \<le> a \<longleftrightarrow> 0 \<le> a" |
14738 | 1056 |
proof - |
25090 | 1057 |
from add_le_cancel_left [of "uminus a" zero "plus a a"] |
1058 |
have "(-a <= a) = (0 <= a+a)" |
|
14738 | 1059 |
by (simp add: add_assoc[symmetric]) |
1060 |
thus ?thesis by simp |
|
1061 |
qed |
|
1062 |
||
25090 | 1063 |
lemma abs_le_D1: "\<bar>a\<bar> \<le> b \<Longrightarrow> a \<le> b" |
1064 |
by (insert abs_ge_self, blast intro: order_trans) |
|
14738 | 1065 |
|
25090 | 1066 |
lemma abs_le_D2: "\<bar>a\<bar> \<le> b \<Longrightarrow> - a \<le> b" |
1067 |
by (insert abs_le_D1 [of "uminus a"], simp) |
|
14738 | 1068 |
|
25090 | 1069 |
lemma abs_le_iff: "\<bar>a\<bar> \<le> b \<longleftrightarrow> a \<le> b \<and> - a \<le> b" |
1070 |
by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2) |
|
14738 | 1071 |
|
25090 | 1072 |
lemma abs_triangle_ineq: "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" |
14738 | 1073 |
proof - |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1074 |
have g:"abs a + abs b = sup (a+b) (sup (-a-b) (sup (-a+b) (a + (-b))))" (is "_=sup ?m ?n") |
25090 | 1075 |
by (simp add: abs_lattice add_sup_inf_distribs sup_ACI diff_minus) |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1076 |
have a:"a+b <= sup ?m ?n" by (simp) |
21312 | 1077 |
have b:"-a-b <= ?n" by (simp) |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1078 |
have c:"?n <= sup ?m ?n" by (simp) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1079 |
from b c have d: "-a-b <= sup ?m ?n" by(rule order_trans) |
14738 | 1080 |
have e:"-a-b = -(a+b)" by (simp add: diff_minus) |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1081 |
from a d e have "abs(a+b) <= sup ?m ?n" |
14738 | 1082 |
by (drule_tac abs_leI, auto) |
1083 |
with g[symmetric] show ?thesis by simp |
|
1084 |
qed |
|
1085 |
||
25090 | 1086 |
lemma abs_triangle_ineq2: "\<bar>a\<bar> - \<bar>b\<bar> \<le> \<bar>a - b\<bar>" |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1087 |
apply (simp add: compare_rls) |
25090 | 1088 |
apply (subgoal_tac "abs a = abs (plus (minus a b) b)") |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1089 |
apply (erule ssubst) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1090 |
apply (rule abs_triangle_ineq) |
25090 | 1091 |
apply (rule arg_cong) back |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1092 |
apply (simp add: compare_rls) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1093 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1094 |
|
25090 | 1095 |
lemma abs_triangle_ineq3: "\<bar>\<bar>a\<bar> - \<bar>b\<bar>\<bar> \<le> \<bar>a - b\<bar>" |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1096 |
apply (subst abs_le_iff) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1097 |
apply auto |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1098 |
apply (rule abs_triangle_ineq2) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1099 |
apply (subst abs_minus_commute) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1100 |
apply (rule abs_triangle_ineq2) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1101 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1102 |
|
25090 | 1103 |
lemma abs_triangle_ineq4: "\<bar>a - b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" |
1104 |
proof - |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1105 |
have "abs(a - b) = abs(a + - b)" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1106 |
by (subst diff_minus, rule refl) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1107 |
also have "... <= abs a + abs (- b)" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1108 |
by (rule abs_triangle_ineq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1109 |
finally show ?thesis |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1110 |
by simp |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1111 |
qed |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1112 |
|
25090 | 1113 |
lemma abs_diff_triangle_ineq: "\<bar>a + b - (c + d)\<bar> \<le> \<bar>a - c\<bar> + \<bar>b - d\<bar>" |
14738 | 1114 |
proof - |
1115 |
have "\<bar>a + b - (c+d)\<bar> = \<bar>(a-c) + (b-d)\<bar>" by (simp add: diff_minus add_ac) |
|
1116 |
also have "... \<le> \<bar>a-c\<bar> + \<bar>b-d\<bar>" by (rule abs_triangle_ineq) |
|
1117 |
finally show ?thesis . |
|
1118 |
qed |
|
1119 |
||
15539 | 1120 |
lemma abs_add_abs[simp]: |
25090 | 1121 |
"\<bar>\<bar>a\<bar> + \<bar>b\<bar>\<bar> = \<bar>a\<bar> + \<bar>b\<bar>" (is "?L = ?R") |
1122 |
proof (rule antisym) |
|
15539 | 1123 |
show "?L \<ge> ?R" by(rule abs_ge_self) |
1124 |
next |
|
1125 |
have "?L \<le> \<bar>\<bar>a\<bar>\<bar> + \<bar>\<bar>b\<bar>\<bar>" by(rule abs_triangle_ineq) |
|
1126 |
also have "\<dots> = ?R" by simp |
|
1127 |
finally show "?L \<le> ?R" . |
|
1128 |
qed |
|
1129 |
||
25090 | 1130 |
end |
1131 |
||
1132 |
lemma sup_eq_if: |
|
1133 |
fixes a :: "'a\<Colon>{lordered_ab_group, linorder}" |
|
1134 |
shows "sup a (- a) = (if a < 0 then - a else a)" |
|
1135 |
proof - |
|
1136 |
note add_le_cancel_right [of a a "- a", symmetric, simplified] |
|
1137 |
moreover note add_le_cancel_right [of "-a" a a, symmetric, simplified] |
|
1138 |
then show ?thesis by (auto simp: sup_max max_def) |
|
1139 |
qed |
|
1140 |
||
1141 |
lemma abs_if_lattice: |
|
1142 |
fixes a :: "'a\<Colon>{lordered_ab_group_abs, linorder}" |
|
1143 |
shows "\<bar>a\<bar> = (if a < 0 then - a else a)" |
|
1144 |
by auto |
|
1145 |
||
1146 |
||
14754
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1147 |
text {* Needed for abelian cancellation simprocs: *} |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1148 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1149 |
lemma add_cancel_21: "((x::'a::ab_group_add) + (y + z) = y + u) = (x + z = u)" |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1150 |
apply (subst add_left_commute) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1151 |
apply (subst add_left_cancel) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1152 |
apply simp |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1153 |
done |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1154 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1155 |
lemma add_cancel_end: "(x + (y + z) = y) = (x = - (z::'a::ab_group_add))" |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1156 |
apply (subst add_cancel_21[of _ _ _ 0, simplified]) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1157 |
apply (simp add: add_right_cancel[symmetric, of "x" "-z" "z", simplified]) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1158 |
done |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1159 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1160 |
lemma less_eqI: "(x::'a::pordered_ab_group_add) - y = x' - y' \<Longrightarrow> (x < y) = (x' < y')" |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1161 |
by (simp add: less_iff_diff_less_0[of x y] less_iff_diff_less_0[of x' y']) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1162 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1163 |
lemma le_eqI: "(x::'a::pordered_ab_group_add) - y = x' - y' \<Longrightarrow> (y <= x) = (y' <= x')" |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1164 |
apply (simp add: le_iff_diff_le_0[of y x] le_iff_diff_le_0[of y' x']) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1165 |
apply (simp add: neg_le_iff_le[symmetric, of "y-x" 0] neg_le_iff_le[symmetric, of "y'-x'" 0]) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1166 |
done |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1167 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1168 |
lemma eq_eqI: "(x::'a::ab_group_add) - y = x' - y' \<Longrightarrow> (x = y) = (x' = y')" |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1169 |
by (simp add: eq_iff_diff_eq_0[of x y] eq_iff_diff_eq_0[of x' y']) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1170 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1171 |
lemma diff_def: "(x::'a::ab_group_add) - y == x + (-y)" |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1172 |
by (simp add: diff_minus) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1173 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1174 |
lemma add_minus_cancel: "(a::'a::ab_group_add) + (-a + b) = b" |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1175 |
by (simp add: add_assoc[symmetric]) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1176 |
|
25090 | 1177 |
lemma le_add_right_mono: |
15178 | 1178 |
assumes |
1179 |
"a <= b + (c::'a::pordered_ab_group_add)" |
|
1180 |
"c <= d" |
|
1181 |
shows "a <= b + d" |
|
1182 |
apply (rule_tac order_trans[where y = "b+c"]) |
|
1183 |
apply (simp_all add: prems) |
|
1184 |
done |
|
1185 |
||
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23389
diff
changeset
|
1186 |
lemmas group_simps = |
15178 | 1187 |
mult_ac |
1188 |
add_ac |
|
1189 |
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 |
|
25090 | 1190 |
diff_eq_eq eq_diff_eq diff_minus [symmetric] uminus_add_conv_diff |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23389
diff
changeset
|
1191 |
diff_less_eq less_diff_eq diff_le_eq le_diff_eq |
15178 | 1192 |
|
1193 |
lemma estimate_by_abs: |
|
24380
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24286
diff
changeset
|
1194 |
"a + b <= (c::'a::lordered_ab_group_abs) \<Longrightarrow> a <= c + abs b" |
15178 | 1195 |
proof - |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23389
diff
changeset
|
1196 |
assume "a+b <= c" |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23389
diff
changeset
|
1197 |
hence 2: "a <= c+(-b)" by (simp add: group_simps) |
15178 | 1198 |
have 3: "(-b) <= abs b" by (rule abs_ge_minus_self) |
1199 |
show ?thesis by (rule le_add_right_mono[OF 2 3]) |
|
1200 |
qed |
|
1201 |
||
25090 | 1202 |
subsection {* Tools setup *} |
1203 |
||
25077 | 1204 |
lemma add_mono_thms_ordered_semiring [noatp]: |
1205 |
fixes i j k :: "'a\<Colon>pordered_ab_semigroup_add" |
|
1206 |
shows "i \<le> j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l" |
|
1207 |
and "i = j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l" |
|
1208 |
and "i \<le> j \<and> k = l \<Longrightarrow> i + k \<le> j + l" |
|
1209 |
and "i = j \<and> k = l \<Longrightarrow> i + k = j + l" |
|
1210 |
by (rule add_mono, clarify+)+ |
|
1211 |
||
1212 |
lemma add_mono_thms_ordered_field [noatp]: |
|
1213 |
fixes i j k :: "'a\<Colon>pordered_cancel_ab_semigroup_add" |
|
1214 |
shows "i < j \<and> k = l \<Longrightarrow> i + k < j + l" |
|
1215 |
and "i = j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
1216 |
and "i < j \<and> k \<le> l \<Longrightarrow> i + k < j + l" |
|
1217 |
and "i \<le> j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
1218 |
and "i < j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
1219 |
by (auto intro: add_strict_right_mono add_strict_left_mono |
|
1220 |
add_less_le_mono add_le_less_mono add_strict_mono) |
|
1221 |
||
17085 | 1222 |
text{*Simplification of @{term "x-y < 0"}, etc.*} |
24380
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24286
diff
changeset
|
1223 |
lemmas diff_less_0_iff_less [simp] = less_iff_diff_less_0 [symmetric] |
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24286
diff
changeset
|
1224 |
lemmas diff_eq_0_iff_eq [simp, noatp] = eq_iff_diff_eq_0 [symmetric] |
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24286
diff
changeset
|
1225 |
lemmas diff_le_0_iff_le [simp] = le_iff_diff_le_0 [symmetric] |
17085 | 1226 |
|
22482 | 1227 |
ML {* |
1228 |
structure ab_group_add_cancel = Abel_Cancel( |
|
1229 |
struct |
|
1230 |
||
1231 |
(* term order for abelian groups *) |
|
1232 |
||
1233 |
fun agrp_ord (Const (a, _)) = find_index (fn a' => a = a') |
|
22997 | 1234 |
[@{const_name HOL.zero}, @{const_name HOL.plus}, |
1235 |
@{const_name HOL.uminus}, @{const_name HOL.minus}] |
|
22482 | 1236 |
| agrp_ord _ = ~1; |
1237 |
||
1238 |
fun termless_agrp (a, b) = (Term.term_lpo agrp_ord (a, b) = LESS); |
|
1239 |
||
1240 |
local |
|
1241 |
val ac1 = mk_meta_eq @{thm add_assoc}; |
|
1242 |
val ac2 = mk_meta_eq @{thm add_commute}; |
|
1243 |
val ac3 = mk_meta_eq @{thm add_left_commute}; |
|
22997 | 1244 |
fun solve_add_ac thy _ (_ $ (Const (@{const_name HOL.plus},_) $ _ $ _) $ _) = |
22482 | 1245 |
SOME ac1 |
22997 | 1246 |
| solve_add_ac thy _ (_ $ x $ (Const (@{const_name HOL.plus},_) $ y $ z)) = |
22482 | 1247 |
if termless_agrp (y, x) then SOME ac3 else NONE |
1248 |
| solve_add_ac thy _ (_ $ x $ y) = |
|
1249 |
if termless_agrp (y, x) then SOME ac2 else NONE |
|
1250 |
| solve_add_ac thy _ _ = NONE |
|
1251 |
in |
|
1252 |
val add_ac_proc = Simplifier.simproc @{theory} |
|
1253 |
"add_ac_proc" ["x + y::'a::ab_semigroup_add"] solve_add_ac; |
|
1254 |
end; |
|
1255 |
||
1256 |
val cancel_ss = HOL_basic_ss settermless termless_agrp |
|
1257 |
addsimprocs [add_ac_proc] addsimps |
|
23085 | 1258 |
[@{thm add_0_left}, @{thm add_0_right}, @{thm diff_def}, |
22482 | 1259 |
@{thm minus_add_distrib}, @{thm minus_minus}, @{thm minus_zero}, |
1260 |
@{thm right_minus}, @{thm left_minus}, @{thm add_minus_cancel}, |
|
1261 |
@{thm minus_add_cancel}]; |
|
1262 |
||
22548 | 1263 |
val eq_reflection = @{thm eq_reflection}; |
22482 | 1264 |
|
24137
8d7896398147
replaced Theory.self_ref by Theory.check_thy, which now produces a checked ref;
wenzelm
parents:
23879
diff
changeset
|
1265 |
val thy_ref = Theory.check_thy @{theory}; |
22482 | 1266 |
|
25077 | 1267 |
val T = @{typ "'a\<Colon>ab_group_add"}; |
22482 | 1268 |
|
22548 | 1269 |
val eqI_rules = [@{thm less_eqI}, @{thm le_eqI}, @{thm eq_eqI}]; |
22482 | 1270 |
|
1271 |
val dest_eqI = |
|
1272 |
fst o HOLogic.dest_bin "op =" HOLogic.boolT o HOLogic.dest_Trueprop o concl_of; |
|
1273 |
||
1274 |
end); |
|
1275 |
*} |
|
1276 |
||
1277 |
ML_setup {* |
|
1278 |
Addsimprocs [ab_group_add_cancel.sum_conv, ab_group_add_cancel.rel_conv]; |
|
1279 |
*} |
|
17085 | 1280 |
|
14738 | 1281 |
end |