author  obua 
Mon, 10 Apr 2006 16:00:34 +0200  
changeset 19404  9bf2cdc9e8e8 
parent 19233  77ca20b0ed77 
child 19527  9b5c38e8e780 
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 
15140  10 
imports Inductive LOrder 
16417  11 
uses "../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 

29 
axclass semigroup_add \<subseteq> plus 

30 
add_assoc: "(a + b) + c = a + (b + c)" 

31 

32 
axclass ab_semigroup_add \<subseteq> semigroup_add 

33 
add_commute: "a + b = b + a" 

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 

40 
axclass semigroup_mult \<subseteq> times 

41 
mult_assoc: "(a * b) * c = a * (b * c)" 

42 

43 
axclass ab_semigroup_mult \<subseteq> semigroup_mult 

44 
mult_commute: "a * b = b * a" 

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 

51 
axclass comm_monoid_add \<subseteq> zero, ab_semigroup_add 

52 
add_0[simp]: "0 + a = a" 

53 

54 
axclass monoid_mult \<subseteq> one, semigroup_mult 

55 
mult_1_left[simp]: "1 * a = a" 

56 
mult_1_right[simp]: "a * 1 = a" 

57 

58 
axclass comm_monoid_mult \<subseteq> one, ab_semigroup_mult 

59 
mult_1: "1 * a = a" 

60 

61 
instance comm_monoid_mult \<subseteq> monoid_mult 

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

63 

64 
axclass cancel_semigroup_add \<subseteq> semigroup_add 

65 
add_left_imp_eq: "a + b = a + c \<Longrightarrow> b = c" 

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

67 

68 
axclass cancel_ab_semigroup_add \<subseteq> ab_semigroup_add 

69 
add_imp_eq: "a + b = a + c \<Longrightarrow> b = c" 

70 

71 
instance cancel_ab_semigroup_add \<subseteq> cancel_semigroup_add 

72 
proof 

73 
{ 

74 
fix a b c :: 'a 

75 
assume "a + b = a + c" 

76 
thus "b = c" by (rule add_imp_eq) 

77 
} 

78 
note f = this 

79 
fix a b c :: 'a 

80 
assume "b + a = c + a" 

81 
hence "a + b = a + c" by (simp only: add_commute) 

82 
thus "b = c" by (rule f) 

83 
qed 

84 

85 
axclass ab_group_add \<subseteq> minus, comm_monoid_add 

86 
left_minus[simp]: "  a + a = 0" 

87 
diff_minus: "a  b = a + (b)" 

88 

89 
instance ab_group_add \<subseteq> cancel_ab_semigroup_add 

90 
proof 

91 
fix a b c :: 'a 

92 
assume "a + b = a + c" 

93 
hence "a + a + b = a + a + c" by (simp only: add_assoc) 

94 
thus "b = c" by simp 

95 
qed 

96 

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

98 
proof  

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

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

101 
finally show ?thesis . 

102 
qed 

103 

104 
lemma add_left_cancel [simp]: 

105 
"(a + b = a + c) = (b = (c::'a::cancel_semigroup_add))" 

106 
by (blast dest: add_left_imp_eq) 

107 

108 
lemma add_right_cancel [simp]: 

109 
"(b + a = c + a) = (b = (c::'a::cancel_semigroup_add))" 

110 
by (blast dest: add_right_imp_eq) 

111 

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

113 
proof  

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

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

116 
finally show ?thesis . 

117 
qed 

118 

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

120 
proof 

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

122 
also assume "a  b = 0" 

123 
finally show "a = b" by simp 

124 
next 

125 
assume "a = b" 

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

127 
qed 

128 

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

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

131 
show "(a + (a) = a + a)" 

132 
by simp 

133 
qed 

134 

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

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

137 
apply (simp add: diff_minus add_commute) 

138 
done 

139 

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

141 
by (simp add: equals_zero_I) 

142 

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

144 
by (simp add: diff_minus) 

145 

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

147 
by (simp add: diff_minus) 

148 

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

150 
by (simp add: diff_minus) 

151 

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

153 
by (simp add: diff_minus) 

154 

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

156 
proof 

157 
assume " a =  b" 

158 
hence " ( a) =  ( b)" 

159 
by simp 

160 
thus "a=b" by simp 

161 
next 

162 
assume "a=b" 

