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