1 (* Title: HOL/Group.thy
3 Author: Gertrud Bauer and Markus Wenzel, TU Muenchen
4 Lawrence C Paulson, University of Cambridge
5 Revised and decoupled from Ring_and_Field.thy
6 by Steven Obua, TU Muenchen, in May 2004
7 License: GPL (GNU GENERAL PUBLIC LICENSE)
10 header {* Ordered Groups *}
12 theory OrderedGroup = Inductive + LOrder:
15 The theory of partially ordered groups is taken from the books:
17 \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979
18 \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
20 Most of the used notions can also be looked up in
22 \item \emph{www.mathworld.com} by Eric Weisstein et. al.
23 \item \emph{Algebra I} by van der Waerden, Springer.
27 subsection {* Semigroups, Groups *}
29 axclass semigroup_add \<subseteq> plus
30 add_assoc: "(a + b) + c = a + (b + c)"
32 axclass ab_semigroup_add \<subseteq> semigroup_add
33 add_commute: "a + b = b + a"
35 lemma add_left_commute: "a + (b + c) = b + (a + (c::'a::ab_semigroup_add))"
36 by (rule mk_left_commute [of "op +", OF add_assoc add_commute])
38 theorems add_ac = add_assoc add_commute add_left_commute
40 axclass semigroup_mult \<subseteq> times
41 mult_assoc: "(a * b) * c = a * (b * c)"
43 axclass ab_semigroup_mult \<subseteq> semigroup_mult
44 mult_commute: "a * b = b * a"
46 lemma mult_left_commute: "a * (b * c) = b * (a * (c::'a::ab_semigroup_mult))"
47 by (rule mk_left_commute [of "op *", OF mult_assoc mult_commute])
49 theorems mult_ac = mult_assoc mult_commute mult_left_commute
51 axclass comm_monoid_add \<subseteq> zero, ab_semigroup_add
52 add_0[simp]: "0 + a = a"
54 axclass monoid_mult \<subseteq> one, semigroup_mult
55 mult_1_left[simp]: "1 * a = a"
56 mult_1_right[simp]: "a * 1 = a"
58 axclass comm_monoid_mult \<subseteq> one, ab_semigroup_mult
61 instance comm_monoid_mult \<subseteq> monoid_mult
62 by (intro_classes, insert mult_1, simp_all add: mult_commute, auto)
64 axclass cancel_semigroup_add \<subseteq> semigroup_add
65 add_left_imp_eq: "a + b = a + c \<Longrightarrow> b = c"
66 add_right_imp_eq: "b + a = c + a \<Longrightarrow> b = c"
68 axclass cancel_ab_semigroup_add \<subseteq> ab_semigroup_add
69 add_imp_eq: "a + b = a + c \<Longrightarrow> b = c"
71 instance cancel_ab_semigroup_add \<subseteq> cancel_semigroup_add
75 assume "a + b = a + c"
76 thus "b = c" by (rule add_imp_eq)
80 assume "b + a = c + a"
81 hence "a + b = a + c" by (simp only: add_commute)
82 thus "b = c" by (rule f)
85 axclass ab_group_add \<subseteq> minus, comm_monoid_add
86 left_minus[simp]: " - a + a = 0"
87 diff_minus: "a - b = a + (-b)"
89 instance ab_group_add \<subseteq> cancel_ab_semigroup_add
92 assume "a + b = a + c"
93 hence "-a + a + b = -a + a + c" by (simp only: add_assoc)
97 lemma add_0_right [simp]: "a + 0 = (a::'a::comm_monoid_add)"
99 have "a + 0 = 0 + a" by (simp only: add_commute)
100 also have "... = a" by simp
101 finally show ?thesis .
104 lemma add_left_cancel [simp]:
105 "(a + b = a + c) = (b = (c::'a::cancel_semigroup_add))"
106 by (blast dest: add_left_imp_eq)
108 lemma add_right_cancel [simp]:
109 "(b + a = c + a) = (b = (c::'a::cancel_semigroup_add))"
110 by (blast dest: add_right_imp_eq)
112 lemma right_minus [simp]: "a + -(a::'a::ab_group_add) = 0"
114 have "a + -a = -a + a" by (simp add: add_ac)
115 also have "... = 0" by simp
116 finally show ?thesis .
119 lemma right_minus_eq: "(a - b = 0) = (a = (b::'a::ab_group_add))"
121 have "a = a - b + b" by (simp add: diff_minus add_ac)
122 also assume "a - b = 0"
123 finally show "a = b" by simp
126 thus "a - b = 0" by (simp add: diff_minus)
129 lemma minus_minus [simp]: "- (- (a::'a::ab_group_add)) = a"
130 proof (rule add_left_cancel [of "-a", THEN iffD1])
131 show "(-a + -(-a) = -a + a)"
135 lemma equals_zero_I: "a+b = 0 ==> -a = (b::'a::ab_group_add)"
136 apply (rule right_minus_eq [THEN iffD1, symmetric])
137 apply (simp add: diff_minus add_commute)
140 lemma minus_zero [simp]: "- 0 = (0::'a::ab_group_add)"
141 by (simp add: equals_zero_I)
143 lemma diff_self [simp]: "a - (a::'a::ab_group_add) = 0"
144 by (simp add: diff_minus)
146 lemma diff_0 [simp]: "(0::'a::ab_group_add) - a = -a"
147 by (simp add: diff_minus)
149 lemma diff_0_right [simp]: "a - (0::'a::ab_group_add) = a"
150 by (simp add: diff_minus)
152 lemma diff_minus_eq_add [simp]: "a - - b = a + (b::'a::ab_group_add)"
153 by (simp add: diff_minus)
155 lemma neg_equal_iff_equal [simp]: "(-a = -b) = (a = (b::'a::ab_group_add))"
158 hence "- (- a) = - (- b)"
163 thus "-a = -b" by simp
166 lemma neg_equal_0_iff_equal [simp]: "(-a = 0) = (a = (0::'a::ab_group_add))"
167 by (subst neg_equal_iff_equal [symmetric], simp)
169 lemma neg_0_equal_iff_equal [simp]: "(0 = -a) = (0 = (a::'a::ab_group_add))"
170 by (subst neg_equal_iff_equal [symmetric], simp)
172 text{*The next two equations can make the simplifier loop!*}
174 lemma equation_minus_iff: "(a = - b) = (b = - (a::'a::ab_group_add))"
176 have "(- (-a) = - b) = (- a = b)" by (rule neg_equal_iff_equal)
177 thus ?thesis by (simp add: eq_commute)
180 lemma minus_equation_iff: "(- a = b) = (- (b::'a::ab_group_add) = a)"
182 have "(- a = - (-b)) = (a = -b)" by (rule neg_equal_iff_equal)
183 thus ?thesis by (simp add: eq_commute)
186 lemma minus_add_distrib [simp]: "- (a + b) = -a + -(b::'a::ab_group_add)"
187 apply (rule equals_zero_I)
188 apply (simp add: add_ac)
191 lemma minus_diff_eq [simp]: "- (a - b) = b - (a::'a::ab_group_add)"
192 by (simp add: diff_minus add_commute)
194 subsection {* (Partially) Ordered Groups *}
196 axclass pordered_ab_semigroup_add \<subseteq> order, ab_semigroup_add
197 add_left_mono: "a \<le> b \<Longrightarrow> c + a \<le> c + b"
199 axclass pordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add, cancel_ab_semigroup_add
201 instance pordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add ..
203 axclass pordered_ab_semigroup_add_imp_le \<subseteq> pordered_cancel_ab_semigroup_add
204 add_le_imp_le_left: "c + a \<le> c + b \<Longrightarrow> a \<le> b"
206 axclass pordered_ab_group_add \<subseteq> ab_group_add, pordered_ab_semigroup_add
208 instance pordered_ab_group_add \<subseteq> pordered_ab_semigroup_add_imp_le
211 assume "c + a \<le> c + b"
212 hence "(-c) + (c + a) \<le> (-c) + (c + b)" by (rule add_left_mono)
213 hence "((-c) + c) + a \<le> ((-c) + c) + b" by (simp only: add_assoc)
214 thus "a \<le> b" by simp
217 axclass ordered_cancel_ab_semigroup_add \<subseteq> pordered_cancel_ab_semigroup_add, linorder
219 instance ordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add_imp_le
222 assume le: "c + a <= c + b"
225 assume w: "~ a \<le> b"
226 hence "b <= a" by (simp add: linorder_not_le)
227 hence le2: "c+b <= c+a" by (rule add_left_mono)
231 apply (drule order_antisym, simp_all)
234 by (simp add: linorder_not_le [symmetric])
238 lemma add_right_mono: "a \<le> (b::'a::pordered_ab_semigroup_add) ==> a + c \<le> b + c"
239 by (simp add: add_commute[of _ c] add_left_mono)
241 text {* non-strict, in both arguments *}
243 "[|a \<le> b; c \<le> d|] ==> a + c \<le> b + (d::'a::pordered_ab_semigroup_add)"
244 apply (erule add_right_mono [THEN order_trans])
245 apply (simp add: add_commute add_left_mono)
248 lemma add_strict_left_mono:
249 "a < b ==> c + a < c + (b::'a::pordered_cancel_ab_semigroup_add)"
250 by (simp add: order_less_le add_left_mono)
252 lemma add_strict_right_mono:
253 "a < b ==> a + c < b + (c::'a::pordered_cancel_ab_semigroup_add)"
254 by (simp add: add_commute [of _ c] add_strict_left_mono)
256 text{*Strict monotonicity in both arguments*}
257 lemma add_strict_mono: "[|a<b; c<d|] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)"
258 apply (erule add_strict_right_mono [THEN order_less_trans])
259 apply (erule add_strict_left_mono)
262 lemma add_less_le_mono:
263 "[| a<b; c\<le>d |] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)"
264 apply (erule add_strict_right_mono [THEN order_less_le_trans])
265 apply (erule add_left_mono)
268 lemma add_le_less_mono:
269 "[| a\<le>b; c<d |] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)"
270 apply (erule add_right_mono [THEN order_le_less_trans])
271 apply (erule add_strict_left_mono)
274 lemma add_less_imp_less_left:
275 assumes less: "c + a < c + b" shows "a < (b::'a::pordered_ab_semigroup_add_imp_le)"
277 from less have le: "c + a <= c + b" by (simp add: order_le_less)
280 apply (drule add_le_imp_le_left)
281 by (insert le, drule add_le_imp_le_left, assumption)
282 moreover have "a \<noteq> b"
284 assume "~(a \<noteq> b)"
285 then have "a = b" by simp
286 then have "c + a = c + b" by simp
287 with less show "False"by simp
289 ultimately show "a < b" by (simp add: order_le_less)
292 lemma add_less_imp_less_right:
293 "a + c < b + c ==> a < (b::'a::pordered_ab_semigroup_add_imp_le)"
294 apply (rule add_less_imp_less_left [of c])
295 apply (simp add: add_commute)
298 lemma add_less_cancel_left [simp]:
299 "(c+a < c+b) = (a < (b::'a::pordered_ab_semigroup_add_imp_le))"
300 by (blast intro: add_less_imp_less_left add_strict_left_mono)
302 lemma add_less_cancel_right [simp]:
303 "(a+c < b+c) = (a < (b::'a::pordered_ab_semigroup_add_imp_le))"
304 by (blast intro: add_less_imp_less_right add_strict_right_mono)
306 lemma add_le_cancel_left [simp]:
307 "(c+a \<le> c+b) = (a \<le> (b::'a::pordered_ab_semigroup_add_imp_le))"
308 by (auto, drule add_le_imp_le_left, simp_all add: add_left_mono)
310 lemma add_le_cancel_right [simp]:
311 "(a+c \<le> b+c) = (a \<le> (b::'a::pordered_ab_semigroup_add_imp_le))"
312 by (simp add: add_commute[of a c] add_commute[of b c])
314 lemma add_le_imp_le_right:
315 "a + c \<le> b + c ==> a \<le> (b::'a::pordered_ab_semigroup_add_imp_le)"
318 lemma add_increasing: "[|0\<le>a; b\<le>c|] ==> b \<le> a + (c::'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add})"
319 by (insert add_mono [of 0 a b c], simp)
321 subsection {* Ordering Rules for Unary Minus *}
324 assumes "a \<le> (b::'a::{pordered_ab_semigroup_add_imp_le, ab_group_add})" shows "-b \<le> -a"
326 have "-a+a \<le> -a+b"
327 by (rule add_left_mono)
330 hence "0 + (-b) \<le> (-a + b) + (-b)"
331 by (rule add_right_mono)
333 by (simp add: add_assoc)
336 lemma neg_le_iff_le [simp]: "(-b \<le> -a) = (a \<le> (b::'a::pordered_ab_group_add))"
338 assume "- b \<le> - a"
339 hence "- (- a) \<le> - (- b)"
340 by (rule le_imp_neg_le)
341 thus "a\<le>b" by simp
344 thus "-b \<le> -a" by (rule le_imp_neg_le)
347 lemma neg_le_0_iff_le [simp]: "(-a \<le> 0) = (0 \<le> (a::'a::pordered_ab_group_add))"
348 by (subst neg_le_iff_le [symmetric], simp)
350 lemma neg_0_le_iff_le [simp]: "(0 \<le> -a) = (a \<le> (0::'a::pordered_ab_group_add))"
351 by (subst neg_le_iff_le [symmetric], simp)
353 lemma neg_less_iff_less [simp]: "(-b < -a) = (a < (b::'a::pordered_ab_group_add))"
354 by (force simp add: order_less_le)
356 lemma neg_less_0_iff_less [simp]: "(-a < 0) = (0 < (a::'a::pordered_ab_group_add))"
357 by (subst neg_less_iff_less [symmetric], simp)
359 lemma neg_0_less_iff_less [simp]: "(0 < -a) = (a < (0::'a::pordered_ab_group_add))"
360 by (subst neg_less_iff_less [symmetric], simp)
362 text{*The next several equations can make the simplifier loop!*}
364 lemma less_minus_iff: "(a < - b) = (b < - (a::'a::pordered_ab_group_add))"
366 have "(- (-a) < - b) = (b < - a)" by (rule neg_less_iff_less)
370 lemma minus_less_iff: "(- a < b) = (- b < (a::'a::pordered_ab_group_add))"
372 have "(- a < - (-b)) = (- b < a)" by (rule neg_less_iff_less)
376 lemma le_minus_iff: "(a \<le> - b) = (b \<le> - (a::'a::pordered_ab_group_add))"
378 have mm: "!! a (b::'a). (-(-a)) < -b \<Longrightarrow> -(-b) < -a" by (simp only: minus_less_iff)
379 have "(- (- a) <= -b) = (b <= - a)"
380 apply (auto simp only: order_le_less)
383 apply (drule mm[simplified], assumption)
385 then show ?thesis by simp
388 lemma minus_le_iff: "(- a \<le> b) = (- b \<le> (a::'a::pordered_ab_group_add))"
389 by (auto simp add: order_le_less minus_less_iff)
391 lemma add_diff_eq: "a + (b - c) = (a + b) - (c::'a::ab_group_add)"
392 by (simp add: diff_minus add_ac)
394 lemma diff_add_eq: "(a - b) + c = (a + c) - (b::'a::ab_group_add)"
395 by (simp add: diff_minus add_ac)
397 lemma diff_eq_eq: "(a-b = c) = (a = c + (b::'a::ab_group_add))"
398 by (auto simp add: diff_minus add_assoc)
400 lemma eq_diff_eq: "(a = c-b) = (a + (b::'a::ab_group_add) = c)"
401 by (auto simp add: diff_minus add_assoc)
403 lemma diff_diff_eq: "(a - b) - c = a - (b + (c::'a::ab_group_add))"
404 by (simp add: diff_minus add_ac)
406 lemma diff_diff_eq2: "a - (b - c) = (a + c) - (b::'a::ab_group_add)"
407 by (simp add: diff_minus add_ac)
409 lemma diff_add_cancel: "a - b + b = (a::'a::ab_group_add)"
410 by (simp add: diff_minus add_ac)
412 lemma add_diff_cancel: "a + b - b = (a::'a::ab_group_add)"
413 by (simp add: diff_minus add_ac)
415 text{*Further subtraction laws for ordered rings*}
417 lemma less_iff_diff_less_0: "(a < b) = (a - b < (0::'a::pordered_ab_group_add))"
419 have "(a < b) = (a + (- b) < b + (-b))"
420 by (simp only: add_less_cancel_right)
421 also have "... = (a - b < 0)" by (simp add: diff_minus)
422 finally show ?thesis .
425 lemma diff_less_eq: "(a-b < c) = (a < c + (b::'a::pordered_ab_group_add))"
426 apply (subst less_iff_diff_less_0)
427 apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst])
428 apply (simp add: diff_minus add_ac)
431 lemma less_diff_eq: "(a < c-b) = (a + (b::'a::pordered_ab_group_add) < c)"
432 apply (subst less_iff_diff_less_0)
433 apply (rule less_iff_diff_less_0 [of _ "c-b", THEN ssubst])
434 apply (simp add: diff_minus add_ac)
437 lemma diff_le_eq: "(a-b \<le> c) = (a \<le> c + (b::'a::pordered_ab_group_add))"
438 by (auto simp add: order_le_less diff_less_eq diff_add_cancel add_diff_cancel)
440 lemma le_diff_eq: "(a \<le> c-b) = (a + (b::'a::pordered_ab_group_add) \<le> c)"
441 by (auto simp add: order_le_less less_diff_eq diff_add_cancel add_diff_cancel)
443 text{*This list of rewrites simplifies (in)equalities by bringing subtractions
444 to the top and then moving negative terms to the other side.
445 Use with @{text add_ac}*}
447 diff_minus [symmetric]
448 add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2
449 diff_less_eq less_diff_eq diff_le_eq le_diff_eq
450 diff_eq_eq eq_diff_eq
453 subsection{*Lemmas for the @{text cancel_numerals} simproc*}
455 lemma eq_iff_diff_eq_0: "(a = b) = (a-b = (0::'a::ab_group_add))"
456 by (simp add: compare_rls)
458 lemma le_iff_diff_le_0: "(a \<le> b) = (a-b \<le> (0::'a::pordered_ab_group_add))"
459 by (simp add: compare_rls)
461 subsection {* Lattice Ordered (Abelian) Groups *}
463 axclass lordered_ab_group_meet < pordered_ab_group_add, meet_semilorder
465 axclass lordered_ab_group_join < pordered_ab_group_add, join_semilorder
467 lemma add_meet_distrib_left: "a + (meet b c) = meet (a + b) (a + (c::'a::{pordered_ab_group_add, meet_semilorder}))"
468 apply (rule order_antisym)
469 apply (rule meet_imp_le, simp_all add: meet_join_le)
470 apply (rule add_le_imp_le_left [of "-a"])
471 apply (simp only: add_assoc[symmetric], simp)
472 apply (rule meet_imp_le)
473 apply (rule add_le_imp_le_left[of "a"], simp only: add_assoc[symmetric], simp add: meet_join_le)+
476 lemma add_join_distrib_left: "a + (join b c) = join (a + b) (a+ (c::'a::{pordered_ab_group_add, join_semilorder}))"
477 apply (rule order_antisym)
478 apply (rule add_le_imp_le_left [of "-a"])
479 apply (simp only: add_assoc[symmetric], simp)
480 apply (rule join_imp_le)
481 apply (rule add_le_imp_le_left [of "a"], simp only: add_assoc[symmetric], simp add: meet_join_le)+
482 apply (rule join_imp_le)
483 apply (simp_all add: meet_join_le)
486 lemma is_join_neg_meet: "is_join (% (a::'a::{pordered_ab_group_add, meet_semilorder}) b. - (meet (-a) (-b)))"
487 apply (auto simp add: is_join_def)
488 apply (rule_tac c="meet (-a) (-b)" in add_le_imp_le_right, simp, simp add: add_meet_distrib_left meet_join_le)
489 apply (rule_tac c="meet (-a) (-b)" in add_le_imp_le_right, simp, simp add: add_meet_distrib_left meet_join_le)
490 apply (subst neg_le_iff_le[symmetric])
491 apply (simp add: meet_imp_le)
494 lemma is_meet_neg_join: "is_meet (% (a::'a::{pordered_ab_group_add, join_semilorder}) b. - (join (-a) (-b)))"
495 apply (auto simp add: is_meet_def)
496 apply (rule_tac c="join (-a) (-b)" in add_le_imp_le_right, simp, simp add: add_join_distrib_left meet_join_le)
497 apply (rule_tac c="join (-a) (-b)" in add_le_imp_le_right, simp, simp add: add_join_distrib_left meet_join_le)
498 apply (subst neg_le_iff_le[symmetric])
499 apply (simp add: join_imp_le)
502 axclass lordered_ab_group \<subseteq> pordered_ab_group_add, lorder
504 instance lordered_ab_group_meet \<subseteq> lordered_ab_group
506 show "? j. is_join (j::'a\<Rightarrow>'a\<Rightarrow>('a::lordered_ab_group_meet))" by (blast intro: is_join_neg_meet)
509 instance lordered_ab_group_join \<subseteq> lordered_ab_group
511 show "? m. is_meet (m::'a\<Rightarrow>'a\<Rightarrow>('a::lordered_ab_group_join))" by (blast intro: is_meet_neg_join)
514 lemma add_join_distrib_right: "(join a b) + (c::'a::lordered_ab_group) = join (a+c) (b+c)"
516 have "c + (join a b) = join (c+a) (c+b)" by (simp add: add_join_distrib_left)
517 thus ?thesis by (simp add: add_commute)
520 lemma add_meet_distrib_right: "(meet a b) + (c::'a::lordered_ab_group) = meet (a+c) (b+c)"
522 have "c + (meet a b) = meet (c+a) (c+b)" by (simp add: add_meet_distrib_left)
523 thus ?thesis by (simp add: add_commute)
526 lemmas add_meet_join_distribs = add_meet_distrib_right add_meet_distrib_left add_join_distrib_right add_join_distrib_left
528 lemma join_eq_neg_meet: "join a (b::'a::lordered_ab_group) = - meet (-a) (-b)"
529 by (simp add: is_join_unique[OF is_join_join is_join_neg_meet])
531 lemma meet_eq_neg_join: "meet a (b::'a::lordered_ab_group) = - join (-a) (-b)"
532 by (simp add: is_meet_unique[OF is_meet_meet is_meet_neg_join])
534 lemma add_eq_meet_join: "a + b = (join a b) + (meet a (b::'a::lordered_ab_group))"
536 have "0 = - meet 0 (a-b) + meet (a-b) 0" by (simp add: meet_comm)
537 hence "0 = join 0 (b-a) + meet (a-b) 0" by (simp add: meet_eq_neg_join)
538 hence "0 = (-a + join a b) + (meet a b + (-b))"
539 apply (simp add: add_join_distrib_left add_meet_distrib_right)
540 by (simp add: diff_minus add_commute)
542 apply (simp add: compare_rls)
543 apply (subst add_left_cancel[symmetric, of "a+b" "join a b + meet a b" "-a"])
544 apply (simp only: add_assoc, simp add: add_assoc[symmetric])
548 subsection {* Positive Part, Negative Part, Absolute Value *}
551 pprt :: "'a \<Rightarrow> ('a::lordered_ab_group)"
553 nprt :: "'a \<Rightarrow> ('a::lordered_ab_group)"
556 lemma prts: "a = pprt a + nprt a"
557 by (simp add: pprt_def nprt_def add_eq_meet_join[symmetric])
559 lemma zero_le_pprt[simp]: "0 \<le> pprt a"
560 by (simp add: pprt_def meet_join_le)
562 lemma nprt_le_zero[simp]: "nprt a \<le> 0"
563 by (simp add: nprt_def meet_join_le)
565 lemma le_eq_neg: "(a \<le> -b) = (a + b \<le> (0::_::lordered_ab_group))" (is "?l = ?r")
567 have a: "?l \<longrightarrow> ?r"
569 apply (rule add_le_imp_le_right[of _ "-b" _])
570 apply (simp add: add_assoc)
572 have b: "?r \<longrightarrow> ?l"
574 apply (rule add_le_imp_le_right[of _ "b" _])
577 from a b show ?thesis by blast
580 lemma join_0_imp_0: "join a (-a) = 0 \<Longrightarrow> a = (0::'a::lordered_ab_group)"
584 assume hyp: "join a (-a) = 0"
585 hence "join a (-a) + a = a" by (simp)
586 hence "join (a+a) 0 = a" by (simp add: add_join_distrib_right)
587 hence "join (a+a) 0 <= a" by (simp)
588 hence "0 <= a" by (blast intro: order_trans meet_join_le)
592 assume hyp:"join a (-a) = 0"
593 hence hyp2:"join (-a) (-(-a)) = 0" by (simp add: join_comm)
594 from p[OF hyp] p[OF hyp2] show "a = 0" by simp
597 lemma meet_0_imp_0: "meet a (-a) = 0 \<Longrightarrow> a = (0::'a::lordered_ab_group)"
598 apply (simp add: meet_eq_neg_join)
599 apply (simp add: join_comm)
600 apply (subst join_0_imp_0)
603 lemma join_0_eq_0[simp]: "(join a (-a) = 0) = (a = (0::'a::lordered_ab_group))"
604 by (auto, erule join_0_imp_0)
606 lemma meet_0_eq_0[simp]: "(meet a (-a) = 0) = (a = (0::'a::lordered_ab_group))"
607 by (auto, erule meet_0_imp_0)
609 lemma zero_le_double_add_iff_zero_le_single_add[simp]: "(0 \<le> a + a) = (0 \<le> (a::'a::lordered_ab_group))"
612 hence a:"meet (a+a) 0 = 0" by (simp add: le_def_meet meet_comm)
613 have "(meet a 0)+(meet a 0) = meet (meet (a+a) 0) a" (is "?l=_") by (simp add: add_meet_join_distribs meet_aci)
614 hence "?l = 0 + meet a 0" by (simp add: a, simp add: meet_comm)
615 hence "meet a 0 = 0" by (simp only: add_right_cancel)
616 then show "0 <= a" by (simp add: le_def_meet meet_comm)
619 show "0 <= a + a" by (simp add: add_mono[OF a a, simplified])
622 lemma double_add_le_zero_iff_single_add_le_zero[simp]: "(a + a <= 0) = ((a::'a::lordered_ab_group) <= 0)"
624 have "(a + a <= 0) = (0 <= -(a+a))" by (subst le_minus_iff, simp)
625 moreover have "\<dots> = (a <= 0)" by (simp add: zero_le_double_add_iff_zero_le_single_add)
626 ultimately show ?thesis by blast
629 lemma double_add_less_zero_iff_single_less_zero[simp]: "(a+a<0) = ((a::'a::{pordered_ab_group_add,linorder}) < 0)" (is ?s)
632 thus ?s by (simp add: add_strict_mono[OF a a, simplified])
635 hence a:"0 <= a" by (simp)
636 hence "0 <= a+a" by (simp add: add_mono[OF a a, simplified])
637 hence "~(a+a < 0)" by simp
638 with a show ?thesis by simp
641 axclass lordered_ab_group_abs \<subseteq> lordered_ab_group
642 abs_lattice: "abs x = join x (-x)"
644 lemma abs_zero[simp]: "abs 0 = (0::'a::lordered_ab_group_abs)"
645 by (simp add: abs_lattice)
647 lemma abs_eq_0[simp]: "(abs a = 0) = (a = (0::'a::lordered_ab_group_abs))"
648 by (simp add: abs_lattice)
650 lemma abs_0_eq[simp]: "(0 = abs a) = (a = (0::'a::lordered_ab_group_abs))"
652 have "(0 = abs a) = (abs a = 0)" by (simp only: eq_ac)
656 lemma neg_meet_eq_join[simp]: "- meet a (b::_::lordered_ab_group) = join (-a) (-b)"
657 by (simp add: meet_eq_neg_join)
659 lemma neg_join_eq_meet[simp]: "- join a (b::_::lordered_ab_group) = meet (-a) (-b)"
660 by (simp del: neg_meet_eq_join add: join_eq_neg_meet)
662 lemma join_eq_if: "join a (-a) = (if a < 0 then -a else (a::'a::{lordered_ab_group, linorder}))"
664 note b = add_le_cancel_right[of a a "-a",symmetric,simplified]
665 have c: "a + a = 0 \<Longrightarrow> -a = a" by (rule add_right_imp_eq[of _ a], simp)
667 apply (auto simp add: join_max max_def b linorder_not_less)
668 apply (drule order_antisym, auto)
672 lemma abs_if_lattice: "\<bar>a\<bar> = (if a < 0 then -a else (a::'a::{lordered_ab_group_abs, linorder}))"
674 show ?thesis by (simp add: abs_lattice join_eq_if)
677 lemma abs_ge_zero[simp]: "0 \<le> abs (a::'a::lordered_ab_group_abs)"
679 have a:"a <= abs a" and b:"-a <= abs a" by (auto simp add: abs_lattice meet_join_le)
680 show ?thesis by (rule add_mono[OF a b, simplified])
683 lemma abs_le_zero_iff [simp]: "(abs a \<le> (0::'a::lordered_ab_group_abs)) = (a = 0)"
686 hence "abs a = 0" by (auto dest: order_antisym)
690 thus "abs a <= 0" by simp
693 lemma zero_less_abs_iff [simp]: "(0 < abs a) = (a \<noteq> (0::'a::lordered_ab_group_abs))"
694 by (simp add: order_less_le)
696 lemma abs_not_less_zero [simp]: "~ abs a < (0::'a::lordered_ab_group_abs)"
698 have a:"!! x (y::_::order). x <= y \<Longrightarrow> ~(y < x)" by auto
699 show ?thesis by (simp add: a)
702 lemma abs_ge_self: "a \<le> abs (a::'a::lordered_ab_group_abs)"
703 by (simp add: abs_lattice meet_join_le)
705 lemma abs_ge_minus_self: "-a \<le> abs (a::'a::lordered_ab_group_abs)"
706 by (simp add: abs_lattice meet_join_le)
708 lemma le_imp_join_eq: "a \<le> b \<Longrightarrow> join a b = b"
709 by (simp add: le_def_join)
711 lemma ge_imp_join_eq: "b \<le> a \<Longrightarrow> join a b = a"
712 by (simp add: le_def_join join_aci)
714 lemma le_imp_meet_eq: "a \<le> b \<Longrightarrow> meet a b = a"
715 by (simp add: le_def_meet)
717 lemma ge_imp_meet_eq: "b \<le> a \<Longrightarrow> meet a b = b"
718 by (simp add: le_def_meet meet_aci)
720 lemma abs_prts: "abs (a::_::lordered_ab_group_abs) = pprt a - nprt a"
721 apply (simp add: pprt_def nprt_def diff_minus)
722 apply (simp add: add_meet_join_distribs join_aci abs_lattice[symmetric])
723 apply (subst le_imp_join_eq, auto)
726 lemma abs_minus_cancel [simp]: "abs (-a) = abs(a::'a::lordered_ab_group_abs)"
727 by (simp add: abs_lattice join_comm)
729 lemma abs_idempotent [simp]: "abs (abs a) = abs (a::'a::lordered_ab_group_abs)"
730 apply (simp add: abs_lattice[of "abs a"])
731 apply (subst ge_imp_join_eq)
732 apply (rule order_trans[of _ 0])
735 lemma zero_le_iff_zero_nprt: "(0 \<le> a) = (nprt a = 0)"
736 by (simp add: le_def_meet nprt_def meet_comm)
738 lemma le_zero_iff_zero_pprt: "(a \<le> 0) = (pprt a = 0)"
739 by (simp add: le_def_join pprt_def join_comm)
741 lemma le_zero_iff_pprt_id: "(0 \<le> a) = (pprt a = a)"
742 by (simp add: le_def_join pprt_def join_comm)
744 lemma zero_le_iff_nprt_id: "(a \<le> 0) = (nprt a = a)"
745 by (simp add: le_def_meet nprt_def meet_comm)
747 lemma iff2imp: "(A=B) \<Longrightarrow> (A \<Longrightarrow> B)"
750 lemma imp_abs_id: "0 \<le> a \<Longrightarrow> abs a = (a::'a::lordered_ab_group_abs)"
751 by (simp add: iff2imp[OF zero_le_iff_zero_nprt] iff2imp[OF le_zero_iff_pprt_id] abs_prts)
753 lemma imp_abs_neg_id: "a \<le> 0 \<Longrightarrow> abs a = -(a::'a::lordered_ab_group_abs)"
754 by (simp add: iff2imp[OF le_zero_iff_zero_pprt] iff2imp[OF zero_le_iff_nprt_id] abs_prts)
756 lemma abs_leI: "[|a \<le> b; -a \<le> b|] ==> abs a \<le> (b::'a::lordered_ab_group_abs)"
757 by (simp add: abs_lattice join_imp_le)
759 lemma le_minus_self_iff: "(a \<le> -a) = (a \<le> (0::'a::lordered_ab_group))"
761 from add_le_cancel_left[of "-a" "a+a" "0"] have "(a <= -a) = (a+a <= 0)"
762 by (simp add: add_assoc[symmetric])
766 lemma minus_le_self_iff: "(-a \<le> a) = (0 \<le> (a::'a::lordered_ab_group))"
768 from add_le_cancel_left[of "-a" "0" "a+a"] have "(-a <= a) = (0 <= a+a)"
769 by (simp add: add_assoc[symmetric])
773 lemma abs_le_D1: "abs a \<le> b ==> a \<le> (b::'a::lordered_ab_group_abs)"
774 by (insert abs_ge_self, blast intro: order_trans)
776 lemma abs_le_D2: "abs a \<le> b ==> -a \<le> (b::'a::lordered_ab_group_abs)"
777 by (insert abs_le_D1 [of "-a"], simp)
779 lemma abs_le_iff: "(abs a \<le> b) = (a \<le> b & -a \<le> (b::'a::lordered_ab_group_abs))"
780 by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2)
782 lemma abs_triangle_ineq: "abs (a+b) \<le> abs a + abs (b::'a::lordered_ab_group_abs)"
784 have g:"abs a + abs b = join (a+b) (join (-a-b) (join (-a+b) (a + (-b))))" (is "_=join ?m ?n")
785 apply (simp add: abs_lattice add_meet_join_distribs join_aci)
786 by (simp only: diff_minus)
787 have a:"a+b <= join ?m ?n" by (simp add: meet_join_le)
788 have b:"-a-b <= ?n" by (simp add: meet_join_le)
789 have c:"?n <= join ?m ?n" by (simp add: meet_join_le)
790 from b c have d: "-a-b <= join ?m ?n" by simp
791 have e:"-a-b = -(a+b)" by (simp add: diff_minus)
792 from a d e have "abs(a+b) <= join ?m ?n"
793 by (drule_tac abs_leI, auto)
794 with g[symmetric] show ?thesis by simp
797 lemma abs_diff_triangle_ineq:
798 "\<bar>(a::'a::lordered_ab_group_abs) + b - (c+d)\<bar> \<le> \<bar>a-c\<bar> + \<bar>b-d\<bar>"
800 have "\<bar>a + b - (c+d)\<bar> = \<bar>(a-c) + (b-d)\<bar>" by (simp add: diff_minus add_ac)
801 also have "... \<le> \<bar>a-c\<bar> + \<bar>b-d\<bar>" by (rule abs_triangle_ineq)
802 finally show ?thesis .
806 val add_zero_left = thm"add_0";
807 val add_zero_right = thm"add_0_right";
811 val add_assoc = thm "add_assoc";
812 val add_commute = thm "add_commute";
813 val add_left_commute = thm "add_left_commute";
814 val add_ac = thms "add_ac";
815 val mult_assoc = thm "mult_assoc";
816 val mult_commute = thm "mult_commute";
817 val mult_left_commute = thm "mult_left_commute";
818 val mult_ac = thms "mult_ac";
819 val add_0 = thm "add_0";
820 val mult_1_left = thm "mult_1_left";
821 val mult_1_right = thm "mult_1_right";
822 val mult_1 = thm "mult_1";
823 val add_left_imp_eq = thm "add_left_imp_eq";
824 val add_right_imp_eq = thm "add_right_imp_eq";
825 val add_imp_eq = thm "add_imp_eq";
826 val left_minus = thm "left_minus";
827 val diff_minus = thm "diff_minus";
828 val add_0_right = thm "add_0_right";
829 val add_left_cancel = thm "add_left_cancel";
830 val add_right_cancel = thm "add_right_cancel";
831 val right_minus = thm "right_minus";
832 val right_minus_eq = thm "right_minus_eq";
833 val minus_minus = thm "minus_minus";
834 val equals_zero_I = thm "equals_zero_I";
835 val minus_zero = thm "minus_zero";
836 val diff_self = thm "diff_self";
837 val diff_0 = thm "diff_0";
838 val diff_0_right = thm "diff_0_right";
839 val diff_minus_eq_add = thm "diff_minus_eq_add";
840 val neg_equal_iff_equal = thm "neg_equal_iff_equal";
841 val neg_equal_0_iff_equal = thm "neg_equal_0_iff_equal";
842 val neg_0_equal_iff_equal = thm "neg_0_equal_iff_equal";
843 val equation_minus_iff = thm "equation_minus_iff";
844 val minus_equation_iff = thm "minus_equation_iff";
845 val minus_add_distrib = thm "minus_add_distrib";
846 val minus_diff_eq = thm "minus_diff_eq";
847 val add_left_mono = thm "add_left_mono";
848 val add_le_imp_le_left = thm "add_le_imp_le_left";
849 val add_right_mono = thm "add_right_mono";
850 val add_mono = thm "add_mono";
851 val add_strict_left_mono = thm "add_strict_left_mono";
852 val add_strict_right_mono = thm "add_strict_right_mono";
853 val add_strict_mono = thm "add_strict_mono";
854 val add_less_le_mono = thm "add_less_le_mono";
855 val add_le_less_mono = thm "add_le_less_mono";
856 val add_less_imp_less_left = thm "add_less_imp_less_left";
857 val add_less_imp_less_right = thm "add_less_imp_less_right";
858 val add_less_cancel_left = thm "add_less_cancel_left";
859 val add_less_cancel_right = thm "add_less_cancel_right";
860 val add_le_cancel_left = thm "add_le_cancel_left";
861 val add_le_cancel_right = thm "add_le_cancel_right";
862 val add_le_imp_le_right = thm "add_le_imp_le_right";
863 val add_increasing = thm "add_increasing";
864 val le_imp_neg_le = thm "le_imp_neg_le";
865 val neg_le_iff_le = thm "neg_le_iff_le";
866 val neg_le_0_iff_le = thm "neg_le_0_iff_le";
867 val neg_0_le_iff_le = thm "neg_0_le_iff_le";
868 val neg_less_iff_less = thm "neg_less_iff_less";
869 val neg_less_0_iff_less = thm "neg_less_0_iff_less";
870 val neg_0_less_iff_less = thm "neg_0_less_iff_less";
871 val less_minus_iff = thm "less_minus_iff";
872 val minus_less_iff = thm "minus_less_iff";
873 val le_minus_iff = thm "le_minus_iff";
874 val minus_le_iff = thm "minus_le_iff";
875 val add_diff_eq = thm "add_diff_eq";
876 val diff_add_eq = thm "diff_add_eq";
877 val diff_eq_eq = thm "diff_eq_eq";
878 val eq_diff_eq = thm "eq_diff_eq";
879 val diff_diff_eq = thm "diff_diff_eq";
880 val diff_diff_eq2 = thm "diff_diff_eq2";
881 val diff_add_cancel = thm "diff_add_cancel";
882 val add_diff_cancel = thm "add_diff_cancel";
883 val less_iff_diff_less_0 = thm "less_iff_diff_less_0";
884 val diff_less_eq = thm "diff_less_eq";
885 val less_diff_eq = thm "less_diff_eq";
886 val diff_le_eq = thm "diff_le_eq";
887 val le_diff_eq = thm "le_diff_eq";
888 val compare_rls = thms "compare_rls";
889 val eq_iff_diff_eq_0 = thm "eq_iff_diff_eq_0";
890 val le_iff_diff_le_0 = thm "le_iff_diff_le_0";
891 val add_meet_distrib_left = thm "add_meet_distrib_left";
892 val add_join_distrib_left = thm "add_join_distrib_left";
893 val is_join_neg_meet = thm "is_join_neg_meet";
894 val is_meet_neg_join = thm "is_meet_neg_join";
895 val add_join_distrib_right = thm "add_join_distrib_right";
896 val add_meet_distrib_right = thm "add_meet_distrib_right";
897 val add_meet_join_distribs = thms "add_meet_join_distribs";
898 val join_eq_neg_meet = thm "join_eq_neg_meet";
899 val meet_eq_neg_join = thm "meet_eq_neg_join";
900 val add_eq_meet_join = thm "add_eq_meet_join";
901 val prts = thm "prts";
902 val zero_le_pprt = thm "zero_le_pprt";
903 val nprt_le_zero = thm "nprt_le_zero";
904 val le_eq_neg = thm "le_eq_neg";
905 val join_0_imp_0 = thm "join_0_imp_0";
906 val meet_0_imp_0 = thm "meet_0_imp_0";
907 val join_0_eq_0 = thm "join_0_eq_0";
908 val meet_0_eq_0 = thm "meet_0_eq_0";
909 val zero_le_double_add_iff_zero_le_single_add = thm "zero_le_double_add_iff_zero_le_single_add";
910 val double_add_le_zero_iff_single_add_le_zero = thm "double_add_le_zero_iff_single_add_le_zero";
911 val double_add_less_zero_iff_single_less_zero = thm "double_add_less_zero_iff_single_less_zero";
912 val abs_lattice = thm "abs_lattice";
913 val abs_zero = thm "abs_zero";
914 val abs_eq_0 = thm "abs_eq_0";
915 val abs_0_eq = thm "abs_0_eq";
916 val neg_meet_eq_join = thm "neg_meet_eq_join";
917 val neg_join_eq_meet = thm "neg_join_eq_meet";
918 val join_eq_if = thm "join_eq_if";
919 val abs_if_lattice = thm "abs_if_lattice";
920 val abs_ge_zero = thm "abs_ge_zero";
921 val abs_le_zero_iff = thm "abs_le_zero_iff";
922 val zero_less_abs_iff = thm "zero_less_abs_iff";
923 val abs_not_less_zero = thm "abs_not_less_zero";
924 val abs_ge_self = thm "abs_ge_self";
925 val abs_ge_minus_self = thm "abs_ge_minus_self";
926 val le_imp_join_eq = thm "le_imp_join_eq";
927 val ge_imp_join_eq = thm "ge_imp_join_eq";
928 val le_imp_meet_eq = thm "le_imp_meet_eq";
929 val ge_imp_meet_eq = thm "ge_imp_meet_eq";
930 val abs_prts = thm "abs_prts";
931 val abs_minus_cancel = thm "abs_minus_cancel";
932 val abs_idempotent = thm "abs_idempotent";
933 val zero_le_iff_zero_nprt = thm "zero_le_iff_zero_nprt";
934 val le_zero_iff_zero_pprt = thm "le_zero_iff_zero_pprt";
935 val le_zero_iff_pprt_id = thm "le_zero_iff_pprt_id";
936 val zero_le_iff_nprt_id = thm "zero_le_iff_nprt_id";
937 val iff2imp = thm "iff2imp";
938 val imp_abs_id = thm "imp_abs_id";
939 val imp_abs_neg_id = thm "imp_abs_neg_id";
940 val abs_leI = thm "abs_leI";
941 val le_minus_self_iff = thm "le_minus_self_iff";
942 val minus_le_self_iff = thm "minus_le_self_iff";
943 val abs_le_D1 = thm "abs_le_D1";
944 val abs_le_D2 = thm "abs_le_D2";
945 val abs_le_iff = thm "abs_le_iff";
946 val abs_triangle_ineq = thm "abs_triangle_ineq";
947 val abs_diff_triangle_ineq = thm "abs_diff_triangle_ineq";