163 
thus "a = b" by simp 

164 
qed 

165 

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

167 
by (subst neg_equal_iff_equal [symmetric], simp) 

168 

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

170 
by (subst neg_equal_iff_equal [symmetric], simp) 

171 

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

173 

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

175 
proof  

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

177 
thus ?thesis by (simp add: eq_commute) 

178 
qed 

179 

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

181 
proof  

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

183 
thus ?thesis by (simp add: eq_commute) 

184 
qed 

185 

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

187 
apply (rule equals_zero_I) 

188 
apply (simp add: add_ac) 

189 
done 

190 

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

192 
by (simp add: diff_minus add_commute) 

193 

194 
subsection {* (Partially) Ordered Groups *} 

195 

196 
axclass pordered_ab_semigroup_add \<subseteq> order, ab_semigroup_add 

197 
add_left_mono: "a \<le> b \<Longrightarrow> c + a \<le> c + b" 

198 

199 
axclass pordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add, cancel_ab_semigroup_add 

200 

201 
instance pordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add .. 

202 

203 
axclass pordered_ab_semigroup_add_imp_le \<subseteq> pordered_cancel_ab_semigroup_add 

204 
add_le_imp_le_left: "c + a \<le> c + b \<Longrightarrow> a \<le> b" 

205 

206 
axclass pordered_ab_group_add \<subseteq> ab_group_add, pordered_ab_semigroup_add 

207 

208 
instance pordered_ab_group_add \<subseteq> pordered_ab_semigroup_add_imp_le 

209 
proof 

210 
fix a b c :: 'a 

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

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

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

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

215 
qed 

216 

217 
axclass ordered_cancel_ab_semigroup_add \<subseteq> pordered_cancel_ab_semigroup_add, linorder 

218 

219 
instance ordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add_imp_le 

220 
proof 

221 
fix a b c :: 'a 

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

223 
show "a <= b" 

224 
proof (rule ccontr) 

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

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

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

228 
have "a = b" 

229 
apply (insert le) 

230 
apply (insert le2) 

231 
apply (drule order_antisym, simp_all) 

232 
done 

233 
with w show False 

234 
by (simp add: linorder_not_le [symmetric]) 

235 
qed 

236 
qed 

237 

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

239 
by (simp add: add_commute[of _ c] add_left_mono) 

240 

241 
text {* nonstrict, in both arguments *} 

242 
lemma add_mono: 

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

244 
apply (erule add_right_mono [THEN order_trans]) 

245 
apply (simp add: add_commute add_left_mono) 

246 
done 

247 

248 
lemma add_strict_left_mono: 

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

250 
by (simp add: order_less_le add_left_mono) 

251 

252 
lemma add_strict_right_mono: 

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

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

255 

256 
text{*Strict monotonicity in both arguments*} 

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

258 
apply (erule add_strict_right_mono [THEN order_less_trans]) 

259 
apply (erule add_strict_left_mono) 

260 
done 

261 

262 
lemma add_less_le_mono: 

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

264 
apply (erule add_strict_right_mono [THEN order_less_le_trans]) 

265 
apply (erule add_left_mono) 

266 
done 

267 

268 
lemma add_le_less_mono: 

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

270 
apply (erule add_right_mono [THEN order_le_less_trans]) 

271 
apply (erule add_strict_left_mono) 

272 
done 

273 

274 
lemma add_less_imp_less_left: 

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

276 
proof  

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

278 
have "a <= b" 

279 
apply (insert le) 

280 
apply (drule add_le_imp_le_left) 

281 
by (insert le, drule add_le_imp_le_left, assumption) 

282 
moreover have "a \<noteq> b" 

283 
proof (rule ccontr) 

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

285 
then have "a = b" by simp 

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

287 
with less show "False"by simp 

288 
qed 

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

290 
qed 

291 

292 
lemma add_less_imp_less_right: 

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

294 
apply (rule add_less_imp_less_left [of c]) 

295 
apply (simp add: add_commute) 

296 
done 

297 

298 
lemma add_less_cancel_left [simp]: 

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

300 
by (blast intro: add_less_imp_less_left add_strict_left_mono) 

301 

302 
lemma add_less_cancel_right [simp]: 

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

304 
by (blast intro: add_less_imp_less_right add_strict_right_mono) 

305 

306 
lemma add_le_cancel_left [simp]: 

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

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

