author  haftmann 
Fri, 02 Mar 2007 15:43:21 +0100  
changeset 22390  378f34b1e380 
parent 21382  d71aed9286d3 
child 22422  ee19cdb07528 
permissions  rwrr 
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 
21382  10 
imports LOrder 
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 

27 
subsection {* Semigroups, Groups *} 

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 

22390  51 
class comm_monoid_add = zero + ab_semigroup_add + 
52 
assumes add_0 [simp]: "\<^loc>0 \<^loc>+ a = a" 

14738  53 

22390  54 
class monoid_mult = one + semigroup_mult + 
55 
assumes mult_1_left [simp]: "\<^loc>1 \<^loc>* a = a" 

56 
assumes mult_1_right [simp]: "a \<^loc>* \<^loc>1 = a" 

14738  57 

22390  58 
class comm_monoid_mult = one + ab_semigroup_mult + 
59 
assumes mult_1: "\<^loc>1 \<^loc>* a = a" 

14738  60 

61 
instance comm_monoid_mult \<subseteq> monoid_mult 

22390  62 
by intro_classes (insert mult_1, simp_all add: mult_commute, auto) 
14738  63 

22390  64 
class cancel_semigroup_add = semigroup_add + 
65 
assumes add_left_imp_eq: "a \<^loc>+ b = a \<^loc>+ c \<Longrightarrow> b = c" 

66 
assumes add_right_imp_eq: "b \<^loc>+ a = c \<^loc>+ a \<Longrightarrow> b = c" 

14738  67 

22390  68 
class cancel_ab_semigroup_add = ab_semigroup_add + 
69 
assumes add_imp_eq: "a \<^loc>+ b = a \<^loc>+ c \<Longrightarrow> b = c" 

14738  70 

71 
instance cancel_ab_semigroup_add \<subseteq> cancel_semigroup_add 

22390  72 
proof intro_classes 
73 
fix a b c :: 'a 

74 
assume "a + b = a + c" 

75 
then show "b = c" by (rule add_imp_eq) 

76 
next 

14738  77 
fix a b c :: 'a 
78 
assume "b + a = c + a" 

22390  79 
then have "a + b = a + c" by (simp only: add_commute) 
80 
then show "b = c" by (rule add_imp_eq) 

14738  81 
qed 
82 

22390  83 
class ab_group_add = minus + comm_monoid_add + 
84 
assumes left_minus [simp]: "uminus a \<^loc>+ a = \<^loc>0" 

85 
assumes diff_minus: "a \<^loc> b = a \<^loc>+ (uminus b)" 

14738  86 

87 
instance ab_group_add \<subseteq> cancel_ab_semigroup_add 

22390  88 
proof intro_classes 
14738  89 
fix a b c :: 'a 
90 
assume "a + b = a + c" 

22390  91 
then have "uminus a + a + b = uminus a + a + c" unfolding add_assoc by simp 
92 
then show "b = c" by simp 

14738  93 
qed 
94 

95 
lemma add_0_right [simp]: "a + 0 = (a::'a::comm_monoid_add)" 

96 
proof  

97 
have "a + 0 = 0 + a" by (simp only: add_commute) 

98 
also have "... = a" by simp 

99 
finally show ?thesis . 

100 
qed 

101 

21245  102 
lemmas add_zero_left = add_0 
103 
and add_zero_right = add_0_right 

104 

14738  105 
lemma add_left_cancel [simp]: 
22390  106 
"a + b = a + c \<longleftrightarrow> b = (c \<Colon> 'a\<Colon>cancel_semigroup_add)" 
107 
by (blast dest: add_left_imp_eq) 

14738  108 

109 
lemma add_right_cancel [simp]: 

22390  110 
"b + a = c + a \<longleftrightarrow> b = (c \<Colon> 'a\<Colon>cancel_semigroup_add)" 
14738  111 
by (blast dest: add_right_imp_eq) 
112 

113 
lemma right_minus [simp]: "a + (a::'a::ab_group_add) = 0" 

114 
proof  

115 
have "a + a = a + a" by (simp add: add_ac) 

116 
also have "... = 0" by simp 

117 
finally show ?thesis . 

118 
qed 

119 

120 
lemma right_minus_eq: "(a  b = 0) = (a = (b::'a::ab_group_add))" 

121 
proof 

122 
have "a = a  b + b" by (simp add: diff_minus add_ac) 

123 
also assume "a  b = 0" 

124 
finally show "a = b" by simp 

125 
next 

126 
assume "a = b" 

127 
thus "a  b = 0" by (simp add: diff_minus) 

128 
qed 

129 

130 
lemma minus_minus [simp]: " ( (a::'a::ab_group_add)) = a" 

131 
proof (rule add_left_cancel [of "a", THEN iffD1]) 

132 
show "(a + (a) = a + a)" 

133 
by simp 

134 
qed 

135 

136 
lemma equals_zero_I: "a+b = 0 ==> a = (b::'a::ab_group_add)" 

137 
apply (rule right_minus_eq [THEN iffD1, symmetric]) 

138 
apply (simp add: diff_minus add_commute) 

139 
done 

140 

141 
lemma minus_zero [simp]: " 0 = (0::'a::ab_group_add)" 

142 
by (simp add: equals_zero_I) 

143 

144 
lemma diff_self [simp]: "a  (a::'a::ab_group_add) = 0" 

145 
by (simp add: diff_minus) 

146 

147 
lemma diff_0 [simp]: "(0::'a::ab_group_add)  a = a" 

148 
by (simp add: diff_minus) 

149 

150 
lemma diff_0_right [simp]: "a  (0::'a::ab_group_add) = a" 

151 
by (simp add: diff_minus) 

152 

153 
lemma diff_minus_eq_add [simp]: "a   b = a + (b::'a::ab_group_add)" 

154 
by (simp add: diff_minus) 

155 

156 
lemma neg_equal_iff_equal [simp]: "(a = b) = (a = (b::'a::ab_group_add))" 

157 
proof 

158 
assume " a =  b" 

159 
hence " ( a) =  ( b)" 

160 
by simp 

161 
thus "a=b" by simp 

162 
next 

163 
assume "a=b" 

164 
thus "a = b" by simp 

165 
qed 

166 

167 
lemma neg_equal_0_iff_equal [simp]: "(a = 0) = (a = (0::'a::ab_group_add))" 

168 
by (subst neg_equal_iff_equal [symmetric], simp) 

169 

170 
lemma neg_0_equal_iff_equal [simp]: "(0 = a) = (0 = (a::'a::ab_group_add))" 

171 
by (subst neg_equal_iff_equal [symmetric], simp) 

172 

173 
text{*The next two equations can make the simplifier loop!*} 

174 

175 
lemma equation_minus_iff: "(a =  b) = (b =  (a::'a::ab_group_add))" 

176 
proof  

177 
have "( (a) =  b) = ( a = b)" by (rule neg_equal_iff_equal) 

178 
thus ?thesis by (simp add: eq_commute) 

179 
qed 

180 

181 
lemma minus_equation_iff: "( a = b) = ( (b::'a::ab_group_add) = a)" 

182 
proof  

183 
have "( a =  (b)) = (a = b)" by (rule neg_equal_iff_equal) 

184 
thus ?thesis by (simp add: eq_commute) 

185 
qed 

186 

187 
lemma minus_add_distrib [simp]: " (a + b) = a + (b::'a::ab_group_add)" 

188 
apply (rule equals_zero_I) 

189 
apply (simp add: add_ac) 

190 
done 

191 

192 
lemma minus_diff_eq [simp]: " (a  b) = b  (a::'a::ab_group_add)" 

193 
by (simp add: diff_minus add_commute) 

194 

195 
subsection {* (Partially) Ordered Groups *} 

196 

