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