309 

310 
lemma add_le_cancel_right [simp]: 

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

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

313 

314 
lemma add_le_imp_le_right: 

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

316 
by simp 

317 

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

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

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

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

15539  323 
lemma add_increasing2: 
324 
fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}" 

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

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

327 

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

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

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

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

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

332 

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

333 
lemma add_strict_increasing2: 
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<c] ==> b < a + c" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

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

337 

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

338 

14738  339 
subsection {* Ordering Rules for Unary Minus *} 
340 

341 
lemma le_imp_neg_le: 

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

343 
proof  

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

345 
by (rule add_left_mono) 

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

347 
by simp 

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

349 
by (rule add_right_mono) 

350 
thus ?thesis 

351 
by (simp add: add_assoc) 

352 
qed 

353 

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

355 
proof 

356 
assume " b \<le>  a" 

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

358 
by (rule le_imp_neg_le) 

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

360 
next 

361 
assume "a\<le>b" 

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

363 
qed 

364 

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

366 
by (subst neg_le_iff_le [symmetric], simp) 

367 

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

369 
by (subst neg_le_iff_le [symmetric], simp) 

370 

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

372 
by (force simp add: order_less_le) 

373 

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

375 
by (subst neg_less_iff_less [symmetric], simp) 

376 

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

378 
by (subst neg_less_iff_less [symmetric], simp) 

379 

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

381 

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

383 
proof  

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

385 
thus ?thesis by simp 

386 
qed 

387 

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

389 
proof  

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

391 
thus ?thesis by simp 

392 
qed 

393 

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

395 
proof  

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

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

398 
apply (auto simp only: order_le_less) 

399 
apply (drule mm) 

400 
apply (simp_all) 

401 
apply (drule mm[simplified], assumption) 

402 
done 

403 
then show ?thesis by simp 

404 
qed 

405 

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

407 
by (auto simp add: order_le_less minus_less_iff) 

408 

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

410 
by (simp add: diff_minus add_ac) 

411 

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

413 
by (simp add: diff_minus add_ac) 

414 

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

416 
by (auto simp add: diff_minus add_assoc) 

417 

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

419 
by (auto simp add: diff_minus add_assoc) 

420 

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

422 
by (simp add: diff_minus add_ac) 

423 

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

425 
by (simp add: diff_minus add_ac) 

426 

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

428 
by (simp add: diff_minus add_ac) 

429 

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

431 
by (simp add: diff_minus add_ac) 

432 

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

433 
text{*Further subtraction laws*} 
14738  434 

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

436 
proof  

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

438 
by (simp only: add_less_cancel_right) 

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

440 
finally show ?thesis . 

441 
qed 

442 

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

15481  444 
apply (subst less_iff_diff_less_0 [of a]) 
14738  445 
apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst]) 
446 
apply (simp add: diff_minus add_ac) 

447 
done 

448 

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

15481  450 
apply (subst less_iff_diff_less_0 [of "a+b"]) 
451 
apply (subst less_iff_diff_less_0 [of a]) 

14738  452 
apply (simp add: diff_minus add_ac) 
453 
done 

454 

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

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

457 

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

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

460 

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

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

463 
Use with @{text add_ac}*} 

464 
lemmas compare_rls = 

465 
diff_minus [symmetric] 

466 
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 

467 
diff_less_eq less_diff_eq diff_le_eq le_diff_eq 

468 
diff_eq_eq eq_diff_eq 

469 

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

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

471 

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

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

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

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

475 
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

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

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

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

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

480 

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

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

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

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

484 
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

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

486 
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

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

488 

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

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

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

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

492 
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

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

494 
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

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

496 

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

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

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

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

500 
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

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

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

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

504 

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

505 
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

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

507 
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

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

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

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

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

512 

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

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

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

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

516 
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

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

518 
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

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

520 

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

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

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

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

524 
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

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

526 
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

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

528 

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

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

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

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

532 
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

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

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

535 
done 
14738  536 

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

538 

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

540 
by (simp add: compare_rls) 

541 

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

543 
by (simp add: compare_rls) 

544 

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

546 

547 
axclass lordered_ab_group_meet < pordered_ab_group_add, meet_semilorder 

548 

549 
axclass lordered_ab_group_join < pordered_ab_group_add, join_semilorder 

550 

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

552 
apply (rule order_antisym) 