22390  197 
class pordered_ab_semigroup_add = order + ab_semigroup_add + 
198 
assumes add_left_mono: "a \<sqsubseteq> b \<Longrightarrow> c \<^loc>+ a \<sqsubseteq> c \<^loc>+ b" 

14738  199 

22390  200 
class pordered_cancel_ab_semigroup_add = 
201 
pordered_ab_semigroup_add + cancel_ab_semigroup_add 

14738  202 

203 
instance pordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add .. 

204 

22390  205 
class pordered_ab_semigroup_add_imp_le = pordered_cancel_ab_semigroup_add + 
206 
assumes add_le_imp_le_left: "c \<^loc>+ a \<sqsubseteq> c + b \<Longrightarrow> a \<sqsubseteq> b" 

14738  207 

22390  208 
class pordered_ab_group_add = ab_group_add + pordered_ab_semigroup_add 
14738  209 

210 
instance pordered_ab_group_add \<subseteq> pordered_ab_semigroup_add_imp_le 

211 
proof 

212 
fix a b c :: 'a 

213 
assume "c + a \<le> c + b" 

214 
hence "(c) + (c + a) \<le> (c) + (c + b)" by (rule add_left_mono) 

215 
hence "((c) + c) + a \<le> ((c) + c) + b" by (simp only: add_assoc) 

216 
thus "a \<le> b" by simp 

217 
qed 

218 

22390  219 
class ordered_cancel_ab_semigroup_add = pordered_cancel_ab_semigroup_add + linorder 
14738  220 

221 
instance ordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add_imp_le 

222 
proof 

223 
fix a b c :: 'a 

224 
assume le: "c + a <= c + b" 

225 
show "a <= b" 

226 
proof (rule ccontr) 

227 
assume w: "~ a \<le> b" 

228 
hence "b <= a" by (simp add: linorder_not_le) 

229 
hence le2: "c+b <= c+a" by (rule add_left_mono) 

230 
have "a = b" 

231 
apply (insert le) 

232 
apply (insert le2) 

233 
apply (drule order_antisym, simp_all) 

234 
done 

235 
with w show False 

236 
by (simp add: linorder_not_le [symmetric]) 

237 
qed 

238 
qed 

239 

240 
lemma add_right_mono: "a \<le> (b::'a::pordered_ab_semigroup_add) ==> a + c \<le> b + c" 

22390  241 
by (simp add: add_commute [of _ c] add_left_mono) 
14738  242 

243 
text {* nonstrict, in both arguments *} 

244 
lemma add_mono: 

245 
"[a \<le> b; c \<le> d] ==> a + c \<le> b + (d::'a::pordered_ab_semigroup_add)" 

246 
apply (erule add_right_mono [THEN order_trans]) 

247 
apply (simp add: add_commute add_left_mono) 

248 
done 

249 

250 
lemma add_strict_left_mono: 

251 
"a < b ==> c + a < c + (b::'a::pordered_cancel_ab_semigroup_add)" 

252 
by (simp add: order_less_le add_left_mono) 

253 

254 
lemma add_strict_right_mono: 

255 
"a < b ==> a + c < b + (c::'a::pordered_cancel_ab_semigroup_add)" 

256 
by (simp add: add_commute [of _ c] add_strict_left_mono) 

257 

258 
text{*Strict monotonicity in both arguments*} 

259 
lemma add_strict_mono: "[a<b; c<d] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)" 

260 
apply (erule add_strict_right_mono [THEN order_less_trans]) 

261 
apply (erule add_strict_left_mono) 

262 
done 

263 

264 
lemma add_less_le_mono: 

265 
"[ a<b; c\<le>d ] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)" 

266 
apply (erule add_strict_right_mono [THEN order_less_le_trans]) 

267 
apply (erule add_left_mono) 

268 
done 

269 

270 
lemma add_le_less_mono: 

271 
"[ a\<le>b; c<d ] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)" 

272 
apply (erule add_right_mono [THEN order_le_less_trans]) 

273 
apply (erule add_strict_left_mono) 

274 
done 

275 

276 
lemma add_less_imp_less_left: 

277 
assumes less: "c + a < c + b" shows "a < (b::'a::pordered_ab_semigroup_add_imp_le)" 

278 
proof  

279 
from less have le: "c + a <= c + b" by (simp add: order_le_less) 

280 
have "a <= b" 

281 
apply (insert le) 

282 
apply (drule add_le_imp_le_left) 

283 
by (insert le, drule add_le_imp_le_left, assumption) 

284 
moreover have "a \<noteq> b" 

285 
proof (rule ccontr) 

286 
assume "~(a \<noteq> b)" 

287 
then have "a = b" by simp 

288 
then have "c + a = c + b" by simp 

289 
with less show "False"by simp 

290 
qed 

291 
ultimately show "a < b" by (simp add: order_le_less) 

292 
qed 

293 

294 
lemma add_less_imp_less_right: 

295 
"a + c < b + c ==> a < (b::'a::pordered_ab_semigroup_add_imp_le)" 

296 
apply (rule add_less_imp_less_left [of c]) 

297 
apply (simp add: add_commute) 

298 
done 

299 

300 
lemma add_less_cancel_left [simp]: 

301 
"(c+a < c+b) = (a < (b::'a::pordered_ab_semigroup_add_imp_le))" 

302 
by (blast intro: add_less_imp_less_left add_strict_left_mono) 

303 

304 
lemma add_less_cancel_right [simp]: 

305 
"(a+c < b+c) = (a < (b::'a::pordered_ab_semigroup_add_imp_le))" 

306 
by (blast intro: add_less_imp_less_right add_strict_right_mono) 

307 

308 
lemma add_le_cancel_left [simp]: 

309 
"(c+a \<le> c+b) = (a \<le> (b::'a::pordered_ab_semigroup_add_imp_le))" 

310 
by (auto, drule add_le_imp_le_left, simp_all add: add_left_mono) 

311 

312 
lemma add_le_cancel_right [simp]: 

313 
"(a+c \<le> b+c) = (a \<le> (b::'a::pordered_ab_semigroup_add_imp_le))" 

314 
by (simp add: add_commute[of a c] add_commute[of b c]) 

315 

316 
lemma add_le_imp_le_right: 

317 
"a + c \<le> b + c ==> a \<le> (b::'a::pordered_ab_semigroup_add_imp_le)" 

318 
by simp 

319 

15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

320 
lemma add_increasing: 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

321 
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

322 
shows "[0\<le>a; b\<le>c] ==> b \<le> a + c" 
14738  323 
by (insert add_mono [of 0 a b c], simp) 
324 

15539  325 
lemma add_increasing2: 
326 
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" 

327 
shows "[0\<le>c; b\<le>a] ==> b \<le> a + c" 

328 
by (simp add:add_increasing add_commute[of a]) 

329 

15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

330 
lemma add_strict_increasing: 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

331 
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

332 
shows "[0<a; b\<le>c] ==> b < a + c" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

