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