553 
apply (rule meet_imp_le, simp_all add: meet_join_le) 

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

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

556 
apply (rule meet_imp_le) 

557 
apply (rule add_le_imp_le_left[of "a"], simp only: add_assoc[symmetric], simp add: meet_join_le)+ 

558 
done 

559 

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

561 
apply (rule order_antisym) 

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

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

564 
apply (rule join_imp_le) 

565 
apply (rule add_le_imp_le_left [of "a"], simp only: add_assoc[symmetric], simp add: meet_join_le)+ 

566 
apply (rule join_imp_le) 

567 
apply (simp_all add: meet_join_le) 

568 
done 

569 

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

571 
apply (auto simp add: is_join_def) 

572 
apply (rule_tac c="meet (a) (b)" in add_le_imp_le_right, simp, simp add: add_meet_distrib_left meet_join_le) 

573 
apply (rule_tac c="meet (a) (b)" in add_le_imp_le_right, simp, simp add: add_meet_distrib_left meet_join_le) 

574 
apply (subst neg_le_iff_le[symmetric]) 

575 
apply (simp add: meet_imp_le) 

576 
done 

577 

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

579 
apply (auto simp add: is_meet_def) 

580 
apply (rule_tac c="join (a) (b)" in add_le_imp_le_right, simp, simp add: add_join_distrib_left meet_join_le) 

581 
apply (rule_tac c="join (a) (b)" in add_le_imp_le_right, simp, simp add: add_join_distrib_left meet_join_le) 

582 
apply (subst neg_le_iff_le[symmetric]) 

583 
apply (simp add: join_imp_le) 

584 
done 

585 

586 
axclass lordered_ab_group \<subseteq> pordered_ab_group_add, lorder 

587 

588 
instance lordered_ab_group_meet \<subseteq> lordered_ab_group 

589 
proof 

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

591 
qed 

592 

593 
instance lordered_ab_group_join \<subseteq> lordered_ab_group 

594 
proof 

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

596 
qed 

597 

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

599 
proof  

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

601 
thus ?thesis by (simp add: add_commute) 

602 
qed 

603 

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

605 
proof  

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

607 
thus ?thesis by (simp add: add_commute) 

608 
qed 

609 

610 
lemmas add_meet_join_distribs = add_meet_distrib_right add_meet_distrib_left add_join_distrib_right add_join_distrib_left 

611 

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

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

614 

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

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

617 

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

619 
proof  

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

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

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

623 
apply (simp add: add_join_distrib_left add_meet_distrib_right) 

624 
by (simp add: diff_minus add_commute) 

625 
thus ?thesis 

626 
apply (simp add: compare_rls) 

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

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

629 
done 

630 
qed 

631 

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

633 

634 
constdefs 

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

636 
"pprt x == join x 0" 

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

638 
"nprt x == meet x 0" 

639 

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

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

642 

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

644 
by (simp add: pprt_def meet_join_le) 

645 

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

647 
by (simp add: nprt_def meet_join_le) 

648 

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

650 
proof  

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

652 
apply (auto) 

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

654 
apply (simp add: add_assoc) 

655 
done 

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

657 
apply (auto) 

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

659 
apply (simp) 

660 
done 

661 
from a b show ?thesis by blast 

662 
qed 

663 

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

666 

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

668 
by (simp add: pprt_def le_def_join join_aci) 

669 

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

671 
by (simp add: nprt_def le_def_meet meet_aci) 

672 

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

674 
by (simp add: pprt_def le_def_join join_aci) 

675 

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

677 
by (simp add: nprt_def le_def_meet meet_aci) 

678 

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

681 
{ 

682 
fix a::'a 

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

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

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

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

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

688 
} 

689 
note p = this 

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

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

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

693 
qed 

694 

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

696 
apply (simp add: meet_eq_neg_join) 

697 
apply (simp add: join_comm) 

15481  698 
apply (erule join_0_imp_0) 
699 
done 

14738  700 

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

702 
by (auto, erule join_0_imp_0) 

703 

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

705 
by (auto, erule meet_0_imp_0) 

706 

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

708 
proof 

709 
assume "0 <= a + a" 

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

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

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

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

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

715 
next 

716 
assume a: "0 <= a" 

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

718 
qed 

719 

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

721 
proof  

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

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

724 
ultimately show ?thesis by blast 