333 
by (insert add_less_le_mono [of 0 a b c], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

334 

ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

335 
lemma add_strict_increasing2: 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

336 
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

337 
shows "[0\<le>a; b<c] ==> b < a + c" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

338 
by (insert add_le_less_mono [of 0 a b c], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

339 

19527  340 
lemma max_add_distrib_left: 
341 
fixes z :: "'a::pordered_ab_semigroup_add_imp_le" 

342 
shows "(max x y) + z = max (x+z) (y+z)" 

343 
by (rule max_of_mono [THEN sym], rule add_le_cancel_right) 

344 

345 
lemma min_add_distrib_left: 

346 
fixes z :: "'a::pordered_ab_semigroup_add_imp_le" 

347 
shows "(min x y) + z = min (x+z) (y+z)" 

348 
by (rule min_of_mono [THEN sym], rule add_le_cancel_right) 

349 

350 
lemma max_diff_distrib_left: 

351 
fixes z :: "'a::pordered_ab_group_add" 

352 
shows "(max x y)  z = max (xz) (yz)" 

353 
by (simp add: diff_minus, rule max_add_distrib_left) 

354 

355 
lemma min_diff_distrib_left: 

356 
fixes z :: "'a::pordered_ab_group_add" 

357 
shows "(min x y)  z = min (xz) (yz)" 

358 
by (simp add: diff_minus, rule min_add_distrib_left) 

359 

15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

360 

14738  361 
subsection {* Ordering Rules for Unary Minus *} 
362 

363 
lemma le_imp_neg_le: 

364 
assumes "a \<le> (b::'a::{pordered_ab_semigroup_add_imp_le, ab_group_add})" shows "b \<le> a" 

365 
proof  

366 
have "a+a \<le> a+b" 

367 
by (rule add_left_mono) 

368 
hence "0 \<le> a+b" 

369 
by simp 

370 
hence "0 + (b) \<le> (a + b) + (b)" 

371 
by (rule add_right_mono) 

372 
thus ?thesis 

373 
by (simp add: add_assoc) 

374 
qed 

375 

376 
lemma neg_le_iff_le [simp]: "(b \<le> a) = (a \<le> (b::'a::pordered_ab_group_add))" 

377 
proof 

378 
assume " b \<le>  a" 

379 
hence " ( a) \<le>  ( b)" 

380 
by (rule le_imp_neg_le) 

381 
thus "a\<le>b" by simp 

382 
next 

383 
assume "a\<le>b" 

384 
thus "b \<le> a" by (rule le_imp_neg_le) 

385 
qed 

386 

387 
lemma neg_le_0_iff_le [simp]: "(a \<le> 0) = (0 \<le> (a::'a::pordered_ab_group_add))" 

388 
by (subst neg_le_iff_le [symmetric], simp) 

389 

390 
lemma neg_0_le_iff_le [simp]: "(0 \<le> a) = (a \<le> (0::'a::pordered_ab_group_add))" 

391 
by (subst neg_le_iff_le [symmetric], simp) 

392 

393 
lemma neg_less_iff_less [simp]: "(b < a) = (a < (b::'a::pordered_ab_group_add))" 

394 
by (force simp add: order_less_le) 

395 

396 
lemma neg_less_0_iff_less [simp]: "(a < 0) = (0 < (a::'a::pordered_ab_group_add))" 

397 
by (subst neg_less_iff_less [symmetric], simp) 

398 

399 
lemma neg_0_less_iff_less [simp]: "(0 < a) = (a < (0::'a::pordered_ab_group_add))" 

400 
by (subst neg_less_iff_less [symmetric], simp) 

401 

402 
text{*The next several equations can make the simplifier loop!*} 

403 

404 
lemma less_minus_iff: "(a <  b) = (b <  (a::'a::pordered_ab_group_add))" 

405 
proof  

406 
have "( (a) <  b) = (b <  a)" by (rule neg_less_iff_less) 

407 
thus ?thesis by simp 

408 
qed 

409 

410 
lemma minus_less_iff: "( a < b) = ( b < (a::'a::pordered_ab_group_add))" 

411 
proof  

412 
have "( a <  (b)) = ( b < a)" by (rule neg_less_iff_less) 

413 
thus ?thesis by simp 

414 
qed 

415 

416 
lemma le_minus_iff: "(a \<le>  b) = (b \<le>  (a::'a::pordered_ab_group_add))" 

417 
proof  

418 
have mm: "!! a (b::'a). ((a)) < b \<Longrightarrow> (b) < a" by (simp only: minus_less_iff) 

419 
have "( ( a) <= b) = (b <=  a)" 

420 
apply (auto simp only: order_le_less) 

421 
apply (drule mm) 

422 
apply (simp_all) 

423 
apply (drule mm[simplified], assumption) 

424 
done 

425 
then show ?thesis by simp 

426 
qed 

427 

428 
lemma minus_le_iff: "( a \<le> b) = ( b \<le> (a::'a::pordered_ab_group_add))" 

429 
by (auto simp add: order_le_less minus_less_iff) 

430 

431 
lemma add_diff_eq: "a + (b  c) = (a + b)  (c::'a::ab_group_add)" 

432 
by (simp add: diff_minus add_ac) 

433 

434 
lemma diff_add_eq: "(a  b) + c = (a + c)  (b::'a::ab_group_add)" 

435 
by (simp add: diff_minus add_ac) 

436 

437 
lemma diff_eq_eq: "(ab = c) = (a = c + (b::'a::ab_group_add))" 

438 
by (auto simp add: diff_minus add_assoc) 

439 

440 
lemma eq_diff_eq: "(a = cb) = (a + (b::'a::ab_group_add) = c)" 

441 
by (auto simp add: diff_minus add_assoc) 

442 

443 
lemma diff_diff_eq: "(a  b)  c = a  (b + (c::'a::ab_group_add))" 

444 
by (simp add: diff_minus add_ac) 

445 

446 
lemma diff_diff_eq2: "a  (b  c) = (a + c)  (b::'a::ab_group_add)" 

447 
by (simp add: diff_minus add_ac) 

448 

449 
lemma diff_add_cancel: "a  b + b = (a::'a::ab_group_add)" 

450 
by (simp add: diff_minus add_ac) 

451 

452 
lemma add_diff_cancel: "a + b  b = (a::'a::ab_group_add)" 

453 
by (simp add: diff_minus add_ac) 

454 

14754
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

455 
text{*Further subtraction laws*} 
14738  456 

457 
lemma less_iff_diff_less_0: "(a < b) = (a  b < (0::'a::pordered_ab_group_add))" 

458 
proof  

459 
have "(a < b) = (a + ( b) < b + (b))" 

460 
by (simp only: add_less_cancel_right) 

461 
also have "... = (a  b < 0)" by (simp add: diff_minus) 

462 
finally show ?thesis . 

463 
qed 

464 

465 
lemma diff_less_eq: "(ab < c) = (a < c + (b::'a::pordered_ab_group_add))" 

15481  466 
apply (subst less_iff_diff_less_0 [of a]) 
14738  467 
apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst]) 
468 
apply (simp add: diff_minus add_ac) 

469 
done 

470 

471 
lemma less_diff_eq: "(a < cb) = (a + (b::'a::pordered_ab_group_add) < c)" 

15481  472 
apply (subst less_iff_diff_less_0 [of "a+b"]) 
473 
apply (subst less_iff_diff_less_0 [of a]) 

14738  474 
apply (simp add: diff_minus add_ac) 
475 
done 

476 

477 
lemma diff_le_eq: "(ab \<le> c) = (a \<le> c + (b::'a::pordered_ab_group_add))" 

478 
by (auto simp add: order_le_less diff_less_eq diff_add_cancel add_diff_cancel) 

479 

480 
lemma le_diff_eq: "(a \<le> cb) = (a + (b::'a::pordered_ab_group_add) \<le> c)" 

481 
by (auto simp add: order_le_less less_diff_eq diff_add_cancel add_diff_cancel) 

482 

483 
text{*This list of rewrites simplifies (in)equalities by bringing subtractions 

484 
to the top and then moving negative terms to the other side. 

485 
Use with @{text add_ac}*} 

486 
lemmas compare_rls = 

487 
diff_minus [symmetric] 

488 
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 

489 
diff_less_eq less_diff_eq diff_le_eq le_diff_eq 

490 
diff_eq_eq eq_diff_eq 

491 

16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

492 
subsection {* Support for reasoning about signs *} 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

493 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

494 
lemma add_pos_pos: "0 < 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

