author | haftmann |
Tue, 06 Nov 2007 13:12:48 +0100 | |
changeset 25307 | 389902f0a0c8 |
parent 25303 | 0699e20feabd |
child 25512 | 4134f7c782e2 |
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 |
||
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
397 |
subsection {* Support for reasoning about signs *} |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
398 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
399 |
class pordered_comm_monoid_add = |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
400 |
pordered_cancel_ab_semigroup_add + comm_monoid_add |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
401 |
begin |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
402 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
403 |
lemma add_pos_nonneg: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
404 |
assumes "0 < a" and "0 \<le> b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
405 |
shows "0 < a + b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
406 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
407 |
have "0 + 0 < a + b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
408 |
using assms by (rule add_less_le_mono) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
409 |
then show ?thesis by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
410 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
411 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
412 |
lemma add_pos_pos: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
413 |
assumes "0 < a" and "0 < b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
414 |
shows "0 < a + b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
415 |
by (rule add_pos_nonneg) (insert assms, auto) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
416 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
417 |
lemma add_nonneg_pos: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
418 |
assumes "0 \<le> a" and "0 < b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
419 |
shows "0 < a + b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
420 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
421 |
have "0 + 0 < a + b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
422 |
using assms by (rule add_le_less_mono) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
423 |
then show ?thesis by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
424 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
425 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
426 |
lemma add_nonneg_nonneg: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
427 |
assumes "0 \<le> a" and "0 \<le> b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
428 |
shows "0 \<le> a + b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
429 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
430 |
have "0 + 0 \<le> a + b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
431 |
using assms by (rule add_mono) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
432 |
then show ?thesis by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
433 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
434 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
435 |
lemma add_neg_nonpos: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
436 |
assumes "a < 0" and "b \<le> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
437 |
shows "a + b < 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
438 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
439 |
have "a + b < 0 + 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
440 |
using assms by (rule add_less_le_mono) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
441 |
then show ?thesis by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
442 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
443 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
444 |
lemma add_neg_neg: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
445 |
assumes "a < 0" and "b < 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
446 |
shows "a + b < 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
447 |
by (rule add_neg_nonpos) (insert assms, auto) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
448 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
449 |
lemma add_nonpos_neg: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
450 |
assumes "a \<le> 0" and "b < 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
451 |
shows "a + b < 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
452 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
453 |
have "a + b < 0 + 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
454 |
using assms by (rule add_le_less_mono) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
455 |
then show ?thesis by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
456 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
457 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
458 |
lemma add_nonpos_nonpos: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
459 |
assumes "a \<le> 0" and "b \<le> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
460 |
shows "a + b \<le> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
461 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
462 |
have "a + b \<le> 0 + 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
463 |
using assms by (rule add_mono) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
464 |
then show ?thesis by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
465 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
466 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
467 |
end |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
468 |
|
25062 | 469 |
class pordered_ab_group_add = |
470 |
ab_group_add + pordered_ab_semigroup_add |
|
471 |
begin |
|
472 |
||
473 |
subclass pordered_cancel_ab_semigroup_add |
|
474 |
by unfold_locales |
|
475 |
||
476 |
subclass pordered_ab_semigroup_add_imp_le |
|
477 |
proof unfold_locales |
|
478 |
fix a b c :: 'a |
|
479 |
assume "c + a \<le> c + b" |
|
480 |
hence "(-c) + (c + a) \<le> (-c) + (c + b)" by (rule add_left_mono) |
|
481 |
hence "((-c) + c) + a \<le> ((-c) + c) + b" by (simp only: add_assoc) |
|
482 |
thus "a \<le> b" by simp |
|
483 |
qed |
|
484 |
||
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
485 |
subclass pordered_comm_monoid_add |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
486 |
by unfold_locales |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
487 |
|
25077 | 488 |
lemma max_diff_distrib_left: |
489 |
shows "max x y - z = max (x - z) (y - z)" |
|
490 |
by (simp add: diff_minus, rule max_add_distrib_left) |
|
491 |
||
492 |
lemma min_diff_distrib_left: |
|
493 |
shows "min x y - z = min (x - z) (y - z)" |
|
494 |
by (simp add: diff_minus, rule min_add_distrib_left) |
|
495 |
||
496 |
lemma le_imp_neg_le: |
|
497 |
assumes "a \<le> b" |
|
498 |
shows "-b \<le> -a" |
|
499 |
proof - |
|
500 |
have "-a+a \<le> -a+b" |
|
501 |
using `a \<le> b` by (rule add_left_mono) |
|
502 |
hence "0 \<le> -a+b" |
|
503 |
by simp |
|
504 |
hence "0 + (-b) \<le> (-a + b) + (-b)" |
|
505 |
by (rule add_right_mono) |
|
506 |
thus ?thesis |
|
507 |
by (simp add: add_assoc) |
|
508 |
qed |
|
509 |
||
510 |
lemma neg_le_iff_le [simp]: "- b \<le> - a \<longleftrightarrow> a \<le> b" |
|
511 |
proof |
|
512 |
assume "- b \<le> - a" |
|
513 |
hence "- (- a) \<le> - (- b)" |
|
514 |
by (rule le_imp_neg_le) |
|
515 |
thus "a\<le>b" by simp |
|
516 |
next |
|
517 |
assume "a\<le>b" |
|
518 |
thus "-b \<le> -a" by (rule le_imp_neg_le) |
|
519 |
qed |
|
520 |
||
521 |
lemma neg_le_0_iff_le [simp]: "- a \<le> 0 \<longleftrightarrow> 0 \<le> a" |
|
522 |
by (subst neg_le_iff_le [symmetric], simp) |
|
523 |
||
524 |
lemma neg_0_le_iff_le [simp]: "0 \<le> - a \<longleftrightarrow> a \<le> 0" |
|
525 |
by (subst neg_le_iff_le [symmetric], simp) |
|
526 |
||
527 |
lemma neg_less_iff_less [simp]: "- b < - a \<longleftrightarrow> a < b" |
|
528 |
by (force simp add: less_le) |
|
529 |
||
530 |
lemma neg_less_0_iff_less [simp]: "- a < 0 \<longleftrightarrow> 0 < a" |
|
531 |
by (subst neg_less_iff_less [symmetric], simp) |
|
532 |
||
533 |
lemma neg_0_less_iff_less [simp]: "0 < - a \<longleftrightarrow> a < 0" |
|
534 |
by (subst neg_less_iff_less [symmetric], simp) |
|
535 |
||
536 |
text{*The next several equations can make the simplifier loop!*} |
|
537 |
||
538 |
lemma less_minus_iff: "a < - b \<longleftrightarrow> b < - a" |
|
539 |
proof - |
|
540 |
have "(- (-a) < - b) = (b < - a)" by (rule neg_less_iff_less) |
|
541 |
thus ?thesis by simp |
|
542 |
qed |
|
543 |
||
544 |
lemma minus_less_iff: "- a < b \<longleftrightarrow> - b < a" |
|
545 |
proof - |
|
546 |
have "(- a < - (-b)) = (- b < a)" by (rule neg_less_iff_less) |
|
547 |
thus ?thesis by simp |
|
548 |
qed |
|
549 |
||
550 |
lemma le_minus_iff: "a \<le> - b \<longleftrightarrow> b \<le> - a" |
|
551 |
proof - |
|
552 |
have mm: "!! a (b::'a). (-(-a)) < -b \<Longrightarrow> -(-b) < -a" by (simp only: minus_less_iff) |
|
553 |
have "(- (- a) <= -b) = (b <= - a)" |
|
554 |
apply (auto simp only: le_less) |
|
555 |
apply (drule mm) |
|
556 |
apply (simp_all) |
|
557 |
apply (drule mm[simplified], assumption) |
|
558 |
done |
|
559 |
then show ?thesis by simp |
|
560 |
qed |
|
561 |
||
562 |
lemma minus_le_iff: "- a \<le> b \<longleftrightarrow> - b \<le> a" |
|
563 |
by (auto simp add: le_less minus_less_iff) |
|
564 |
||
565 |
lemma less_iff_diff_less_0: "a < b \<longleftrightarrow> a - b < 0" |
|
566 |
proof - |
|
567 |
have "(a < b) = (a + (- b) < b + (-b))" |
|
568 |
by (simp only: add_less_cancel_right) |
|
569 |
also have "... = (a - b < 0)" by (simp add: diff_minus) |
|
570 |
finally show ?thesis . |
|
571 |
qed |
|
572 |
||
573 |
lemma diff_less_eq: "a - b < c \<longleftrightarrow> a < c + b" |
|
574 |
apply (subst less_iff_diff_less_0 [of a]) |
|
575 |
apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst]) |
|
576 |
apply (simp add: diff_minus add_ac) |
|
577 |
done |
|
578 |
||
579 |
lemma less_diff_eq: "a < c - b \<longleftrightarrow> a + b < c" |
|
580 |
apply (subst less_iff_diff_less_0 [of "plus a b"]) |
|
581 |
apply (subst less_iff_diff_less_0 [of a]) |
|
582 |
apply (simp add: diff_minus add_ac) |
|
583 |
done |
|
584 |
||
585 |
lemma diff_le_eq: "a - b \<le> c \<longleftrightarrow> a \<le> c + b" |
|
586 |
by (auto simp add: le_less diff_less_eq diff_add_cancel add_diff_cancel) |
|
587 |
||
588 |
lemma le_diff_eq: "a \<le> c - b \<longleftrightarrow> a + b \<le> c" |
|
589 |
by (auto simp add: le_less less_diff_eq diff_add_cancel add_diff_cancel) |
|
590 |
||
591 |
lemmas compare_rls = |
|
592 |
diff_minus [symmetric] |
|
593 |
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 |
|
594 |
diff_less_eq less_diff_eq diff_le_eq le_diff_eq |
|
595 |
diff_eq_eq eq_diff_eq |
|
596 |
||
597 |
text{*This list of rewrites simplifies (in)equalities by bringing subtractions |
|
598 |
to the top and then moving negative terms to the other side. |
|
599 |
Use with @{text add_ac}*} |
|
600 |
lemmas (in -) compare_rls = |
|
601 |
diff_minus [symmetric] |
|
602 |
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 |
|
603 |
diff_less_eq less_diff_eq diff_le_eq le_diff_eq |
|
604 |
diff_eq_eq eq_diff_eq |
|
605 |
||
606 |
lemma le_iff_diff_le_0: "a \<le> b \<longleftrightarrow> a - b \<le> 0" |
|
607 |
by (simp add: compare_rls) |
|
608 |
||
25230 | 609 |
lemmas group_simps = |
610 |
add_ac |
|
611 |
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 |
|
612 |
diff_eq_eq eq_diff_eq diff_minus [symmetric] uminus_add_conv_diff |
|
613 |
diff_less_eq less_diff_eq diff_le_eq le_diff_eq |
|
614 |
||
25077 | 615 |
end |
616 |
||
25230 | 617 |
lemmas group_simps = |
618 |
mult_ac |
|
619 |
add_ac |
|
620 |
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 |
|
621 |
diff_eq_eq eq_diff_eq diff_minus [symmetric] uminus_add_conv_diff |
|
622 |
diff_less_eq less_diff_eq diff_le_eq le_diff_eq |
|
623 |
||
25062 | 624 |
class ordered_ab_semigroup_add = |
625 |
linorder + pordered_ab_semigroup_add |
|
626 |
||
627 |
class ordered_cancel_ab_semigroup_add = |
|
628 |
linorder + pordered_cancel_ab_semigroup_add |
|
25267 | 629 |
begin |
25062 | 630 |
|
25267 | 631 |
subclass ordered_ab_semigroup_add |
25062 | 632 |
by unfold_locales |
633 |
||
25267 | 634 |
subclass pordered_ab_semigroup_add_imp_le |
25062 | 635 |
proof unfold_locales |
636 |
fix a b c :: 'a |
|
637 |
assume le: "c + a <= c + b" |
|
638 |
show "a <= b" |
|
639 |
proof (rule ccontr) |
|
640 |
assume w: "~ a \<le> b" |
|
641 |
hence "b <= a" by (simp add: linorder_not_le) |
|
642 |
hence le2: "c + b <= c + a" by (rule add_left_mono) |
|
643 |
have "a = b" |
|
644 |
apply (insert le) |
|
645 |
apply (insert le2) |
|
646 |
apply (drule antisym, simp_all) |
|
647 |
done |
|
648 |
with w show False |
|
649 |
by (simp add: linorder_not_le [symmetric]) |
|
650 |
qed |
|
651 |
qed |
|
652 |
||
25267 | 653 |
end |
654 |
||
25230 | 655 |
class ordered_ab_group_add = |
656 |
linorder + pordered_ab_group_add |
|
25267 | 657 |
begin |
25230 | 658 |
|
25267 | 659 |
subclass ordered_cancel_ab_semigroup_add |
25230 | 660 |
by unfold_locales |
661 |
||
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
662 |
lemma neg_less_eq_nonneg: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
663 |
"- a \<le> a \<longleftrightarrow> 0 \<le> a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
664 |
proof |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
665 |
assume A: "- a \<le> a" show "0 \<le> a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
666 |
proof (rule classical) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
667 |
assume "\<not> 0 \<le> a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
668 |
then have "a < 0" by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
669 |
with A have "- a < 0" by (rule le_less_trans) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
670 |
then show ?thesis by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
671 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
672 |
next |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
673 |
assume A: "0 \<le> a" show "- a \<le> a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
674 |
proof (rule order_trans) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
675 |
show "- a \<le> 0" using A by (simp add: minus_le_iff) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
676 |
next |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
677 |
show "0 \<le> a" using A . |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
678 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
679 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
680 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
681 |
lemma less_eq_neg_nonpos: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
682 |
"a \<le> - a \<longleftrightarrow> a \<le> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
683 |
proof |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
684 |
assume A: "a \<le> - a" show "a \<le> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
685 |
proof (rule classical) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
686 |
assume "\<not> a \<le> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
687 |
then have "0 < a" by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
688 |
then have "0 < - a" using A by (rule less_le_trans) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
689 |
then show ?thesis by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
690 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
691 |
next |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
692 |
assume A: "a \<le> 0" show "a \<le> - a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
693 |
proof (rule order_trans) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
694 |
show "0 \<le> - a" using A by (simp add: minus_le_iff) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
695 |
next |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
696 |
show "a \<le> 0" using A . |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
697 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
698 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
699 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
700 |
lemma equal_neg_zero: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
701 |
"a = - a \<longleftrightarrow> a = 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
702 |
proof |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
703 |
assume "a = 0" then show "a = - a" by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
704 |
next |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
705 |
assume A: "a = - a" show "a = 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
706 |
proof (cases "0 \<le> a") |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
707 |
case True with A have "0 \<le> - a" by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
708 |
with le_minus_iff have "a \<le> 0" by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
709 |
with True show ?thesis by (auto intro: order_trans) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
710 |
next |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
711 |
case False then have B: "a \<le> 0" by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
712 |
with A have "- a \<le> 0" by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
713 |
with B show ?thesis by (auto intro: order_trans) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
714 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
715 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
716 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
717 |
lemma neg_equal_zero: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
718 |
"- a = a \<longleftrightarrow> a = 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
719 |
unfolding equal_neg_zero [symmetric] by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
720 |
|
25267 | 721 |
end |
722 |
||
25077 | 723 |
-- {* FIXME localize the following *} |
14738 | 724 |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
725 |
lemma add_increasing: |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
726 |
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
727 |
shows "[|0\<le>a; b\<le>c|] ==> b \<le> a + c" |
14738 | 728 |
by (insert add_mono [of 0 a b c], simp) |
729 |
||
15539 | 730 |
lemma add_increasing2: |
731 |
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" |
|
732 |
shows "[|0\<le>c; b\<le>a|] ==> b \<le> a + c" |
|
733 |
by (simp add:add_increasing add_commute[of a]) |
|
734 |
||
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
735 |
lemma add_strict_increasing: |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
736 |
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
737 |
shows "[|0<a; b\<le>c|] ==> b < a + c" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
738 |
by (insert add_less_le_mono [of 0 a b c], simp) |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
739 |
|
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
740 |
lemma add_strict_increasing2: |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
741 |
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
742 |
shows "[|0\<le>a; b<c|] ==> b < a + c" |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
743 |
by (insert add_le_less_mono [of 0 a b c], simp) |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
744 |
|
14738 | 745 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
746 |
class pordered_ab_group_add_abs = pordered_ab_group_add + abs + |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
747 |
assumes abs_ge_zero [simp]: "\<bar>a\<bar> \<ge> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
748 |
and abs_ge_self: "a \<le> \<bar>a\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
749 |
and abs_leI: "a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
750 |
and abs_minus_cancel [simp]: "\<bar>-a\<bar> = \<bar>a\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
751 |
and abs_triangle_ineq: "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
752 |
begin |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
753 |
|
25307 | 754 |
lemma abs_minus_le_zero: "- \<bar>a\<bar> \<le> 0" |
755 |
unfolding neg_le_0_iff_le by simp |
|
756 |
||
757 |
lemma abs_of_nonneg [simp]: |
|
758 |
assumes nonneg: "0 \<le> a" |
|
759 |
shows "\<bar>a\<bar> = a" |
|
760 |
proof (rule antisym) |
|
761 |
from nonneg le_imp_neg_le have "- a \<le> 0" by simp |
|
762 |
from this nonneg have "- a \<le> a" by (rule order_trans) |
|
763 |
then show "\<bar>a\<bar> \<le> a" by (auto intro: abs_leI) |
|
764 |
qed (rule abs_ge_self) |
|
765 |
||
766 |
lemma abs_idempotent [simp]: "\<bar>\<bar>a\<bar>\<bar> = \<bar>a\<bar>" |
|
767 |
by (rule antisym) |
|
768 |
(auto intro!: abs_ge_self abs_leI order_trans [of "uminus (abs a)" zero "abs a"]) |
|
769 |
||
770 |
lemma abs_eq_0 [simp]: "\<bar>a\<bar> = 0 \<longleftrightarrow> a = 0" |
|
771 |
proof - |
|
772 |
have "\<bar>a\<bar> = 0 \<Longrightarrow> a = 0" |
|
773 |
proof (rule antisym) |
|
774 |
assume zero: "\<bar>a\<bar> = 0" |
|
775 |
with abs_ge_self show "a \<le> 0" by auto |
|
776 |
from zero have "\<bar>-a\<bar> = 0" by simp |
|
777 |
with abs_ge_self [of "uminus a"] have "- a \<le> 0" by auto |
|
778 |
with neg_le_0_iff_le show "0 \<le> a" by auto |
|
779 |
qed |
|
780 |
then show ?thesis by auto |
|
781 |
qed |
|
782 |
||
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
783 |
lemma abs_zero [simp]: "\<bar>0\<bar> = 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
784 |
by simp |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
785 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
786 |
lemma abs_0_eq [simp, noatp]: "0 = \<bar>a\<bar> \<longleftrightarrow> a = 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
787 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
788 |
have "0 = \<bar>a\<bar> \<longleftrightarrow> \<bar>a\<bar> = 0" by (simp only: eq_ac) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
789 |
thus ?thesis by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
790 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
791 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
792 |
lemma abs_le_zero_iff [simp]: "\<bar>a\<bar> \<le> 0 \<longleftrightarrow> a = 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
793 |
proof |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
794 |
assume "\<bar>a\<bar> \<le> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
795 |
then have "\<bar>a\<bar> = 0" by (rule antisym) simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
796 |
thus "a = 0" by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
797 |
next |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
798 |
assume "a = 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
799 |
thus "\<bar>a\<bar> \<le> 0" by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
800 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
801 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
802 |
lemma zero_less_abs_iff [simp]: "0 < \<bar>a\<bar> \<longleftrightarrow> a \<noteq> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
803 |
by (simp add: less_le) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
804 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
805 |
lemma abs_not_less_zero [simp]: "\<not> \<bar>a\<bar> < 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
806 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
807 |
have a: "\<And>x y. x \<le> y \<Longrightarrow> \<not> y < x" by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
808 |
show ?thesis by (simp add: a) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
809 |
qed |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
810 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
811 |
lemma abs_ge_minus_self: "- a \<le> \<bar>a\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
812 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
813 |
have "- a \<le> \<bar>-a\<bar>" by (rule abs_ge_self) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
814 |
then show ?thesis by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
815 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
816 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
817 |
lemma abs_minus_commute: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
818 |
"\<bar>a - b\<bar> = \<bar>b - a\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
819 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
820 |
have "\<bar>a - b\<bar> = \<bar>- (a - b)\<bar>" by (simp only: abs_minus_cancel) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
821 |
also have "... = \<bar>b - a\<bar>" by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
822 |
finally show ?thesis . |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
823 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
824 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
825 |
lemma abs_of_pos: "0 < a \<Longrightarrow> \<bar>a\<bar> = a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
826 |
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
|
827 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
828 |
lemma abs_of_nonpos [simp]: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
829 |
assumes "a \<le> 0" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
830 |
shows "\<bar>a\<bar> = - a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
831 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
832 |
let ?b = "- a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
833 |
have "- ?b \<le> 0 \<Longrightarrow> \<bar>- ?b\<bar> = - (- ?b)" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
834 |
unfolding abs_minus_cancel [of "?b"] |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
835 |
unfolding neg_le_0_iff_le [of "?b"] |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
836 |
unfolding minus_minus by (erule abs_of_nonneg) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
837 |
then show ?thesis using assms by auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
838 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
839 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
840 |
lemma abs_of_neg: "a < 0 \<Longrightarrow> \<bar>a\<bar> = - a" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
841 |
by (rule abs_of_nonpos, rule less_imp_le) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
842 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
843 |
lemma abs_le_D1: "\<bar>a\<bar> \<le> b \<Longrightarrow> a \<le> b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
844 |
by (insert abs_ge_self, blast intro: order_trans) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
845 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
846 |
lemma abs_le_D2: "\<bar>a\<bar> \<le> b \<Longrightarrow> - a \<le> b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
847 |
by (insert abs_le_D1 [of "uminus a"], simp) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
848 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
849 |
lemma abs_le_iff: "\<bar>a\<bar> \<le> b \<longleftrightarrow> a \<le> b \<and> - a \<le> b" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
850 |
by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
851 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
852 |
lemma abs_triangle_ineq2: "\<bar>a\<bar> - \<bar>b\<bar> \<le> \<bar>a - b\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
853 |
apply (simp add: compare_rls) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
854 |
apply (subgoal_tac "abs a = abs (plus (minus a b) b)") |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
855 |
apply (erule ssubst) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
856 |
apply (rule abs_triangle_ineq) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
857 |
apply (rule arg_cong) back |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
858 |
apply (simp add: compare_rls) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
859 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
860 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
861 |
lemma abs_triangle_ineq3: "\<bar>\<bar>a\<bar> - \<bar>b\<bar>\<bar> \<le> \<bar>a - b\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
862 |
apply (subst abs_le_iff) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
863 |
apply auto |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
864 |
apply (rule abs_triangle_ineq2) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
865 |
apply (subst abs_minus_commute) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
866 |
apply (rule abs_triangle_ineq2) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
867 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
868 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
869 |
lemma abs_triangle_ineq4: "\<bar>a - b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
870 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
871 |
have "abs(a - b) = abs(a + - b)" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
872 |
by (subst diff_minus, rule refl) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
873 |
also have "... <= abs a + abs (- b)" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
874 |
by (rule abs_triangle_ineq) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
875 |
finally show ?thesis |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
876 |
by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
877 |
qed |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
878 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
879 |
lemma abs_diff_triangle_ineq: "\<bar>a + b - (c + d)\<bar> \<le> \<bar>a - c\<bar> + \<bar>b - d\<bar>" |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
880 |
proof - |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
881 |
have "\<bar>a + b - (c+d)\<bar> = \<bar>(a-c) + (b-d)\<bar>" by (simp add: diff_minus add_ac) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
882 |
also have "... \<le> \<bar>a-c\<bar> + \<bar>b-d\<bar>" by (rule abs_triangle_ineq) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
883 |
finally show ?thesis . |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
884 |
qed |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
885 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
886 |
lemma abs_add_abs [simp]: |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
887 |
"\<bar>\<bar>a\<bar> + \<bar>b\<bar>\<bar> = \<bar>a\<bar> + \<bar>b\<bar>" (is "?L = ?R") |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
888 |
proof (rule antisym) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
889 |
show "?L \<ge> ?R" by(rule abs_ge_self) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
890 |
next |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
891 |
have "?L \<le> \<bar>\<bar>a\<bar>\<bar> + \<bar>\<bar>b\<bar>\<bar>" by(rule abs_triangle_ineq) |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
892 |
also have "\<dots> = ?R" by simp |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
893 |
finally show "?L \<le> ?R" . |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
894 |
qed |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
895 |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
896 |
end |
14738 | 897 |
|
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
898 |
|
14738 | 899 |
subsection {* Lattice Ordered (Abelian) Groups *} |
900 |
||
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
901 |
class lordered_ab_group_add_meet = pordered_ab_group_add + lower_semilattice |
25090 | 902 |
begin |
14738 | 903 |
|
25090 | 904 |
lemma add_inf_distrib_left: |
905 |
"a + inf b c = inf (a + b) (a + c)" |
|
906 |
apply (rule antisym) |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
907 |
apply (simp_all add: le_infI) |
25090 | 908 |
apply (rule add_le_imp_le_left [of "uminus a"]) |
909 |
apply (simp only: add_assoc [symmetric], simp) |
|
21312 | 910 |
apply rule |
911 |
apply (rule add_le_imp_le_left[of "a"], simp only: add_assoc[symmetric], simp)+ |
|
14738 | 912 |
done |
913 |
||
25090 | 914 |
lemma add_inf_distrib_right: |
915 |
"inf a b + c = inf (a + c) (b + c)" |
|
916 |
proof - |
|
917 |
have "c + inf a b = inf (c+a) (c+b)" by (simp add: add_inf_distrib_left) |
|
918 |
thus ?thesis by (simp add: add_commute) |
|
919 |
qed |
|
920 |
||
921 |
end |
|
922 |
||
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
923 |
class lordered_ab_group_add_join = pordered_ab_group_add + upper_semilattice |
25090 | 924 |
begin |
925 |
||
926 |
lemma add_sup_distrib_left: |
|
927 |
"a + sup b c = sup (a + b) (a + c)" |
|
928 |
apply (rule antisym) |
|
929 |
apply (rule add_le_imp_le_left [of "uminus a"]) |
|
14738 | 930 |
apply (simp only: add_assoc[symmetric], simp) |
21312 | 931 |
apply rule |
932 |
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
|
933 |
apply (rule le_supI) |
21312 | 934 |
apply (simp_all) |
14738 | 935 |
done |
936 |
||
25090 | 937 |
lemma add_sup_distrib_right: |
938 |
"sup a b + c = sup (a+c) (b+c)" |
|
14738 | 939 |
proof - |
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
940 |
have "c + sup a b = sup (c+a) (c+b)" by (simp add: add_sup_distrib_left) |
14738 | 941 |
thus ?thesis by (simp add: add_commute) |
942 |
qed |
|
943 |
||
25090 | 944 |
end |
945 |
||
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
946 |
class lordered_ab_group_add = pordered_ab_group_add + lattice |
25090 | 947 |
begin |
948 |
||
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
949 |
subclass lordered_ab_group_add_meet by unfold_locales |
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
950 |
subclass lordered_ab_group_add_join by unfold_locales |
25090 | 951 |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
952 |
lemmas add_sup_inf_distribs = add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left |
14738 | 953 |
|
25090 | 954 |
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
|
955 |
proof (rule inf_unique) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
956 |
fix a b :: 'a |
25090 | 957 |
show "- sup (-a) (-b) \<le> a" |
958 |
by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"]) |
|
959 |
(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
|
960 |
next |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
961 |
fix a b :: 'a |
25090 | 962 |
show "- sup (-a) (-b) \<le> b" |
963 |
by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"]) |
|
964 |
(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
|
965 |
next |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
966 |
fix a b c :: 'a |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
967 |
assume "a \<le> b" "a \<le> c" |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
968 |
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
|
969 |
(simp add: le_supI) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
970 |
qed |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
971 |
|
25090 | 972 |
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
|
973 |
proof (rule sup_unique) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
974 |
fix a b :: 'a |
25090 | 975 |
show "a \<le> - inf (-a) (-b)" |
976 |
by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"]) |
|
977 |
(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
|
978 |
next |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
979 |
fix a b :: 'a |
25090 | 980 |
show "b \<le> - inf (-a) (-b)" |
981 |
by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"]) |
|
982 |
(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
|
983 |
next |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
984 |
fix a b c :: 'a |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
985 |
assume "a \<le> c" "b \<le> c" |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
986 |
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
|
987 |
(simp add: le_infI) |
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset
|
988 |
qed |
14738 | 989 |
|
25230 | 990 |
lemma neg_inf_eq_sup: "- inf a b = sup (-a) (-b)" |
991 |
by (simp add: inf_eq_neg_sup) |
|
992 |
||
993 |
lemma neg_sup_eq_inf: "- sup a b = inf (-a) (-b)" |
|
994 |
by (simp add: sup_eq_neg_inf) |
|
995 |
||
25090 | 996 |
lemma add_eq_inf_sup: "a + b = sup a b + inf a b" |
14738 | 997 |
proof - |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
998 |
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
|
999 |
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
|
1000 |
hence "0 = (-a + sup a b) + (inf a b + (-b))" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1001 |
apply (simp add: add_sup_distrib_left add_inf_distrib_right) |
14738 | 1002 |
by (simp add: diff_minus add_commute) |
1003 |
thus ?thesis |
|
1004 |
apply (simp add: compare_rls) |
|
25090 | 1005 |
apply (subst add_left_cancel [symmetric, of "plus a b" "plus (sup a b) (inf a b)" "uminus a"]) |
14738 | 1006 |
apply (simp only: add_assoc, simp add: add_assoc[symmetric]) |
1007 |
done |
|
1008 |
qed |
|
1009 |
||
1010 |
subsection {* Positive Part, Negative Part, Absolute Value *} |
|
1011 |
||
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1012 |
definition |
25090 | 1013 |
nprt :: "'a \<Rightarrow> 'a" where |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1014 |
"nprt x = inf x 0" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1015 |
|
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1016 |
definition |
25090 | 1017 |
pprt :: "'a \<Rightarrow> 'a" where |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1018 |
"pprt x = sup x 0" |
14738 | 1019 |
|
25230 | 1020 |
lemma pprt_neg: "pprt (- x) = - nprt x" |
1021 |
proof - |
|
1022 |
have "sup (- x) 0 = sup (- x) (- 0)" unfolding minus_zero .. |
|
1023 |
also have "\<dots> = - inf x 0" unfolding neg_inf_eq_sup .. |
|
1024 |
finally have "sup (- x) 0 = - inf x 0" . |
|
1025 |
then show ?thesis unfolding pprt_def nprt_def . |
|
1026 |
qed |
|
1027 |
||
1028 |
lemma nprt_neg: "nprt (- x) = - pprt x" |
|
1029 |
proof - |
|
1030 |
from pprt_neg have "pprt (- (- x)) = - nprt (- x)" . |
|
1031 |
then have "pprt x = - nprt (- x)" by simp |
|
1032 |
then show ?thesis by simp |
|
1033 |
qed |
|
1034 |
||
14738 | 1035 |
lemma prts: "a = pprt a + nprt a" |
25090 | 1036 |
by (simp add: pprt_def nprt_def add_eq_inf_sup[symmetric]) |
14738 | 1037 |
|
1038 |
lemma zero_le_pprt[simp]: "0 \<le> pprt a" |
|
25090 | 1039 |
by (simp add: pprt_def) |
14738 | 1040 |
|
1041 |
lemma nprt_le_zero[simp]: "nprt a \<le> 0" |
|
25090 | 1042 |
by (simp add: nprt_def) |
14738 | 1043 |
|
25090 | 1044 |
lemma le_eq_neg: "a \<le> - b \<longleftrightarrow> a + b \<le> 0" (is "?l = ?r") |
14738 | 1045 |
proof - |
1046 |
have a: "?l \<longrightarrow> ?r" |
|
1047 |
apply (auto) |
|
25090 | 1048 |
apply (rule add_le_imp_le_right[of _ "uminus b" _]) |
14738 | 1049 |
apply (simp add: add_assoc) |
1050 |
done |
|
1051 |
have b: "?r \<longrightarrow> ?l" |
|
1052 |
apply (auto) |
|
1053 |
apply (rule add_le_imp_le_right[of _ "b" _]) |
|
1054 |
apply (simp) |
|
1055 |
done |
|
1056 |
from a b show ?thesis by blast |
|
1057 |
qed |
|
1058 |
||
15580 | 1059 |
lemma pprt_0[simp]: "pprt 0 = 0" by (simp add: pprt_def) |
1060 |
lemma nprt_0[simp]: "nprt 0 = 0" by (simp add: nprt_def) |
|
1061 |
||
25090 | 1062 |
lemma pprt_eq_id [simp, noatp]: "0 \<le> x \<Longrightarrow> pprt x = x" |
1063 |
by (simp add: pprt_def le_iff_sup sup_ACI) |
|
15580 | 1064 |
|
25090 | 1065 |
lemma nprt_eq_id [simp, noatp]: "x \<le> 0 \<Longrightarrow> nprt x = x" |
1066 |
by (simp add: nprt_def le_iff_inf inf_ACI) |
|
15580 | 1067 |
|
25090 | 1068 |
lemma pprt_eq_0 [simp, noatp]: "x \<le> 0 \<Longrightarrow> pprt x = 0" |
1069 |
by (simp add: pprt_def le_iff_sup sup_ACI) |
|
15580 | 1070 |
|
25090 | 1071 |
lemma nprt_eq_0 [simp, noatp]: "0 \<le> x \<Longrightarrow> nprt x = 0" |
1072 |
by (simp add: nprt_def le_iff_inf inf_ACI) |
|
15580 | 1073 |
|
25090 | 1074 |
lemma sup_0_imp_0: "sup a (- a) = 0 \<Longrightarrow> a = 0" |
14738 | 1075 |
proof - |
1076 |
{ |
|
1077 |
fix a::'a |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1078 |
assume hyp: "sup a (-a) = 0" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1079 |
hence "sup a (-a) + a = a" by (simp) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1080 |
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
|
1081 |
hence "sup (a+a) 0 <= a" by (simp) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1082 |
hence "0 <= a" by (blast intro: order_trans inf_sup_ord) |
14738 | 1083 |
} |
1084 |
note p = this |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1085 |
assume hyp:"sup a (-a) = 0" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1086 |
hence hyp2:"sup (-a) (-(-a)) = 0" by (simp add: sup_commute) |
14738 | 1087 |
from p[OF hyp] p[OF hyp2] show "a = 0" by simp |
1088 |
qed |
|
1089 |
||
25090 | 1090 |
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
|
1091 |
apply (simp add: inf_eq_neg_sup) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1092 |
apply (simp add: sup_commute) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1093 |
apply (erule sup_0_imp_0) |
15481 | 1094 |
done |
14738 | 1095 |
|
25090 | 1096 |
lemma inf_0_eq_0 [simp, noatp]: "inf a (- a) = 0 \<longleftrightarrow> a = 0" |
1097 |
by (rule, erule inf_0_imp_0) simp |
|
14738 | 1098 |
|
25090 | 1099 |
lemma sup_0_eq_0 [simp, noatp]: "sup a (- a) = 0 \<longleftrightarrow> a = 0" |
1100 |
by (rule, erule sup_0_imp_0) simp |
|
14738 | 1101 |
|
25090 | 1102 |
lemma zero_le_double_add_iff_zero_le_single_add [simp]: |
1103 |
"0 \<le> a + a \<longleftrightarrow> 0 \<le> a" |
|
14738 | 1104 |
proof |
1105 |
assume "0 <= a + a" |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1106 |
hence a:"inf (a+a) 0 = 0" by (simp add: le_iff_inf inf_commute) |
25090 | 1107 |
have "(inf a 0)+(inf a 0) = inf (inf (a+a) 0) a" (is "?l=_") |
1108 |
by (simp add: add_sup_inf_distribs inf_ACI) |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset
|
1109 |
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
|
1110 |
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
|
1111 |
then show "0 <= a" by (simp add: le_iff_inf inf_commute) |
14738 | 1112 |
next |
1113 |
assume a: "0 <= a" |
|
1114 |
show "0 <= a + a" by (simp add: add_mono[OF a a, simplified]) |
|
1115 |
qed |
|
1116 |
||
25090 | 1117 |
lemma double_zero: "a + a = 0 \<longleftrightarrow> a = 0" |
1118 |
proof |
|
1119 |
assume assm: "a + a = 0" |
|
1120 |
then have "a + a + - a = - a" by simp |
|
1121 |
then have "a + (a + - a) = - a" by (simp only: add_assoc) |
|
1122 |
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
|
1123 |
show "a = 0" apply (rule antisym) |
25090 | 1124 |
apply (unfold neg_le_iff_le [symmetric, of a]) |
1125 |
unfolding a apply simp |
|
1126 |
unfolding zero_le_double_add_iff_zero_le_single_add [symmetric, of a] |
|
1127 |
unfolding assm unfolding le_less apply simp_all done |
|
1128 |
next |
|
1129 |
assume "a = 0" then show "a + a = 0" by simp |
|
1130 |
qed |
|
1131 |
||
1132 |
lemma zero_less_double_add_iff_zero_less_single_add: |
|
1133 |
"0 < a + a \<longleftrightarrow> 0 < a" |
|
1134 |
proof (cases "a = 0") |
|
1135 |
case True then show ?thesis by auto |
|
1136 |
next |
|
1137 |
case False then show ?thesis (*FIXME tune proof*) |
|
1138 |
unfolding less_le apply simp apply rule |
|
1139 |
apply clarify |
|
1140 |
apply rule |
|
1141 |
apply assumption |
|
1142 |
apply (rule notI) |
|
1143 |
unfolding double_zero [symmetric, of a] apply simp |
|
1144 |
done |
|
1145 |
qed |
|
1146 |
||
1147 |
lemma double_add_le_zero_iff_single_add_le_zero [simp]: |
|
1148 |
"a + a \<le> 0 \<longleftrightarrow> a \<le> 0" |
|
14738 | 1149 |
proof - |
25090 | 1150 |
have "a + a \<le> 0 \<longleftrightarrow> 0 \<le> - (a + a)" by (subst le_minus_iff, simp) |
1151 |
moreover have "\<dots> \<longleftrightarrow> a \<le> 0" by (simp add: zero_le_double_add_iff_zero_le_single_add) |
|
14738 | 1152 |
ultimately show ?thesis by blast |
1153 |
qed |
|
1154 |
||
25090 | 1155 |
lemma double_add_less_zero_iff_single_less_zero [simp]: |
1156 |
"a + a < 0 \<longleftrightarrow> a < 0" |
|
1157 |
proof - |
|
1158 |
have "a + a < 0 \<longleftrightarrow> 0 < - (a + a)" by (subst less_minus_iff, simp) |
|
1159 |
moreover have "\<dots> \<longleftrightarrow> a < 0" by (simp add: zero_less_double_add_iff_zero_less_single_add) |
|
1160 |
ultimately show ?thesis by blast |
|
14738 | 1161 |
qed |
1162 |
||
25230 | 1163 |
declare neg_inf_eq_sup [simp] neg_sup_eq_inf [simp] |
1164 |
||
1165 |
lemma le_minus_self_iff: "a \<le> - a \<longleftrightarrow> a \<le> 0" |
|
1166 |
proof - |
|
1167 |
from add_le_cancel_left [of "uminus a" "plus a a" zero] |
|
1168 |
have "(a <= -a) = (a+a <= 0)" |
|
1169 |
by (simp add: add_assoc[symmetric]) |
|
1170 |
thus ?thesis by simp |
|
1171 |
qed |
|
1172 |
||
1173 |
lemma minus_le_self_iff: "- a \<le> a \<longleftrightarrow> 0 \<le> a" |
|
1174 |
proof - |
|
1175 |
from add_le_cancel_left [of "uminus a" zero "plus a a"] |
|
1176 |
have "(-a <= a) = (0 <= a+a)" |
|
1177 |
by (simp add: add_assoc[symmetric]) |
|
1178 |
thus ?thesis by simp |
|
1179 |
qed |
|
1180 |
||
1181 |
lemma zero_le_iff_zero_nprt: "0 \<le> a \<longleftrightarrow> nprt a = 0" |
|
1182 |
by (simp add: le_iff_inf nprt_def inf_commute) |
|
1183 |
||
1184 |
lemma le_zero_iff_zero_pprt: "a \<le> 0 \<longleftrightarrow> pprt a = 0" |
|
1185 |
by (simp add: le_iff_sup pprt_def sup_commute) |
|
1186 |
||
1187 |
lemma le_zero_iff_pprt_id: "0 \<le> a \<longleftrightarrow> pprt a = a" |
|
1188 |
by (simp add: le_iff_sup pprt_def sup_commute) |
|
1189 |
||
1190 |
lemma zero_le_iff_nprt_id: "a \<le> 0 \<longleftrightarrow> nprt a = a" |
|
1191 |
by (simp add: le_iff_inf nprt_def inf_commute) |
|
1192 |
||
1193 |
lemma pprt_mono [simp, noatp]: "a \<le> b \<Longrightarrow> pprt a \<le> pprt b" |
|
1194 |
by (simp add: le_iff_sup pprt_def sup_ACI sup_assoc [symmetric, of a]) |
|
1195 |
||
1196 |
lemma nprt_mono [simp, noatp]: "a \<le> b \<Longrightarrow> nprt a \<le> nprt b" |
|
1197 |
by (simp add: le_iff_inf nprt_def inf_ACI inf_assoc [symmetric, of a]) |
|
1198 |
||
25090 | 1199 |
end |
1200 |
||
1201 |
lemmas add_sup_inf_distribs = add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left |
|
1202 |
||
25230 | 1203 |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1204 |
class lordered_ab_group_add_abs = lordered_ab_group_add + abs + |
25230 | 1205 |
assumes abs_lattice: "\<bar>a\<bar> = sup a (- a)" |
1206 |
begin |
|
1207 |
||
1208 |
lemma abs_prts: "\<bar>a\<bar> = pprt a - nprt a" |
|
1209 |
proof - |
|
1210 |
have "0 \<le> \<bar>a\<bar>" |
|
1211 |
proof - |
|
1212 |
have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>" by (auto simp add: abs_lattice) |
|
1213 |
show ?thesis by (rule add_mono [OF a b, simplified]) |
|
1214 |
qed |
|
1215 |
then have "0 \<le> sup a (- a)" unfolding abs_lattice . |
|
1216 |
then have "sup (sup a (- a)) 0 = sup a (- a)" by (rule sup_absorb1) |
|
1217 |
then show ?thesis |
|
1218 |
by (simp add: add_sup_inf_distribs sup_ACI |
|
1219 |
pprt_def nprt_def diff_minus abs_lattice) |
|
1220 |
qed |
|
1221 |
||
1222 |
subclass pordered_ab_group_add_abs |
|
1223 |
proof - |
|
1224 |
have abs_ge_zero [simp]: "\<And>a. 0 \<le> \<bar>a\<bar>" |
|
1225 |
proof - |
|
1226 |
fix a b |
|
1227 |
have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>" by (auto simp add: abs_lattice) |
|
1228 |
show "0 \<le> \<bar>a\<bar>" by (rule add_mono [OF a b, simplified]) |
|
1229 |
qed |
|
1230 |
have abs_leI: "\<And>a b. a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" |
|
1231 |
by (simp add: abs_lattice le_supI) |
|
1232 |
show ?thesis |
|
1233 |
proof unfold_locales |
|
1234 |
fix a |
|
1235 |
show "0 \<le> \<bar>a\<bar>" by simp |
|
1236 |
next |
|
1237 |
fix a |
|
1238 |
show "a \<le> \<bar>a\<bar>" |
|
1239 |
by (auto simp add: abs_lattice) |
|
1240 |
next |
|
1241 |
fix a |
|
1242 |
show "\<bar>-a\<bar> = \<bar>a\<bar>" |
|
1243 |
by (simp add: abs_lattice sup_commute) |
|
1244 |
next |
|
1245 |
fix a b |
|
1246 |
show "a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" by (erule abs_leI) |
|
1247 |
next |
|
1248 |
fix a b |
|
1249 |
show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" |
|
1250 |
proof - |
|
1251 |
have g:"abs a + abs b = sup (a+b) (sup (-a-b) (sup (-a+b) (a + (-b))))" (is "_=sup ?m ?n") |
|
1252 |
by (simp add: abs_lattice add_sup_inf_distribs sup_ACI diff_minus) |
|
1253 |
have a:"a+b <= sup ?m ?n" by (simp) |
|
1254 |
have b:"-a-b <= ?n" by (simp) |
|
1255 |
have c:"?n <= sup ?m ?n" by (simp) |
|
1256 |
from b c have d: "-a-b <= sup ?m ?n" by(rule order_trans) |
|
1257 |
have e:"-a-b = -(a+b)" by (simp add: diff_minus) |
|
1258 |
from a d e have "abs(a+b) <= sup ?m ?n" |
|
1259 |
by (drule_tac abs_leI, auto) |
|
1260 |
with g[symmetric] show ?thesis by simp |
|
1261 |
qed |
|
1262 |
qed auto |
|
1263 |
qed |
|
1264 |
||
1265 |
end |
|
1266 |
||
25090 | 1267 |
lemma sup_eq_if: |
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1268 |
fixes a :: "'a\<Colon>{lordered_ab_group_add, linorder}" |
25090 | 1269 |
shows "sup a (- a) = (if a < 0 then - a else a)" |
1270 |
proof - |
|
1271 |
note add_le_cancel_right [of a a "- a", symmetric, simplified] |
|
1272 |
moreover note add_le_cancel_right [of "-a" a a, symmetric, simplified] |
|
1273 |
then show ?thesis by (auto simp: sup_max max_def) |
|
1274 |
qed |
|
1275 |
||
1276 |
lemma abs_if_lattice: |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1277 |
fixes a :: "'a\<Colon>{lordered_ab_group_add_abs, linorder}" |
25090 | 1278 |
shows "\<bar>a\<bar> = (if a < 0 then - a else a)" |
1279 |
by auto |
|
1280 |
||
1281 |
||
14754
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1282 |
text {* Needed for abelian cancellation simprocs: *} |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1283 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1284 |
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
|
1285 |
apply (subst add_left_commute) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1286 |
apply (subst add_left_cancel) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1287 |
apply simp |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1288 |
done |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1289 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1290 |
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
|
1291 |
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
|
1292 |
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
|
1293 |
done |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1294 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1295 |
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
|
1296 |
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
|
1297 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1298 |
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
|
1299 |
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
|
1300 |
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
|
1301 |
done |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1302 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1303 |
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
|
1304 |
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
|
1305 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1306 |
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
|
1307 |
by (simp add: diff_minus) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1308 |
|
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1309 |
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
|
1310 |
by (simp add: add_assoc[symmetric]) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
1311 |
|
25090 | 1312 |
lemma le_add_right_mono: |
15178 | 1313 |
assumes |
1314 |
"a <= b + (c::'a::pordered_ab_group_add)" |
|
1315 |
"c <= d" |
|
1316 |
shows "a <= b + d" |
|
1317 |
apply (rule_tac order_trans[where y = "b+c"]) |
|
1318 |
apply (simp_all add: prems) |
|
1319 |
done |
|
1320 |
||
1321 |
lemma estimate_by_abs: |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1322 |
"a + b <= (c::'a::lordered_ab_group_add_abs) \<Longrightarrow> a <= c + abs b" |
15178 | 1323 |
proof - |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23389
diff
changeset
|
1324 |
assume "a+b <= c" |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23389
diff
changeset
|
1325 |
hence 2: "a <= c+(-b)" by (simp add: group_simps) |
15178 | 1326 |
have 3: "(-b) <= abs b" by (rule abs_ge_minus_self) |
1327 |
show ?thesis by (rule le_add_right_mono[OF 2 3]) |
|
1328 |
qed |
|
1329 |
||
25090 | 1330 |
subsection {* Tools setup *} |
1331 |
||
25077 | 1332 |
lemma add_mono_thms_ordered_semiring [noatp]: |
1333 |
fixes i j k :: "'a\<Colon>pordered_ab_semigroup_add" |
|
1334 |
shows "i \<le> j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l" |
|
1335 |
and "i = j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l" |
|
1336 |
and "i \<le> j \<and> k = l \<Longrightarrow> i + k \<le> j + l" |
|
1337 |
and "i = j \<and> k = l \<Longrightarrow> i + k = j + l" |
|
1338 |
by (rule add_mono, clarify+)+ |
|
1339 |
||
1340 |
lemma add_mono_thms_ordered_field [noatp]: |
|
1341 |
fixes i j k :: "'a\<Colon>pordered_cancel_ab_semigroup_add" |
|
1342 |
shows "i < j \<and> k = l \<Longrightarrow> i + k < j + l" |
|
1343 |
and "i = j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
1344 |
and "i < j \<and> k \<le> l \<Longrightarrow> i + k < j + l" |
|
1345 |
and "i \<le> j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
1346 |
and "i < j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
1347 |
by (auto intro: add_strict_right_mono add_strict_left_mono |
|
1348 |
add_less_le_mono add_le_less_mono add_strict_mono) |
|
1349 |
||
17085 | 1350 |
text{*Simplification of @{term "x-y < 0"}, etc.*} |
24380
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24286
diff
changeset
|
1351 |
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
|
1352 |
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
|
1353 |
lemmas diff_le_0_iff_le [simp] = le_iff_diff_le_0 [symmetric] |
17085 | 1354 |
|
22482 | 1355 |
ML {* |
1356 |
structure ab_group_add_cancel = Abel_Cancel( |
|
1357 |
struct |
|
1358 |
||
1359 |
(* term order for abelian groups *) |
|
1360 |
||
1361 |
fun agrp_ord (Const (a, _)) = find_index (fn a' => a = a') |
|
22997 | 1362 |
[@{const_name HOL.zero}, @{const_name HOL.plus}, |
1363 |
@{const_name HOL.uminus}, @{const_name HOL.minus}] |
|
22482 | 1364 |
| agrp_ord _ = ~1; |
1365 |
||
1366 |
fun termless_agrp (a, b) = (Term.term_lpo agrp_ord (a, b) = LESS); |
|
1367 |
||
1368 |
local |
|
1369 |
val ac1 = mk_meta_eq @{thm add_assoc}; |
|
1370 |
val ac2 = mk_meta_eq @{thm add_commute}; |
|
1371 |
val ac3 = mk_meta_eq @{thm add_left_commute}; |
|
22997 | 1372 |
fun solve_add_ac thy _ (_ $ (Const (@{const_name HOL.plus},_) $ _ $ _) $ _) = |
22482 | 1373 |
SOME ac1 |
22997 | 1374 |
| solve_add_ac thy _ (_ $ x $ (Const (@{const_name HOL.plus},_) $ y $ z)) = |
22482 | 1375 |
if termless_agrp (y, x) then SOME ac3 else NONE |
1376 |
| solve_add_ac thy _ (_ $ x $ y) = |
|
1377 |
if termless_agrp (y, x) then SOME ac2 else NONE |
|
1378 |
| solve_add_ac thy _ _ = NONE |
|
1379 |
in |
|
1380 |
val add_ac_proc = Simplifier.simproc @{theory} |
|
1381 |
"add_ac_proc" ["x + y::'a::ab_semigroup_add"] solve_add_ac; |
|
1382 |
end; |
|
1383 |
||
1384 |
val cancel_ss = HOL_basic_ss settermless termless_agrp |
|
1385 |
addsimprocs [add_ac_proc] addsimps |
|
23085 | 1386 |
[@{thm add_0_left}, @{thm add_0_right}, @{thm diff_def}, |
22482 | 1387 |
@{thm minus_add_distrib}, @{thm minus_minus}, @{thm minus_zero}, |
1388 |
@{thm right_minus}, @{thm left_minus}, @{thm add_minus_cancel}, |
|
1389 |
@{thm minus_add_cancel}]; |
|
1390 |
||
22548 | 1391 |
val eq_reflection = @{thm eq_reflection}; |
22482 | 1392 |
|
24137
8d7896398147
replaced Theory.self_ref by Theory.check_thy, which now produces a checked ref;
wenzelm
parents:
23879
diff
changeset
|
1393 |
val thy_ref = Theory.check_thy @{theory}; |
22482 | 1394 |
|
25077 | 1395 |
val T = @{typ "'a\<Colon>ab_group_add"}; |
22482 | 1396 |
|
22548 | 1397 |
val eqI_rules = [@{thm less_eqI}, @{thm le_eqI}, @{thm eq_eqI}]; |
22482 | 1398 |
|
1399 |
val dest_eqI = |
|
1400 |
fst o HOLogic.dest_bin "op =" HOLogic.boolT o HOLogic.dest_Trueprop o concl_of; |
|
1401 |
||
1402 |
end); |
|
1403 |
*} |
|
1404 |
||
1405 |
ML_setup {* |
|
1406 |
Addsimprocs [ab_group_add_cancel.sum_conv, ab_group_add_cancel.rel_conv]; |
|
1407 |
*} |
|
17085 | 1408 |
|
14738 | 1409 |
end |