725 
qed 

726 

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

728 
proof cases 

729 
assume a: "a < 0" 

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

731 
next 

732 
assume "~(a < 0)" 

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

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

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

736 
with a show ?thesis by simp 

737 
qed 

738 

739 
axclass lordered_ab_group_abs \<subseteq> lordered_ab_group 

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

741 

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

743 
by (simp add: abs_lattice) 

744 

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

746 
by (simp add: abs_lattice) 

747 

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

749 
proof  

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

751 
thus ?thesis by simp 

752 
qed 

753 

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

755 
by (simp add: meet_eq_neg_join) 

756 

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

758 
by (simp del: neg_meet_eq_join add: join_eq_neg_meet) 

759 

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

761 
proof  

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

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

15197  764 
show ?thesis by (auto simp add: join_max max_def b linorder_not_less) 
14738  765 
qed 
766 

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

768 
proof  

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

770 
qed 

771 

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

773 
proof  

774 
have a:"a <= abs a" and b:"a <= abs a" by (auto simp add: abs_lattice meet_join_le) 

775 
show ?thesis by (rule add_mono[OF a b, simplified]) 

776 
qed 

777 

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

779 
proof 

780 
assume "abs a <= 0" 

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

782 
thus "a = 0" by simp 

783 
next 

784 
assume "a = 0" 

785 
thus "abs a <= 0" by simp 

786 
qed 

787 

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

789 
by (simp add: order_less_le) 

790 

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

792 
proof  

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

794 
show ?thesis by (simp add: a) 

795 
qed 

796 

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

798 
by (simp add: abs_lattice meet_join_le) 

799 

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

801 
by (simp add: abs_lattice meet_join_le) 

802 

803 
lemma le_imp_join_eq: "a \<le> b \<Longrightarrow> join a b = b" 

804 
by (simp add: le_def_join) 

805 

806 
lemma ge_imp_join_eq: "b \<le> a \<Longrightarrow> join a b = a" 

807 
by (simp add: le_def_join join_aci) 

808 

809 
lemma le_imp_meet_eq: "a \<le> b \<Longrightarrow> meet a b = a" 

810 
by (simp add: le_def_meet) 

811 

812 
lemma ge_imp_meet_eq: "b \<le> a \<Longrightarrow> meet a b = b" 

813 
by (simp add: le_def_meet meet_aci) 

814 

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

816 
apply (simp add: pprt_def nprt_def diff_minus) 

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

818 
apply (subst le_imp_join_eq, auto) 

819 
done 

820 

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

822 
by (simp add: abs_lattice join_comm) 

823 

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

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

826 
apply (subst ge_imp_join_eq) 

827 
apply (rule order_trans[of _ 0]) 

828 
by auto 

829 

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

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

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

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

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

834 
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

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

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

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

838 

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

841 

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

843 
by (simp add: le_def_join pprt_def join_comm) 

844 

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

846 
by (simp add: le_def_join pprt_def join_comm) 

847 

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

849 
by (simp add: le_def_meet nprt_def meet_comm) 

850 

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

853 

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

855 
by (simp add: le_def_meet nprt_def meet_aci) 

856 

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

859 

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

861 
by (simp add: pprt_def nprt_def) 

862 

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

865 

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

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

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

869 
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

870 
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

871 

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

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

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

875 
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

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

877 
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

878 

14738  879 
lemma abs_leI: "[a \<le> b; a \<le> b] ==> abs a \<le> (b::'a::lordered_ab_group_abs)" 
880 
by (simp add: abs_lattice join_imp_le) 

881 

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

883 
proof  

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

885 
by (simp add: add_assoc[symmetric]) 

886 
thus ?thesis by simp 

887 
qed 

888 

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

890 
proof  

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

892 
by (simp add: add_assoc[symmetric]) 

893 
thus ?thesis by simp 

894 
qed 

895 

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

897 
by (insert abs_ge_self, blast intro: order_trans) 

898 

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

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

901 

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

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

904 

15539  905 
lemma abs_triangle_ineq: "abs(a+b) \<le> abs a + abs(b::'a::lordered_ab_group_abs)" 
14738  906 
proof  
907 
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

908 
by (simp add: abs_lattice add_meet_join_distribs join_aci diff_minus) 
14738  909 
have a:"a+b <= join ?m ?n" by (simp add: meet_join_le) 
910 
have b:"ab <= ?n" by (simp add: meet_join_le) 