495 
(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

496 
==> 0 < y ==> 0 < x + y" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

497 
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

498 
apply simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

499 
apply (erule add_less_le_mono) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

500 
apply (erule order_less_imp_le) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

501 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

502 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

503 
lemma add_pos_nonneg: "0 < 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

504 
(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

505 
==> 0 <= y ==> 0 < x + y" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

506 
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

507 
apply simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

508 
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

509 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

510 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

511 
lemma add_nonneg_pos: "0 <= 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

512 
(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

513 
==> 0 < y ==> 0 < x + y" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

514 
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

515 
apply simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

516 
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

517 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

518 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

519 
lemma add_nonneg_nonneg: "0 <= 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

520 
(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

521 
==> 0 <= y ==> 0 <= x + y" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

522 
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

523 
apply simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

524 
apply (erule add_mono, assumption) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

525 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

526 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

527 
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

528 
< 0 ==> y < 0 ==> x + y < 0" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

529 
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

530 
apply simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

531 
apply (erule add_less_le_mono) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

532 
apply (erule order_less_imp_le) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

533 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

534 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

535 
lemma add_neg_nonpos: 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

536 
"(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

537 
==> y <= 0 ==> x + y < 0" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

538 
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

539 
apply simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

540 
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

541 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

542 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

543 
lemma add_nonpos_neg: 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

544 
"(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

545 
==> y < 0 ==> x + y < 0" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

546 
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

547 
apply simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

548 
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

549 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

550 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

551 
lemma add_nonpos_nonpos: 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

552 
"(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

553 
==> y <= 0 ==> x + y <= 0" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

554 
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

555 
apply simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

556 
apply (erule add_mono, assumption) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

557 
done 
14738  558 

559 
subsection{*Lemmas for the @{text cancel_numerals} simproc*} 

560 

561 
lemma eq_iff_diff_eq_0: "(a = b) = (ab = (0::'a::ab_group_add))" 

562 
by (simp add: compare_rls) 

563 

564 
lemma le_iff_diff_le_0: "(a \<le> b) = (ab \<le> (0::'a::pordered_ab_group_add))" 

565 
by (simp add: compare_rls) 

566 

567 
subsection {* Lattice Ordered (Abelian) Groups *} 

568 

569 
axclass lordered_ab_group_meet < pordered_ab_group_add, meet_semilorder 

570 

571 
axclass lordered_ab_group_join < pordered_ab_group_add, join_semilorder 

572 

573 
lemma add_meet_distrib_left: "a + (meet b c) = meet (a + b) (a + (c::'a::{pordered_ab_group_add, meet_semilorder}))" 

574 
apply (rule order_antisym) 

21312  575 
apply (simp_all add: le_meetI) 
14738  576 
apply (rule add_le_imp_le_left [of "a"]) 
577 
apply (simp only: add_assoc[symmetric], simp) 

21312  578 
apply rule 
579 
apply (rule add_le_imp_le_left[of "a"], simp only: add_assoc[symmetric], simp)+ 

14738  580 
done 
581 

582 
lemma add_join_distrib_left: "a + (join b c) = join (a + b) (a+ (c::'a::{pordered_ab_group_add, join_semilorder}))" 

583 
apply (rule order_antisym) 

584 
apply (rule add_le_imp_le_left [of "a"]) 

585 
apply (simp only: add_assoc[symmetric], simp) 

21312  586 
apply rule 
587 
apply (rule add_le_imp_le_left [of "a"], simp only: add_assoc[symmetric], simp)+ 

588 
apply (rule join_leI) 

589 
apply (simp_all) 

14738  590 
done 
591 

592 
lemma is_join_neg_meet: "is_join (% (a::'a::{pordered_ab_group_add, meet_semilorder}) b.  (meet (a) (b)))" 

593 
apply (auto simp add: is_join_def) 

21312  594 
apply (rule_tac c="meet (a) (b)" in add_le_imp_le_right, simp, simp add: add_meet_distrib_left) 
595 
apply (rule_tac c="meet (a) (b)" in add_le_imp_le_right, simp, simp add: add_meet_distrib_left) 

14738  596 
apply (subst neg_le_iff_le[symmetric]) 
21312  597 
apply (simp add: le_meetI) 
14738  598 
done 
599 

600 
lemma is_meet_neg_join: "is_meet (% (a::'a::{pordered_ab_group_add, join_semilorder}) b.  (join (a) (b)))" 

601 
apply (auto simp add: is_meet_def) 

21312  602 
apply (rule_tac c="join (a) (b)" in add_le_imp_le_right, simp, simp add: add_join_distrib_left) 
603 
apply (rule_tac c="join (a) (b)" in add_le_imp_le_right, simp, simp add: add_join_distrib_left) 

14738  604 
apply (subst neg_le_iff_le[symmetric]) 
21312  605 
apply (simp add: join_leI) 
14738  606 
done 
607 

608 
axclass lordered_ab_group \<subseteq> pordered_ab_group_add, lorder 

609 

610 
instance lordered_ab_group_meet \<subseteq> lordered_ab_group 

611 
proof 

612 
show "? j. is_join (j::'a\<Rightarrow>'a\<Rightarrow>('a::lordered_ab_group_meet))" by (blast intro: is_join_neg_meet) 

613 
qed 

614 

615 
instance lordered_ab_group_join \<subseteq> lordered_ab_group 

616 
proof 

617 
show "? m. is_meet (m::'a\<Rightarrow>'a\<Rightarrow>('a::lordered_ab_group_join))" by (blast intro: is_meet_neg_join) 

618 
qed 

619 

620 
lemma add_join_distrib_right: "(join a b) + (c::'a::lordered_ab_group) = join (a+c) (b+c)" 

621 
proof  

622 
have "c + (join a b) = join (c+a) (c+b)" by (simp add: add_join_distrib_left) 

623 
thus ?thesis by (simp add: add_commute) 

624 
qed 

625 

626 
lemma add_meet_distrib_right: "(meet a b) + (c::'a::lordered_ab_group) = meet (a+c) (b+c)" 

627 
proof  

628 
have "c + (meet a b) = meet (c+a) (c+b)" by (simp add: add_meet_distrib_left) 

629 
thus ?thesis by (simp add: add_commute) 

630 
qed 

631 

632 
lemmas add_meet_join_distribs = add_meet_distrib_right add_meet_distrib_left add_join_distrib_right add_join_distrib_left 

633 

634 
lemma join_eq_neg_meet: "join a (b::'a::lordered_ab_group) =  meet (a) (b)" 

635 
by (simp add: is_join_unique[OF is_join_join is_join_neg_meet]) 

636 

637 
lemma meet_eq_neg_join: "meet a (b::'a::lordered_ab_group) =  join (a) (b)" 

638 
by (simp add: is_meet_unique[OF is_meet_meet is_meet_neg_join]) 

639 

640 
lemma add_eq_meet_join: "a + b = (join a b) + (meet a (b::'a::lordered_ab_group))" 

641 
proof  

642 
have "0 =  meet 0 (ab) + meet (ab) 0" by (simp add: meet_comm) 

643 
hence "0 = join 0 (ba) + meet (ab) 0" by (simp add: meet_eq_neg_join) 

644 
hence "0 = (a + join a b) + (meet a b + (b))" 

645 
apply (simp add: add_join_distrib_left add_meet_distrib_right) 

646 
by (simp add: diff_minus add_commute) 

647 
thus ?thesis 

648 
apply (simp add: compare_rls) 

649 
apply (subst add_left_cancel[symmetric, of "a+b" "join a b + meet a b" "a"]) 

650 
apply (simp only: add_assoc, simp add: add_assoc[symmetric]) 

651 
done 

652 
qed 

653 

654 
subsection {* Positive Part, Negative Part, Absolute Value *} 

655 

656 
constdefs 

657 
pprt :: "'a \<Rightarrow> ('a::lordered_ab_group)" 

658 
"pprt x == join x 0" 

659 
nprt :: "'a \<Rightarrow> ('a::lordered_ab_group)" 

660 
"nprt x == meet x 0" 

661 

662 
lemma prts: "a = pprt a + nprt a" 

663 
by (simp add: pprt_def nprt_def add_eq_meet_join[symmetric]) 

664 

665 
lemma zero_le_pprt[simp]: "0 \<le> pprt a" 

21312  666 
by (simp add: pprt_def) 
14738  667 

668 
lemma nprt_le_zero[simp]: "nprt a \<le> 0" 

21312  669 
by (simp add: nprt_def) 
14738  670 

671 
lemma le_eq_neg: "(a \<le> b) = (a + b \<le> (0::_::lordered_ab_group))" (is "?l = ?r") 

672 
proof  

673 
have a: "?l \<longrightarrow> ?r" 

674 
apply (auto) 

675 
apply (rule add_le_imp_le_right[of _ "b" _]) 

676 
apply (simp add: add_assoc) 

677 
done 

678 
have b: "?r \<longrightarrow> ?l" 

679 
apply (auto) 

680 
apply (rule add_le_imp_le_right[of _ "b" _]) 

681 
apply (simp) 

682 
done 

683 
from a b show ?thesis by blast 

684 
qed 

685 

15580  686 
lemma pprt_0[simp]: "pprt 0 = 0" by (simp add: pprt_def) 
687 
lemma nprt_0[simp]: "nprt 0 = 0" by (simp add: nprt_def) 

688 

689 
lemma pprt_eq_id[simp]: "0 <= x \<Longrightarrow> pprt x = x" 

690 
by (simp add: pprt_def le_def_join join_aci) 

691 

692 
lemma nprt_eq_id[simp]: "x <= 0 \<Longrightarrow> nprt x = x" 

693 
by (simp add: nprt_def le_def_meet meet_aci) 

694 

695 
lemma pprt_eq_0[simp]: "x <= 0 \<Longrightarrow> pprt x = 0" 

696 
by (simp add: pprt_def le_def_join join_aci) 

697 

698 
lemma nprt_eq_0[simp]: "0 <= x \<Longrightarrow> nprt x = 0" 

699 
by (simp add: nprt_def le_def_meet meet_aci) 

700 

14738  701 
lemma join_0_imp_0: "join a (a) = 0 \<Longrightarrow> a = (0::'a::lordered_ab_group)" 
702 
proof  

703 
{ 

704 
fix a::'a 

705 
assume hyp: "join a (a) = 0" 

706 
hence "join a (a) + a = a" by (simp) 

707 
hence "join (a+a) 0 = a" by (simp add: add_join_distrib_right) 

708 
hence "join (a+a) 0 <= a" by (simp) 

709 
hence "0 <= a" by (blast intro: order_trans meet_join_le) 

710 
} 

711 
note p = this 

712 
assume hyp:"join a (a) = 0" 

713 
hence hyp2:"join (a) ((a)) = 0" by (simp add: join_comm) 

714 
from p[OF hyp] p[OF hyp2] show "a = 0" by simp 

715 
qed 

716 

717 
lemma meet_0_imp_0: "meet a (a) = 0 \<Longrightarrow> a = (0::'a::lordered_ab_group)" 

718 
apply (simp add: meet_eq_neg_join) 

719 
apply (simp add: join_comm) 

15481  720 
apply (erule join_0_imp_0) 
721 
done 

14738  722 

723 
lemma join_0_eq_0[simp]: "(join a (a) = 0) = (a = (0::'a::lordered_ab_group))" 

724 
by (auto, erule join_0_imp_0) 

725 

726 
lemma meet_0_eq_0[simp]: "(meet a (a) = 0) = (a = (0::'a::lordered_ab_group))" 

727 
by (auto, erule meet_0_imp_0) 

728 

729 
lemma zero_le_double_add_iff_zero_le_single_add[simp]: "(0 \<le> a + a) = (0 \<le> (a::'a::lordered_ab_group))" 

730 
proof 

731 
assume "0 <= a + a" 

732 
hence a:"meet (a+a) 0 = 0" by (simp add: le_def_meet meet_comm) 

733 
have "(meet a 0)+(meet a 0) = meet (meet (a+a) 0) a" (is "?l=_") by (simp add: add_meet_join_distribs meet_aci) 

734 
hence "?l = 0 + meet a 0" by (simp add: a, simp add: meet_comm) 

735 
hence "meet a 0 = 0" by (simp only: add_right_cancel) 

736 
then show "0 <= a" by (simp add: le_def_meet meet_comm) 

737 
next 

738 
assume a: "0 <= a" 

739 
show "0 <= a + a" by (simp add: add_mono[OF a a, simplified]) 

740 
qed 

741 

742 
lemma double_add_le_zero_iff_single_add_le_zero[simp]: "(a + a <= 0) = ((a::'a::lordered_ab_group) <= 0)" 

743 
proof  

744 
have "(a + a <= 0) = (0 <= (a+a))" by (subst le_minus_iff, simp) 

745 
moreover have "\<dots> = (a <= 0)" by (simp add: zero_le_double_add_iff_zero_le_single_add) 

746 
ultimately show ?thesis by blast 

747 
qed 

748 

749 
lemma double_add_less_zero_iff_single_less_zero[simp]: "(a+a<0) = ((a::'a::{pordered_ab_group_add,linorder}) < 0)" (is ?s) 

750 
proof cases 

751 
assume a: "a < 0" 

752 
thus ?s by (simp add: add_strict_mono[OF a a, simplified]) 

753 
next 

754 
assume "~(a < 0)" 

755 
hence a:"0 <= a" by (simp) 

756 
hence "0 <= a+a" by (simp add: add_mono[OF a a, simplified]) 

757 
hence "~(a+a < 0)" by simp 

758 
with a show ?thesis by simp 

759 
qed 

760 

761 
axclass lordered_ab_group_abs \<subseteq> lordered_ab_group 

762 
abs_lattice: "abs x = join x (x)" 

763 

764 
lemma abs_zero[simp]: "abs 0 = (0::'a::lordered_ab_group_abs)" 

765 
by (simp add: abs_lattice) 

766 

767 
lemma abs_eq_0[simp]: "(abs a = 0) = (a = (0::'a::lordered_ab_group_abs))" 

768 
by (simp add: abs_lattice) 

769 

770 
lemma abs_0_eq[simp]: "(0 = abs a) = (a = (0::'a::lordered_ab_group_abs))" 

771 
proof  

772 
have "(0 = abs a) = (abs a = 0)" by (simp only: eq_ac) 

773 
thus ?thesis by simp 

774 
qed 

775 

776 
lemma neg_meet_eq_join[simp]: " meet a (b::_::lordered_ab_group) = join (a) (b)" 

777 
by (simp add: meet_eq_neg_join) 

778 

779 
lemma neg_join_eq_meet[simp]: " join a (b::_::lordered_ab_group) = meet (a) (b)" 

780 
by (simp del: neg_meet_eq_join add: join_eq_neg_meet) 

781 

782 
lemma join_eq_if: "join a (a) = (if a < 0 then a else (a::'a::{lordered_ab_group, linorder}))" 

783 
proof  

784 
note b = add_le_cancel_right[of a a "a",symmetric,simplified] 

785 
have c: "a + a = 0 \<Longrightarrow> a = a" by (rule add_right_imp_eq[of _ a], simp) 

15197  786 
show ?thesis by (auto simp add: join_max max_def b linorder_not_less) 
14738  787 
qed 
788 

789 
lemma abs_if_lattice: "\<bar>a\<bar> = (if a < 0 then a else (a::'a::{lordered_ab_group_abs, linorder}))" 

790 
proof  

791 
show ?thesis by (simp add: abs_lattice join_eq_if) 

792 
qed 

793 

794 
lemma abs_ge_zero[simp]: "0 \<le> abs (a::'a::lordered_ab_group_abs)" 

795 
proof  

21312  796 
have a:"a <= abs a" and b:"a <= abs a" by (auto simp add: abs_lattice) 
14738  797 
show ?thesis by (rule add_mono[OF a b, simplified]) 
798 
qed 

799 

800 
lemma abs_le_zero_iff [simp]: "(abs a \<le> (0::'a::lordered_ab_group_abs)) = (a = 0)" 

801 
proof 

802 
assume "abs a <= 0" 

803 
hence "abs a = 0" by (auto dest: order_antisym) 

804 
thus "a = 0" by simp 

805 
next 

806 
assume "a = 0" 

807 
thus "abs a <= 0" by simp 

808 
qed 

809 

810 
lemma zero_less_abs_iff [simp]: "(0 < abs a) = (a \<noteq> (0::'a::lordered_ab_group_abs))" 

811 
by (simp add: order_less_le) 

812 

813 
lemma abs_not_less_zero [simp]: "~ abs a < (0::'a::lordered_ab_group_abs)" 

814 
proof  

815 
have a:"!! x (y::_::order). x <= y \<Longrightarrow> ~(y < x)" by auto 

816 
show ?thesis by (simp add: a) 

817 
qed 

818 

819 
lemma abs_ge_self: "a \<le> abs (a::'a::lordered_ab_group_abs)" 

21312  820 
by (simp add: abs_lattice) 
14738  821 

822 
lemma abs_ge_minus_self: "a \<le> abs (a::'a::lordered_ab_group_abs)" 

21312  823 
by (simp add: abs_lattice) 
14738  824 

825 
lemma abs_prts: "abs (a::_::lordered_ab_group_abs) = pprt a  nprt a" 

826 
apply (simp add: pprt_def nprt_def diff_minus) 

827 
apply (simp add: add_meet_join_distribs join_aci abs_lattice[symmetric]) 

21312  828 
apply (subst join_absorp2, auto) 
14738  829 
done 
830 

831 
lemma abs_minus_cancel [simp]: "abs (a) = abs(a::'a::lordered_ab_group_abs)" 

832 
by (simp add: abs_lattice join_comm) 

833 

834 
lemma abs_idempotent [simp]: "abs (abs a) = abs (a::'a::lordered_ab_group_abs)" 

835 
apply (simp add: abs_lattice[of "abs a"]) 

21312  836 
apply (subst join_absorp1) 
14738  837 
apply (rule order_trans[of _ 0]) 
838 
by auto 

839 

15093
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

840 
lemma abs_minus_commute: 
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

841 
fixes a :: "'a::lordered_ab_group_abs" 
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

842 
shows "abs (ab) = abs(ba)" 
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

843 
proof  
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

844 
have "abs (ab) = abs ( (ab))" by (simp only: abs_minus_cancel) 
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

845 
also have "... = abs(ba)" by simp 
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

846 
finally show ?thesis . 
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

847 
qed 
49ede01e9ee6
conversion of Integration and NSPrimes to Isar scripts
paulson
parents:
15010
diff
changeset

848 

14738  849 
lemma zero_le_iff_zero_nprt: "(0 \<le> a) = (nprt a = 0)" 
850 
by (simp add: le_def_meet nprt_def meet_comm) 

851 

852 
lemma le_zero_iff_zero_pprt: "(a \<le> 0) = (pprt a = 0)" 

853 
by (simp add: le_def_join pprt_def join_comm) 

854 

855 
lemma le_zero_iff_pprt_id: "(0 \<le> a) = (pprt a = a)" 

856 
by (simp add: le_def_join pprt_def join_comm) 

857 

858 
lemma zero_le_iff_nprt_id: "(a \<le> 0) = (nprt a = a)" 

859 
by (simp add: le_def_meet nprt_def meet_comm) 

860 

15580  861 
lemma pprt_mono[simp]: "(a::_::lordered_ab_group) <= b \<Longrightarrow> pprt a <= pprt b" 
862 
by (simp add: le_def_join pprt_def join_aci) 

863 

864 
lemma nprt_mono[simp]: "(a::_::lordered_ab_group) <= b \<Longrightarrow> nprt a <= nprt b" 

865 
by (simp add: le_def_meet nprt_def meet_aci) 

866 

19404  867 
lemma pprt_neg: "pprt (x) =  nprt x" 
868 
by (simp add: pprt_def nprt_def) 

869 

870 
lemma nprt_neg: "nprt (x) =  pprt x" 

871 
by (simp add: pprt_def nprt_def) 

872 

14738  873 
lemma iff2imp: "(A=B) \<Longrightarrow> (A \<Longrightarrow> B)" 
874 
by (simp) 

875 

16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

876 
lemma abs_of_nonneg [simp]: "0 \<le> a \<Longrightarrow> abs a = (a::'a::lordered_ab_group_abs)" 
14738  877 
by (simp add: iff2imp[OF zero_le_iff_zero_nprt] iff2imp[OF le_zero_iff_pprt_id] abs_prts) 
878 

16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

879 
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

880 
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

881 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

882 
lemma abs_of_nonpos [simp]: "a \<le> 0 \<Longrightarrow> abs a = (a::'a::lordered_ab_group_abs)" 
14738  883 
by (simp add: iff2imp[OF le_zero_iff_zero_pprt] iff2imp[OF zero_le_iff_nprt_id] abs_prts) 
884 

16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

885 
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

886 
abs x =  x" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

887 
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

888 

14738  889 
lemma abs_leI: "[a \<le> b; a \<le> b] ==> abs a \<le> (b::'a::lordered_ab_group_abs)" 
21312  890 
by (simp add: abs_lattice join_leI) 
14738  891 

892 
lemma le_minus_self_iff: "(a \<le> a) = (a \<le> (0::'a::lordered_ab_group))" 

893 
proof  

894 
from add_le_cancel_left[of "a" "a+a" "0"] have "(a <= a) = (a+a <= 0)" 

895 
by (simp add: add_assoc[symmetric]) 

896 
thus ?thesis by simp 

897 
qed 

898 

899 
lemma minus_le_self_iff: "(a \<le> a) = (0 \<le> (a::'a::lordered_ab_group))" 

900 
proof  

901 
from add_le_cancel_left[of "a" "0" "a+a"] have "(a <= a) = (0 <= a+a)" 

902 
by (simp add: add_assoc[symmetric]) 

903 
thus ?thesis by simp 

904 
qed 

905 

906 
lemma abs_le_D1: "abs a \<le> b ==> a \<le> (b::'a::lordered_ab_group_abs)" 

907 
by (insert abs_ge_self, blast intro: order_trans) 

908 

909 
lemma abs_le_D2: "abs a \<le> b ==> a \<le> (b::'a::lordered_ab_group_abs)" 

910 
by (insert abs_le_D1 [of "a"], simp) 

911 

912 
lemma abs_le_iff: "(abs a \<le> b) = (a \<le> b & a \<le> (b::'a::lordered_ab_group_abs))" 

913 
by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2) 

914 

15539  915 
lemma abs_triangle_ineq: "abs(a+b) \<le> abs a + abs(b::'a::lordered_ab_group_abs)" 
14738  916 
proof  
917 
have g:"abs a + abs b = join (a+b) (join (ab) (join (a+b) (a + (b))))" (is "_=join ?m ?n") 

19233
77ca20b0ed77
renamed HOL +  * etc. to HOL.plus HOL.minus HOL.times etc.
haftmann
parents:
17085
diff
changeset

918 
by (simp add: abs_lattice add_meet_join_distribs join_aci diff_minus) 
21312  919 
have a:"a+b <= join ?m ?n" by (simp) 
920 
have b:"ab <= ?n" by (simp) 

921 
have c:"?n <= join ?m ?n" by (simp) 

922 
from b c have d: "ab <= join ?m ?n" by(rule order_trans) 

14738  923 
have e:"ab = (a+b)" by (simp add: diff_minus) 
924 
from a d e have "abs(a+b) <= join ?m ?n" 

925 
by (drule_tac abs_leI, auto) 

926 
with g[symmetric] show ?thesis by simp 

927 
qed 

928 

16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

929 
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

930 
abs b <= abs (a  b)" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

931 
apply (simp add: compare_rls) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

932 
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

933 
apply (erule ssubst) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

934 
apply (rule abs_triangle_ineq) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

935 
apply (rule arg_cong);back; 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

936 
apply (simp add: compare_rls) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

937 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

938 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

939 
lemma abs_triangle_ineq3: 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

940 
"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

941 
apply (subst abs_le_iff) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

942 
apply auto 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

943 
apply (rule abs_triangle_ineq2) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

944 
apply (subst abs_minus_commute) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

945 
apply (rule abs_triangle_ineq2) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

946 
done 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

947 

c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

948 
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

949 
abs a + abs b" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

950 
proof ; 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

951 
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

952 
by (subst diff_minus, rule refl) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

953 
also have "... <= abs a + abs ( b)" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

954 
by (rule abs_triangle_ineq) 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

955 
finally show ?thesis 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

956 
by simp 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

957 
qed 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

958 

14738  959 
lemma abs_diff_triangle_ineq: 
960 
"\<bar>(a::'a::lordered_ab_group_abs) + b  (c+d)\<bar> \<le> \<bar>ac\<bar> + \<bar>bd\<bar>" 

961 
proof  

962 
have "\<bar>a + b  (c+d)\<bar> = \<bar>(ac) + (bd)\<bar>" by (simp add: diff_minus add_ac) 

963 
also have "... \<le> \<bar>ac\<bar> + \<bar>bd\<bar>" by (rule abs_triangle_ineq) 

964 
finally show ?thesis . 

965 
qed 

966 

15539  967 
lemma abs_add_abs[simp]: 
968 
fixes a:: "'a::{lordered_ab_group_abs}" 

969 
shows "abs(abs a + abs b) = abs a + abs b" (is "?L = ?R") 

970 
proof (rule order_antisym) 

971 
show "?L \<ge> ?R" by(rule abs_ge_self) 

972 
next 

973 
have "?L \<le> \<bar>\<bar>a\<bar>\<bar> + \<bar>\<bar>b\<bar>\<bar>" by(rule abs_triangle_ineq) 

974 
also have "\<dots> = ?R" by simp 

975 
finally show "?L \<le> ?R" . 

976 
qed 

977 

14754
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

978 
text {* Needed for abelian cancellation simprocs: *} 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

979 

a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

980 
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

981 
apply (subst add_left_commute) 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

982 
apply (subst add_left_cancel) 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

983 
apply simp 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

984 
done 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

985 

a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

986 
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

987 
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

988 
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

989 
done 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

990 

a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

991 
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

992 
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

993 

a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

994 
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

995 
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

996 
apply (simp add: neg_le_iff_le[symmetric, of "yx" 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

997 
done 
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 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

1000 
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

1001 

a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

1002 
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

1003 
by (simp add: diff_minus) 
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_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

1006 
by (simp add: add_assoc[symmetric]) 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

1007 

a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

1008 
lemma minus_add_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

1009 
by (simp add: add_assoc[symmetric]) 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

1010 

15178  1011 
lemma le_add_right_mono: 
1012 
assumes 

1013 
"a <= b + (c::'a::pordered_ab_group_add)" 

1014 
"c <= d" 

1015 
shows "a <= b + d" 

1016 
apply (rule_tac order_trans[where y = "b+c"]) 

1017 
apply (simp_all add: prems) 

1018 
done 

1019 

1020 
lemmas group_eq_simps = 

1021 
mult_ac 

1022 
add_ac 

1023 
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 

1024 
diff_eq_eq eq_diff_eq 

1025 

1026 
lemma estimate_by_abs: 

1027 
"a + b <= (c::'a::lordered_ab_group_abs) \<Longrightarrow> a <= c + abs b" 

1028 
proof  

1029 
assume 1: "a+b <= c" 

1030 
have 2: "a <= c+(b)" 

1031 
apply (insert 1) 

1032 
apply (drule_tac add_right_mono[where c="b"]) 

1033 
apply (simp add: group_eq_simps) 

1034 
done 

1035 
have 3: "(b) <= abs b" by (rule abs_ge_minus_self) 

1036 
show ?thesis by (rule le_add_right_mono[OF 2 3]) 

1037 
qed 

1038 

17085  1039 
text{*Simplification of @{term "xy < 0"}, etc.*} 
1040 
lemmas diff_less_0_iff_less = less_iff_diff_less_0 [symmetric] 

1041 
lemmas diff_eq_0_iff_eq = eq_iff_diff_eq_0 [symmetric] 

1042 
lemmas diff_le_0_iff_le = le_iff_diff_le_0 [symmetric] 

1043 
declare diff_less_0_iff_less [simp] 

1044 
declare diff_eq_0_iff_eq [simp] 

1045 
declare diff_le_0_iff_le [simp] 

1046 

1047 

14738  1048 
ML {* 
1049 
val add_assoc = thm "add_assoc"; 

1050 
val add_commute = thm "add_commute"; 

1051 
val add_left_commute = thm "add_left_commute"; 

1052 
val add_ac = thms "add_ac"; 

1053 
val mult_assoc = thm "mult_assoc"; 

1054 
val mult_commute = thm "mult_commute"; 

1055 
val mult_left_commute = thm "mult_left_commute"; 

1056 
val mult_ac = thms "mult_ac"; 

1057 
val add_0 = thm "add_0"; 

1058 
val mult_1_left = thm "mult_1_left"; 

1059 
val mult_1_right = thm "mult_1_right"; 

1060 
val mult_1 = thm "mult_1"; 

1061 
val add_left_imp_eq = thm "add_left_imp_eq"; 

1062 
val add_right_imp_eq = thm "add_right_imp_eq"; 

1063 
val add_imp_eq = thm "add_imp_eq"; 

1064 
val left_minus = thm "left_minus"; 

1065 
val diff_minus = thm "diff_minus"; 

1066 
val add_0_right = thm "add_0_right"; 

1067 
val add_left_cancel = thm "add_left_cancel"; 

1068 
val add_right_cancel = thm "add_right_cancel"; 

1069 
val right_minus = thm "right_minus"; 

1070 
val right_minus_eq = thm "right_minus_eq"; 

1071 
val minus_minus = thm "minus_minus"; 

1072 
val equals_zero_I = thm "equals_zero_I"; 

1073 
val minus_zero = thm "minus_zero"; 

1074 
val diff_self = thm "diff_self"; 

1075 
val diff_0 = thm "diff_0"; 

1076 
val diff_0_right = thm "diff_0_right"; 

1077 
val diff_minus_eq_add = thm "diff_minus_eq_add"; 

1078 
val neg_equal_iff_equal = thm "neg_equal_iff_equal"; 

1079 
val neg_equal_0_iff_equal = thm "neg_equal_0_iff_equal"; 

1080 
val neg_0_equal_iff_equal = thm "neg_0_equal_iff_equal"; 

1081 
val equation_minus_iff = thm "equation_minus_iff"; 

1082 
val minus_equation_iff = thm "minus_equation_iff"; 

1083 
val minus_add_distrib = thm "minus_add_distrib"; 

1084 
val minus_diff_eq = thm "minus_diff_eq"; 

1085 
val add_left_mono = thm "add_left_mono"; 

1086 
val add_le_imp_le_left = thm "add_le_imp_le_left"; 

1087 
val add_right_mono = thm "add_right_mono"; 

1088 
val add_mono = thm "add_mono"; 

1089 
val add_strict_left_mono = thm "add_strict_left_mono"; 

1090 
val add_strict_right_mono = thm "add_strict_right_mono"; 

1091 
val add_strict_mono = thm "add_strict_mono"; 

1092 
val add_less_le_mono = thm "add_less_le_mono"; 

1093 
val add_le_less_mono = thm "add_le_less_mono"; 

1094 
val add_less_imp_less_left = thm "add_less_imp_less_left"; 

1095 
val add_less_imp_less_right = thm "add_less_imp_less_right"; 

1096 
val add_less_cancel_left = thm "add_less_cancel_left"; 

1097 
val add_less_cancel_right = thm "add_less_cancel_right"; 

1098 
val add_le_cancel_left = thm "add_le_cancel_left"; 

1099 
val add_le_cancel_right = thm "add_le_cancel_right"; 

1100 
val add_le_imp_le_right = thm "add_le_imp_le_right"; 

1101 
val add_increasing = thm "add_increasing"; 

1102 
val le_imp_neg_le = thm "le_imp_neg_le"; 

1103 
val neg_le_iff_le = thm "neg_le_iff_le"; 

1104 
val neg_le_0_iff_le = thm "neg_le_0_iff_le"; 

1105 
val neg_0_le_iff_le = thm "neg_0_le_iff_le"; 

1106 
val neg_less_iff_less = thm "neg_less_iff_less"; 

1107 
val neg_less_0_iff_less = thm "neg_less_0_iff_less"; 

1108 
val neg_0_less_iff_less = thm "neg_0_less_iff_less"; 

1109 
val less_minus_iff = thm "less_minus_iff"; 

1110 
val minus_less_iff = thm "minus_less_iff"; 

1111 
val le_minus_iff = thm "le_minus_iff"; 

1112 
val minus_le_iff = thm "minus_le_iff"; 

1113 
val add_diff_eq = thm "add_diff_eq"; 

1114 
val diff_add_eq = thm "diff_add_eq"; 

1115 
val diff_eq_eq = thm "diff_eq_eq"; 

1116 
val eq_diff_eq = thm "eq_diff_eq"; 

1117 
val diff_diff_eq = thm "diff_diff_eq"; 

1118 
val diff_diff_eq2 = thm "diff_diff_eq2"; 

1119 
val diff_add_cancel = thm "diff_add_cancel"; 

1120 
val add_diff_cancel = thm "add_diff_cancel"; 

1121 
val less_iff_diff_less_0 = thm "less_iff_diff_less_0"; 

1122 
val diff_less_eq = thm "diff_less_eq"; 

1123 
val less_diff_eq = thm "less_diff_eq"; 

1124 
val diff_le_eq = thm "diff_le_eq"; 

1125 
val le_diff_eq = thm "le_diff_eq"; 

1126 
val compare_rls = thms "compare_rls"; 

1127 
val eq_iff_diff_eq_0 = thm "eq_iff_diff_eq_0"; 

1128 
val le_iff_diff_le_0 = thm "le_iff_diff_le_0"; 

1129 
val add_meet_distrib_left = thm "add_meet_distrib_left"; 

1130 
val add_join_distrib_left = thm "add_join_distrib_left"; 

1131 
val is_join_neg_meet = thm "is_join_neg_meet"; 

1132 
val is_meet_neg_join = thm "is_meet_neg_join"; 

1133 
val add_join_distrib_right = thm "add_join_distrib_right"; 

1134 
val add_meet_distrib_right = thm "add_meet_distrib_right"; 

1135 
val add_meet_join_distribs = thms "add_meet_join_distribs"; 

1136 
val join_eq_neg_meet = thm "join_eq_neg_meet"; 

1137 
val meet_eq_neg_join = thm "meet_eq_neg_join"; 

1138 
val add_eq_meet_join = thm "add_eq_meet_join"; 

1139 
val prts = thm "prts"; 

1140 
val zero_le_pprt = thm "zero_le_pprt"; 

1141 
val nprt_le_zero = thm "nprt_le_zero"; 

1142 
val le_eq_neg = thm "le_eq_neg"; 

1143 
val join_0_imp_0 = thm "join_0_imp_0"; 

1144 
val meet_0_imp_0 = thm "meet_0_imp_0"; 

1145 
val join_0_eq_0 = thm "join_0_eq_0"; 

1146 
val meet_0_eq_0 = thm "meet_0_eq_0"; 

1147 
val zero_le_double_add_iff_zero_le_single_add = thm "zero_le_double_add_iff_zero_le_single_add"; 

1148 
val double_add_le_zero_iff_single_add_le_zero = thm "double_add_le_zero_iff_single_add_le_zero"; 

1149 
val double_add_less_zero_iff_single_less_zero = thm "double_add_less_zero_iff_single_less_zero"; 

1150 
val abs_lattice = thm "abs_lattice"; 

1151 
val abs_zero = thm "abs_zero"; 

1152 
val abs_eq_0 = thm "abs_eq_0"; 

1153 
val abs_0_eq = thm "abs_0_eq"; 

1154 
val neg_meet_eq_join = thm "neg_meet_eq_join"; 

1155 
val neg_join_eq_meet = thm "neg_join_eq_meet"; 

1156 
val join_eq_if = thm "join_eq_if"; 

1157 
val abs_if_lattice = thm "abs_if_lattice"; 

1158 
val abs_ge_zero = thm "abs_ge_zero"; 

1159 
val abs_le_zero_iff = thm "abs_le_zero_iff"; 

1160 
val zero_less_abs_iff = thm "zero_less_abs_iff"; 

1161 
val abs_not_less_zero = thm "abs_not_less_zero"; 

1162 
val abs_ge_self = thm "abs_ge_self"; 

1163 
val abs_ge_minus_self = thm "abs_ge_minus_self"; 

21312  1164 
val le_imp_join_eq = thm "join_absorp2"; 
1165 
val ge_imp_join_eq = thm "join_absorp1"; 

1166 
val le_imp_meet_eq = thm "meet_absorp1"; 

1167 
val ge_imp_meet_eq = thm "meet_absorp2"; 

14738  1168 
val abs_prts = thm "abs_prts"; 
1169 
val abs_minus_cancel = thm "abs_minus_cancel"; 

1170 
val abs_idempotent = thm "abs_idempotent"; 

1171 
val zero_le_iff_zero_nprt = thm "zero_le_iff_zero_nprt"; 

1172 
val le_zero_iff_zero_pprt = thm "le_zero_iff_zero_pprt"; 

1173 
val le_zero_iff_pprt_id = thm "le_zero_iff_pprt_id"; 

1174 
val zero_le_iff_nprt_id = thm "zero_le_iff_nprt_id"; 

1175 
val iff2imp = thm "iff2imp"; 

16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

1176 
(* val imp_abs_id = thm "imp_abs_id"; 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset

1177 
val imp_abs_neg_id = thm "imp_abs_neg_id"; *) 
14738  1178 
val abs_leI = thm "abs_leI"; 
1179 
val le_minus_self_iff = thm "le_minus_self_iff"; 

1180 
val minus_le_self_iff = thm "minus_le_self_iff"; 

1181 
val abs_le_D1 = thm "abs_le_D1"; 

1182 
val abs_le_D2 = thm "abs_le_D2"; 

1183 
val abs_le_iff = thm "abs_le_iff"; 

1184 
val abs_triangle_ineq = thm "abs_triangle_ineq"; 

1185 
val abs_diff_triangle_ineq = thm "abs_diff_triangle_ineq"; 

1186 
*} 

1187 

1188 
end 