911 
have c:"?n <= join ?m ?n" by (simp add: meet_join_le) 

912 
from b c have d: "ab <= join ?m ?n" by simp 

913 
have e:"ab = (a+b)" by (simp add: diff_minus) 

914 
from a d e have "abs(a+b) <= join ?m ?n" 

915 
by (drule_tac abs_leI, auto) 

916 
with g[symmetric] show ?thesis by simp 

917 
qed 

918 

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

919 
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

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

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

922 
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

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

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

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

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

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

928 

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

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

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

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

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

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

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

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

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

937 

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

938 
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

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

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

941 
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

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

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

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

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

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

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

948 

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

951 
proof  

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

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

954 
finally show ?thesis . 

955 
qed 

956 

15539  957 
lemma abs_add_abs[simp]: 
958 
fixes a:: "'a::{lordered_ab_group_abs}" 

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

960 
proof (rule order_antisym) 

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

962 
next 

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

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

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

966 
qed 

967 

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

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

969 

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

970 
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

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

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

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

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

975 

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

976 
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

977 
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

978 
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

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

980 

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

981 
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

982 
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

983 

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

984 
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

985 
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

986 
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

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

988 

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

989 
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

990 
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

991 

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

992 
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

993 
by (simp add: diff_minus) 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset

994 

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

995 
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

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

997 

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

998 
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

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

1000 

15178  1001 
lemma le_add_right_mono: 
1002 
assumes 

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

1004 
"c <= d" 

1005 
shows "a <= b + d" 

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

1007 
apply (simp_all add: prems) 

1008 
done 

1009 

1010 
lemmas group_eq_simps = 

1011 
mult_ac 

1012 
add_ac 

1013 
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 

1014 
diff_eq_eq eq_diff_eq 

1015 

1016 
lemma estimate_by_abs: 

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

1018 
proof  

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

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

1021 
apply (insert 1) 

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

1023 
apply (simp add: group_eq_simps) 

1024 
done 

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

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

1027 
qed 

1028 

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

1031 
lemmas diff_eq_0_iff_eq = eq_iff_diff_eq_0 [symmetric] 

1032 
lemmas diff_le_0_iff_le = le_iff_diff_le_0 [symmetric] 

1033 
declare diff_less_0_iff_less [simp] 

1034 
declare diff_eq_0_iff_eq [simp] 

1035 
declare diff_le_0_iff_le [simp] 

1036 

1037 

19404  1038 

1039 

14738  1040 
ML {* 
1041 
val add_zero_left = thm"add_0"; 

1042 
val add_zero_right = thm"add_0_right"; 

1043 
*} 

1044 

1045 
ML {* 

1046 
val add_assoc = thm "add_assoc"; 

1047 
val add_commute = thm "add_commute"; 

1048 
val add_left_commute = thm "add_left_commute"; 

1049 
val add_ac = thms "add_ac"; 

1050 
val mult_assoc = thm "mult_assoc"; 

1051 
val mult_commute = thm "mult_commute"; 

1052 
val mult_left_commute = thm "mult_left_commute"; 

1053 
val mult_ac = thms "mult_ac"; 

1054 
val add_0 = thm "add_0"; 

1055 
val mult_1_left = thm "mult_1_left"; 

1056 
val mult_1_right = thm "mult_1_right"; 

1057 
val mult_1 = thm "mult_1"; 

1058 
val add_left_imp_eq = thm "add_left_imp_eq"; 

1059 
val add_right_imp_eq = thm "add_right_imp_eq"; 

1060 
val add_imp_eq = thm "add_imp_eq"; 

1061 
val left_minus = thm "left_minus"; 

1062 
val diff_minus = thm "diff_minus"; 

1063 
val add_0_right = thm "add_0_right"; 

1064 
val add_left_cancel = thm "add_left_cancel"; 

1065 
val add_right_cancel = thm "add_right_cancel"; 

1066 
val right_minus = thm "right_minus"; 

1067 
val right_minus_eq = thm "right_minus_eq"; 

1068 
val minus_minus = thm "minus_minus"; 

1069 
val equals_zero_I = thm "equals_zero_I"; 

1070 
val minus_zero = thm "minus_zero"; 

1071 
val diff_self = thm "diff_self"; 

1072 
val diff_0 = thm "diff_0"; 

1073 
val diff_0_right = thm "diff_0_right"; 

1074 
val diff_minus_eq_add = thm "diff_minus_eq_add"; 

1075 
val neg_equal_iff_equal = thm "neg_equal_iff_equal"; 

1076 
val neg_equal_0_iff_equal = thm "neg_equal_0_iff_equal"; 

1077 
val neg_0_equal_iff_equal = thm "neg_0_equal_iff_equal"; 

1078 
val equation_minus_iff = thm "equation_minus_iff"; 

1079 
val minus_equation_iff = thm "minus_equation_iff"; 

1080 
val minus_add_distrib = thm "minus_add_distrib"; 

1081 
val minus_diff_eq = thm "minus_diff_eq"; 

1082 
val add_left_mono = thm "add_left_mono"; 

1083 
val add_le_imp_le_left = thm "add_le_imp_le_left"; 

1084 
val add_right_mono = thm "add_right_mono"; 

1085 
val add_mono = thm "add_mono"; 

1086 
val add_strict_left_mono = thm "add_strict_left_mono"; 

1087 
val add_strict_right_mono = thm "add_strict_right_mono"; 

1088 
val add_strict_mono = thm "add_strict_mono"; 

1089 
val add_less_le_mono = thm "add_less_le_mono"; 

1090 
val add_le_less_mono = thm "add_le_less_mono"; 

1091 
val add_less_imp_less_left = thm "add_less_imp_less_left"; 

1092 
val add_less_imp_less_right = thm "add_less_imp_less_right"; 

1093 
val add_less_cancel_left = thm "add_less_cancel_left"; 

1094 
val add_less_cancel_right = thm "add_less_cancel_right"; 

1095 
val add_le_cancel_left = thm "add_le_cancel_left"; 

1096 
val add_le_cancel_right = thm "add_le_cancel_right"; 

1097 
val add_le_imp_le_right = thm "add_le_imp_le_right"; 

1098 
val add_increasing = thm "add_increasing"; 

1099 
val le_imp_neg_le = thm "le_imp_neg_le"; 

1100 
val neg_le_iff_le = thm "neg_le_iff_le"; 

1101 
val neg_le_0_iff_le = thm "neg_le_0_iff_le"; 

1102 
val neg_0_le_iff_le = thm "neg_0_le_iff_le"; 

1103 
val neg_less_iff_less = thm "neg_less_iff_less"; 

1104 
val neg_less_0_iff_less = thm "neg_less_0_iff_less"; 

1105 
val neg_0_less_iff_less = thm "neg_0_less_iff_less"; 

1106 
val less_minus_iff = thm "less_minus_iff"; 

1107 
val minus_less_iff = thm "minus_less_iff"; 

1108 
val le_minus_iff = thm "le_minus_iff"; 

1109 
val minus_le_iff = thm "minus_le_iff"; 

1110 
val add_diff_eq = thm "add_diff_eq"; 

1111 
val diff_add_eq = thm "diff_add_eq"; 

1112 
val diff_eq_eq = thm "diff_eq_eq"; 

1113 
val eq_diff_eq = thm "eq_diff_eq"; 

1114 
val diff_diff_eq = thm "diff_diff_eq"; 

1115 
val diff_diff_eq2 = thm "diff_diff_eq2"; 

1116 
val diff_add_cancel = thm "diff_add_cancel"; 

1117 
val add_diff_cancel = thm "add_diff_cancel"; 

1118 
val less_iff_diff_less_0 = thm "less_iff_diff_less_0"; 

1119 
val diff_less_eq = thm "diff_less_eq"; 

1120 
val less_diff_eq = thm "less_diff_eq"; 

1121 
val diff_le_eq = thm "diff_le_eq"; 

1122 
val le_diff_eq = thm "le_diff_eq"; 

1123 
val compare_rls = thms "compare_rls"; 

1124 
val eq_iff_diff_eq_0 = thm "eq_iff_diff_eq_0"; 

1125 
val le_iff_diff_le_0 = thm "le_iff_diff_le_0"; 

1126 
val add_meet_distrib_left = thm "add_meet_distrib_left"; 

1127 
val add_join_distrib_left = thm "add_join_distrib_left"; 

1128 
val is_join_neg_meet = thm "is_join_neg_meet"; 

1129 
val is_meet_neg_join = thm "is_meet_neg_join"; 

1130 
val add_join_distrib_right = thm "add_join_distrib_right"; 

1131 
val add_meet_distrib_right = thm "add_meet_distrib_right"; 

1132 
val add_meet_join_distribs = thms "add_meet_join_distribs"; 

1133 
val join_eq_neg_meet = thm "join_eq_neg_meet"; 

1134 
val meet_eq_neg_join = thm "meet_eq_neg_join"; 

1135 
val add_eq_meet_join = thm "add_eq_meet_join"; 

1136 
val prts = thm "prts"; 

1137 
val zero_le_pprt = thm "zero_le_pprt"; 

1138 
val nprt_le_zero = thm "nprt_le_zero"; 

1139 
val le_eq_neg = thm "le_eq_neg"; 

1140 
val join_0_imp_0 = thm "join_0_imp_0"; 

1141 
val meet_0_imp_0 = thm "meet_0_imp_0"; 

1142 
val join_0_eq_0 = thm "join_0_eq_0"; 

1143 
val meet_0_eq_0 = thm "meet_0_eq_0"; 

1144 
val zero_le_double_add_iff_zero_le_single_add = thm "zero_le_double_add_iff_zero_le_single_add"; 

1145 
val double_add_le_zero_iff_single_add_le_zero = thm "double_add_le_zero_iff_single_add_le_zero"; 

1146 
val double_add_less_zero_iff_single_less_zero = thm "double_add_less_zero_iff_single_less_zero"; 

1147 
val abs_lattice = thm "abs_lattice"; 

1148 
val abs_zero = thm "abs_zero"; 

1149 
val abs_eq_0 = thm "abs_eq_0"; 

1150 
val abs_0_eq = thm "abs_0_eq"; 

1151 
val neg_meet_eq_join = thm "neg_meet_eq_join"; 

1152 
val neg_join_eq_meet = thm "neg_join_eq_meet"; 

1153 
val join_eq_if = thm "join_eq_if"; 

1154 
val abs_if_lattice = thm "abs_if_lattice"; 

1155 
val abs_ge_zero = thm "abs_ge_zero"; 

1156 
val abs_le_zero_iff = thm "abs_le_zero_iff"; 

1157 
val zero_less_abs_iff = thm "zero_less_abs_iff"; 

1158 
val abs_not_less_zero = thm "abs_not_less_zero"; 

1159 
val abs_ge_self = thm "abs_ge_self"; 

1160 
val abs_ge_minus_self = thm "abs_ge_minus_self"; 

1161 
val le_imp_join_eq = thm "le_imp_join_eq"; 

1162 
val ge_imp_join_eq = thm "ge_imp_join_eq"; 

1163 
val le_imp_meet_eq = thm "le_imp_meet_eq"; 

1164 
val ge_imp_meet_eq = thm "ge_imp_meet_eq"; 

1165 
val abs_prts = thm "abs_prts"; 

1166 
val abs_minus_cancel = thm "abs_minus_cancel"; 

1167 
val abs_idempotent = thm "abs_idempotent"; 

1168 
val zero_le_iff_zero_nprt = thm "zero_le_iff_zero_nprt"; 

1169 
val le_zero_iff_zero_pprt = thm "le_zero_iff_zero_pprt"; 

1170 
val le_zero_iff_pprt_id = thm "le_zero_iff_pprt_id"; 

1171 
val zero_le_iff_nprt_id = thm "zero_le_iff_nprt_id"; 

1172 
val iff2imp = thm "iff2imp"; 

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

1173 
(* 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

1174 
val imp_abs_neg_id = thm "imp_abs_neg_id"; *) 
14738  1175 
val abs_leI = thm "abs_leI"; 
1176 
val le_minus_self_iff = thm "le_minus_self_iff"; 

1177 
val minus_le_self_iff = thm "minus_le_self_iff"; 

1178 
val abs_le_D1 = thm "abs_le_D1"; 

1179 
val abs_le_D2 = thm "abs_le_D2"; 

1180 
val abs_le_iff = thm "abs_le_iff"; 

1181 
val abs_triangle_ineq = thm "abs_triangle_ineq"; 

1182 
val abs_diff_triangle_ineq = thm "abs_diff_triangle_ineq"; 

1183 
*} 

1184 

1185 
end 