author  haftmann 
Tue, 20 Mar 2007 15:52:39 +0100  
changeset 22482  8fc3d7237e03 
parent 22452  8a86fd2a1bf0 
child 22548  6ce4bddf3bcb 
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 
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

10 
imports Lattices 
19798  11 
uses "~~/src/Provers/Arith/abel_cancel.ML" 
15131  12 
begin 
14738  13 

14 
text {* 

15 
The theory of partially ordered groups is taken from the books: 

16 
\begin{itemize} 

17 
\item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979 

18 
\item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963 

19 
\end{itemize} 

20 
Most of the used notions can also be looked up in 

21 
\begin{itemize} 

14770  22 
\item \url{http://www.mathworld.com} by Eric Weisstein et. al. 
14738  23 
\item \emph{Algebra I} by van der Waerden, Springer. 
24 
\end{itemize} 

25 
*} 

26 

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 + 
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

206 
assumes add_le_imp_le_left: "c \<^loc>+ a \<sqsubseteq> c \<^loc>+ 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 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

567 

14738  568 
subsection {* Lattice Ordered (Abelian) Groups *} 
569 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

570 
class lordered_ab_group_meet = pordered_ab_group_add + lower_semilattice 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

571 

8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

572 
class lordered_ab_group_join = pordered_ab_group_add + upper_semilattice 
14738  573 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

574 
class lordered_ab_group = pordered_ab_group_add + lattice 
14738  575 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

576 
instance lordered_ab_group \<subseteq> lordered_ab_group_meet by default 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

577 
instance lordered_ab_group \<subseteq> lordered_ab_group_join by default 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

578 

8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

579 
lemma add_inf_distrib_left: "a + inf b c = inf (a + b) (a + (c::'a::{pordered_ab_group_add, lower_semilattice}))" 
14738  580 
apply (rule order_antisym) 
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

581 
apply (simp_all add: le_infI) 
14738  582 
apply (rule add_le_imp_le_left [of "a"]) 
583 
apply (simp only: add_assoc[symmetric], simp) 

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

14738  586 
done 
587 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

588 
lemma add_sup_distrib_left: "a + sup b c = sup (a + b) (a+ (c::'a::{pordered_ab_group_add, upper_semilattice}))" 
14738  589 
apply (rule order_antisym) 
590 
apply (rule add_le_imp_le_left [of "a"]) 

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

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

594 
apply (rule le_supI) 
21312  595 
apply (simp_all) 
14738  596 
done 
597 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

598 
lemma add_inf_distrib_right: "inf a b + (c::'a::lordered_ab_group) = inf (a+c) (b+c)" 
14738  599 
proof  
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

600 
have "c + inf a b = inf (c+a) (c+b)" by (simp add: add_inf_distrib_left) 
14738  601 
thus ?thesis by (simp add: add_commute) 
602 
qed 

603 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

604 
lemma add_sup_distrib_right: "sup a b + (c::'a::lordered_ab_group) = sup (a+c) (b+c)" 
14738  605 
proof  
22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

606 
have "c + sup a b = sup (c+a) (c+b)" by (simp add: add_sup_distrib_left) 
14738  607 
thus ?thesis by (simp add: add_commute) 
608 
qed 

609 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

610 
lemmas add_sup_inf_distribs = add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left 
14738  611 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

612 
lemma inf_eq_neg_sup: "inf a (b\<Colon>'a\<Colon>lordered_ab_group) =  sup (a) (b)" 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

613 
proof (rule inf_unique) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

614 
fix a b :: 'a 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

615 
show " sup (a) (b) \<le> a" by (rule add_le_imp_le_right [of _ "sup (a) (b)"]) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

616 
(simp, simp add: add_sup_distrib_left) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

617 
next 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

618 
fix a b :: 'a 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

619 
show " sup (a) (b) \<le> b" by (rule add_le_imp_le_right [of _ "sup (a) (b)"]) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

620 
(simp, simp add: add_sup_distrib_left) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

621 
next 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

622 
fix a b c :: 'a 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

623 
assume "a \<le> b" "a \<le> c" 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

624 
then show "a \<le>  sup (b) (c)" by (subst neg_le_iff_le [symmetric]) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

625 
(simp add: le_supI) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

626 
qed 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

627 

8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

628 
lemma sup_eq_neg_inf: "sup a (b\<Colon>'a\<Colon>lordered_ab_group) =  inf (a) (b)" 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

629 
proof (rule sup_unique) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

630 
fix a b :: 'a 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

631 
show "a \<le>  inf (a) (b)" by (rule add_le_imp_le_right [of _ "inf (a) (b)"]) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

632 
(simp, simp add: add_inf_distrib_left) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

633 
next 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

634 
fix a b :: 'a 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

635 
show "b \<le>  inf (a) (b)" by (rule add_le_imp_le_right [of _ "inf (a) (b)"]) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

636 
(simp, simp add: add_inf_distrib_left) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

637 
next 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

638 
fix a b c :: 'a 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

639 
assume "a \<le> c" "b \<le> c" 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

640 
then show " inf (a) (b) \<le> c" by (subst neg_le_iff_le [symmetric]) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

641 
(simp add: le_infI) 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

642 
qed 
14738  643 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

644 
lemma add_eq_inf_sup: "a + b = sup a b + inf a (b\<Colon>'a\<Colon>lordered_ab_group)" 
14738  645 
proof  
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

646 
have "0 =  inf 0 (ab) + inf (ab) 0" by (simp add: inf_commute) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

647 
hence "0 = sup 0 (ba) + inf (ab) 0" by (simp add: inf_eq_neg_sup) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

648 
hence "0 = (a + sup a b) + (inf a b + (b))" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

649 
apply (simp add: add_sup_distrib_left add_inf_distrib_right) 
14738  650 
by (simp add: diff_minus add_commute) 
651 
thus ?thesis 

652 
apply (simp add: compare_rls) 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

653 
apply (subst add_left_cancel[symmetric, of "a+b" "sup a b + inf a b" "a"]) 
14738  654 
apply (simp only: add_assoc, simp add: add_assoc[symmetric]) 
655 
done 

656 
qed 

657 

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

659 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

660 
definition 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

661 
nprt :: "'a \<Rightarrow> ('a::lordered_ab_group)" where 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

662 
"nprt x = inf x 0" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

663 

ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

664 
definition 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

665 
pprt :: "'a \<Rightarrow> ('a::lordered_ab_group)" where 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

666 
"pprt x = sup x 0" 
14738  667 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

669 
by (simp add: pprt_def nprt_def add_eq_inf_sup[symmetric]) 
14738  670 

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

21312  672 
by (simp add: pprt_def) 
14738  673 

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

21312  675 
by (simp add: nprt_def) 
14738  676 

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

678 
proof  

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

680 
apply (auto) 

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

682 
apply (simp add: add_assoc) 

683 
done 

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

685 
apply (auto) 

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

687 
apply (simp) 

688 
done 

689 
from a b show ?thesis by blast 

690 
qed 

691 

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

694 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

696 
by (simp add: pprt_def le_iff_sup sup_aci) 
15580  697 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

699 
by (simp add: nprt_def le_iff_inf inf_aci) 
15580  700 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

702 
by (simp add: pprt_def le_iff_sup sup_aci) 
15580  703 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

705 
by (simp add: nprt_def le_iff_inf inf_aci) 
15580  706 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

707 
lemma sup_0_imp_0: "sup a (a) = 0 \<Longrightarrow> a = (0::'a::lordered_ab_group)" 
14738  708 
proof  
709 
{ 

710 
fix a::'a 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

711 
assume hyp: "sup a (a) = 0" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

712 
hence "sup a (a) + a = a" by (simp) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

713 
hence "sup (a+a) 0 = a" by (simp add: add_sup_distrib_right) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

714 
hence "sup (a+a) 0 <= a" by (simp) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

715 
hence "0 <= a" by (blast intro: order_trans inf_sup_ord) 
14738  716 
} 
717 
note p = this 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

718 
assume hyp:"sup a (a) = 0" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

719 
hence hyp2:"sup (a) ((a)) = 0" by (simp add: sup_commute) 
14738  720 
from p[OF hyp] p[OF hyp2] show "a = 0" by simp 
721 
qed 

722 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

723 
lemma inf_0_imp_0: "inf a (a) = 0 \<Longrightarrow> a = (0::'a::lordered_ab_group)" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

724 
apply (simp add: inf_eq_neg_sup) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

725 
apply (simp add: sup_commute) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

726 
apply (erule sup_0_imp_0) 
15481  727 
done 
14738  728 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

729 
lemma inf_0_eq_0[simp]: "(inf a (a) = 0) = (a = (0::'a::lordered_ab_group))" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

730 
by (auto, erule inf_0_imp_0) 
14738  731 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

732 
lemma sup_0_eq_0[simp]: "(sup a (a) = 0) = (a = (0::'a::lordered_ab_group))" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

733 
by (auto, erule sup_0_imp_0) 
14738  734 

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

736 
proof 

737 
assume "0 <= a + a" 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

738 
hence a:"inf (a+a) 0 = 0" by (simp add: le_iff_inf inf_commute) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

739 
have "(inf a 0)+(inf a 0) = inf (inf (a+a) 0) a" (is "?l=_") by (simp add: add_sup_inf_distribs inf_aci) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

740 
hence "?l = 0 + inf a 0" by (simp add: a, simp add: inf_commute) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

741 
hence "inf a 0 = 0" by (simp only: add_right_cancel) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

742 
then show "0 <= a" by (simp add: le_iff_inf inf_commute) 
14738  743 
next 
744 
assume a: "0 <= a" 

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

746 
qed 

747 

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

749 
proof  

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

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

752 
ultimately show ?thesis by blast 

753 
qed 

754 

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

756 
proof cases 

757 
assume a: "a < 0" 

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

759 
next 

760 
assume "~(a < 0)" 

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

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

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

764 
with a show ?thesis by simp 

765 
qed 

766 

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

767 
class lordered_ab_group_abs = lordered_ab_group + 
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

768 
assumes abs_lattice: "abs x = sup x (uminus x)" 
14738  769 

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

771 
by (simp add: abs_lattice) 

772 

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

774 
by (simp add: abs_lattice) 

775 

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

777 
proof  

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

779 
thus ?thesis by simp 

780 
qed 

781 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

782 
lemma neg_inf_eq_sup[simp]: " inf a (b::_::lordered_ab_group) = sup (a) (b)" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

783 
by (simp add: inf_eq_neg_sup) 
14738  784 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

785 
lemma neg_sup_eq_inf[simp]: " sup a (b::_::lordered_ab_group) = inf (a) (b)" 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

786 
by (simp del: neg_inf_eq_sup add: sup_eq_neg_inf) 
14738  787 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

788 
lemma sup_eq_if: "sup a (a) = (if a < 0 then a else (a::'a::{lordered_ab_group, linorder}))" 
14738  789 
proof  
790 
note b = add_le_cancel_right[of a a "a",symmetric,simplified] 

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

22452
8a86fd2a1bf0
adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents:
22422
diff
changeset

792 
show ?thesis by (auto simp add: max_def b linorder_not_less sup_max) 
14738  793 
qed 
794 

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

796 
proof  

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

797 
show ?thesis by (simp add: abs_lattice sup_eq_if) 
14738  798 
qed 
799 

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

801 
proof  

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

805 

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

807 
proof 

808 
assume "abs a <= 0" 

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

810 
thus "a = 0" by simp 

811 
next 

812 
assume "a = 0" 

813 
thus "abs a <= 0" by simp 

814 
qed 

815 

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

817 
by (simp add: order_less_le) 

818 

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

820 
proof  

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

822 
show ?thesis by (simp add: a) 

823 
qed 

824 

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

21312  826 
by (simp add: abs_lattice) 
14738  827 

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

21312  829 
by (simp add: abs_lattice) 
14738  830 

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

832 
apply (simp add: pprt_def nprt_def diff_minus) 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

833 
apply (simp add: add_sup_inf_distribs sup_aci abs_lattice[symmetric]) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

834 
apply (subst sup_absorb2, auto) 
14738  835 
done 
836 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

838 
by (simp add: abs_lattice sup_commute) 
14738  839 

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

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

842 
apply (subst sup_absorb1) 
14738  843 
apply (rule order_trans[of _ 0]) 
844 
by auto 

845 

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

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

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

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

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

850 
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

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

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

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

854 

14738  855 
lemma zero_le_iff_zero_nprt: "(0 \<le> a) = (nprt a = 0)" 
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

856 
by (simp add: le_iff_inf nprt_def inf_commute) 
14738  857 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

859 
by (simp add: le_iff_sup pprt_def sup_commute) 
14738  860 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

862 
by (simp add: le_iff_sup pprt_def sup_commute) 
14738  863 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

865 
by (simp add: le_iff_inf nprt_def inf_commute) 
14738  866 

15580  867 
lemma pprt_mono[simp]: "(a::_::lordered_ab_group) <= b \<Longrightarrow> pprt a <= pprt b" 
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

868 
by (simp add: le_iff_sup pprt_def sup_aci) 
15580  869 

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

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

871 
by (simp add: le_iff_inf nprt_def inf_aci) 
15580  872 

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

875 

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

877 
by (simp add: pprt_def nprt_def) 

878 

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

881 

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

882 
lemma abs_of_nonneg [simp]: "0 \<le> a \<Longrightarrow> abs a = (a::'a::lordered_ab_group_abs)" 
14738  883 
by (simp add: iff2imp[OF zero_le_iff_zero_nprt] iff2imp[OF le_zero_iff_pprt_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_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

886 
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

887 

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

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

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

891 
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

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

893 
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

894 

14738  895 
lemma abs_leI: "[a \<le> b; a \<le> b] ==> abs a \<le> (b::'a::lordered_ab_group_abs)" 
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

896 
by (simp add: abs_lattice le_supI) 
14738  897 

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

899 
proof  

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

901 
by (simp add: add_assoc[symmetric]) 

902 
thus ?thesis by simp 

903 
qed 

904 

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

906 
proof  

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

908 
by (simp add: add_assoc[symmetric]) 

909 
thus ?thesis by simp 

910 
qed 

911 

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

913 
by (insert abs_ge_self, blast intro: order_trans) 

914 

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

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

917 

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

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

920 

15539  921 
lemma abs_triangle_ineq: "abs(a+b) \<le> abs a + abs(b::'a::lordered_ab_group_abs)" 
14738  922 
proof  
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

923 
have g:"abs a + abs b = sup (a+b) (sup (ab) (sup (a+b) (a + (b))))" (is "_=sup ?m ?n") 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

924 
by (simp add: abs_lattice add_sup_inf_distribs sup_aci diff_minus) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

925 
have a:"a+b <= sup ?m ?n" by (simp) 
21312  926 
have b:"ab <= ?n" by (simp) 
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

927 
have c:"?n <= sup ?m ?n" by (simp) 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

928 
from b c have d: "ab <= sup ?m ?n" by(rule order_trans) 
14738  929 
have e:"ab = (a+b)" by (simp add: diff_minus) 
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

930 
from a d e have "abs(a+b) <= sup ?m ?n" 
14738  931 
by (drule_tac abs_leI, auto) 
932 
with g[symmetric] show ?thesis by simp 

933 
qed 

934 

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

935 
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

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

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

938 
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

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

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

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

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

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

944 

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

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

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

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

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

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

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

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

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

953 

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

954 
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

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

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

957 
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

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

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

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

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

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

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

964 

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

967 
proof  

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

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

970 
finally show ?thesis . 

971 
qed 

972 

15539  973 
lemma abs_add_abs[simp]: 
974 
fixes a:: "'a::{lordered_ab_group_abs}" 

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

976 
proof (rule order_antisym) 

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

978 
next 

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

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

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

982 
qed 

983 

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

984 
text {* Needed for abelian cancellation simprocs: *} 
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_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

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

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

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

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

993 
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

994 
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

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

996 

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

997 
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

998 
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

999 

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

1000 
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

1001 
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

1002 
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

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

1004 

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

1005 
lemma 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

1006 
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

1007 

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

1008 
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

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

1010 

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

1011 
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

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

1013 

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

1014 
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

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

1016 

15178  1017 
lemma le_add_right_mono: 
1018 
assumes 

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

1020 
"c <= d" 

1021 
shows "a <= b + d" 

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

1023 
apply (simp_all add: prems) 

1024 
done 

1025 

1026 
lemmas group_eq_simps = 

1027 
mult_ac 

1028 
add_ac 

1029 
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 

1030 
diff_eq_eq eq_diff_eq 

1031 

1032 
lemma estimate_by_abs: 

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

1034 
proof  

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

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

1037 
apply (insert 1) 

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

1039 
apply (simp add: group_eq_simps) 

1040 
done 

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

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

1043 
qed 

1044 

22482  1045 

1046 
subsection {* Tools setup *} 

1047 

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

1050 
lemmas diff_eq_0_iff_eq = eq_iff_diff_eq_0 [symmetric] 

1051 
lemmas diff_le_0_iff_le = le_iff_diff_le_0 [symmetric] 

1052 
declare diff_less_0_iff_less [simp] 

1053 
declare diff_eq_0_iff_eq [simp] 

1054 
declare diff_le_0_iff_le [simp] 

1055 

22482  1056 
ML {* 
1057 
structure ab_group_add_cancel = Abel_Cancel( 

1058 
struct 

1059 

1060 
(* term order for abelian groups *) 

1061 

1062 
fun agrp_ord (Const (a, _)) = find_index (fn a' => a = a') 

1063 
["HOL.zero", "HOL.plus", "HOL.uminus", "HOL.minus"] 

1064 
 agrp_ord _ = ~1; 

1065 

1066 
fun termless_agrp (a, b) = (Term.term_lpo agrp_ord (a, b) = LESS); 

1067 

1068 
local 

1069 
val ac1 = mk_meta_eq @{thm add_assoc}; 

1070 
val ac2 = mk_meta_eq @{thm add_commute}; 

1071 
val ac3 = mk_meta_eq @{thm add_left_commute}; 

1072 
fun solve_add_ac thy _ (_ $ (Const ("HOL.plus",_) $ _ $ _) $ _) = 

1073 
SOME ac1 

1074 
 solve_add_ac thy _ (_ $ x $ (Const ("HOL.plus",_) $ y $ z)) = 

1075 
if termless_agrp (y, x) then SOME ac3 else NONE 

1076 
 solve_add_ac thy _ (_ $ x $ y) = 

1077 
if termless_agrp (y, x) then SOME ac2 else NONE 

1078 
 solve_add_ac thy _ _ = NONE 

1079 
in 

1080 
val add_ac_proc = Simplifier.simproc @{theory} 

1081 
"add_ac_proc" ["x + y::'a::ab_semigroup_add"] solve_add_ac; 

1082 
end; 

1083 

1084 
val cancel_ss = HOL_basic_ss settermless termless_agrp 

1085 
addsimprocs [add_ac_proc] addsimps 

1086 
[@{thm add_0}, @{thm add_0_right}, @{thm diff_def}, 

1087 
@{thm minus_add_distrib}, @{thm minus_minus}, @{thm minus_zero}, 

1088 
@{thm right_minus}, @{thm left_minus}, @{thm add_minus_cancel}, 

1089 
@{thm minus_add_cancel}]; 

1090 

1091 
val eq_reflection = @{thm eq_reflection} 

1092 

1093 
val thy_ref = Theory.self_ref @{theory} 

1094 

1095 
val T = TFree("'a", ["OrderedGroup.ab_group_add"]) 

1096 

1097 
val eqI_rules = [@{thm less_eqI}, @{thm le_eqI}, @{thm eq_eqI}] 

1098 

1099 
val dest_eqI = 

1100 
fst o HOLogic.dest_bin "op =" HOLogic.boolT o HOLogic.dest_Trueprop o concl_of; 

1101 

1102 
end); 

1103 
*} 

1104 

1105 
ML_setup {* 

1106 
Addsimprocs [ab_group_add_cancel.sum_conv, ab_group_add_cancel.rel_conv]; 

1107 
*} 

17085  1108 

14738  1109 
ML {* 
1110 
val add_assoc = thm "add_assoc"; 

1111 
val add_commute = thm "add_commute"; 

1112 
val add_left_commute = thm "add_left_commute"; 

1113 
val add_ac = thms "add_ac"; 

1114 
val mult_assoc = thm "mult_assoc"; 

1115 
val mult_commute = thm "mult_commute"; 

1116 
val mult_left_commute = thm "mult_left_commute"; 

1117 
val mult_ac = thms "mult_ac"; 

1118 
val add_0 = thm "add_0"; 

1119 
val mult_1_left = thm "mult_1_left"; 

1120 
val mult_1_right = thm "mult_1_right"; 

1121 
val mult_1 = thm "mult_1"; 

1122 
val add_left_imp_eq = thm "add_left_imp_eq"; 

1123 
val add_right_imp_eq = thm "add_right_imp_eq"; 

1124 
val add_imp_eq = thm "add_imp_eq"; 

1125 
val left_minus = thm "left_minus"; 

1126 
val diff_minus = thm "diff_minus"; 

1127 
val add_0_right = thm "add_0_right"; 

1128 
val add_left_cancel = thm "add_left_cancel"; 

1129 
val add_right_cancel = thm "add_right_cancel"; 

1130 
val right_minus = thm "right_minus"; 

1131 
val right_minus_eq = thm "right_minus_eq"; 

1132 
val minus_minus = thm "minus_minus"; 

1133 
val equals_zero_I = thm "equals_zero_I"; 

1134 
val minus_zero = thm "minus_zero"; 

1135 
val diff_self = thm "diff_self"; 

1136 
val diff_0 = thm "diff_0"; 

1137 
val diff_0_right = thm "diff_0_right"; 

1138 
val diff_minus_eq_add = thm "diff_minus_eq_add"; 

1139 
val neg_equal_iff_equal = thm "neg_equal_iff_equal"; 

1140 
val neg_equal_0_iff_equal = thm "neg_equal_0_iff_equal"; 

1141 
val neg_0_equal_iff_equal = thm "neg_0_equal_iff_equal"; 

1142 
val equation_minus_iff = thm "equation_minus_iff"; 

1143 
val minus_equation_iff = thm "minus_equation_iff"; 

1144 
val minus_add_distrib = thm "minus_add_distrib"; 

1145 
val minus_diff_eq = thm "minus_diff_eq"; 

1146 
val add_left_mono = thm "add_left_mono"; 

1147 
val add_le_imp_le_left = thm "add_le_imp_le_left"; 

1148 
val add_right_mono = thm "add_right_mono"; 

1149 
val add_mono = thm "add_mono"; 

1150 
val add_strict_left_mono = thm "add_strict_left_mono"; 

1151 
val add_strict_right_mono = thm "add_strict_right_mono"; 

1152 
val add_strict_mono = thm "add_strict_mono"; 

1153 
val add_less_le_mono = thm "add_less_le_mono"; 

1154 
val add_le_less_mono = thm "add_le_less_mono"; 

1155 
val add_less_imp_less_left = thm "add_less_imp_less_left"; 

1156 
val add_less_imp_less_right = thm "add_less_imp_less_right"; 

1157 
val add_less_cancel_left = thm "add_less_cancel_left"; 

1158 
val add_less_cancel_right = thm "add_less_cancel_right"; 

1159 
val add_le_cancel_left = thm "add_le_cancel_left"; 

1160 
val add_le_cancel_right = thm "add_le_cancel_right"; 

1161 
val add_le_imp_le_right = thm "add_le_imp_le_right"; 

1162 
val add_increasing = thm "add_increasing"; 

1163 
val le_imp_neg_le = thm "le_imp_neg_le"; 

1164 
val neg_le_iff_le = thm "neg_le_iff_le"; 

1165 
val neg_le_0_iff_le = thm "neg_le_0_iff_le"; 

1166 
val neg_0_le_iff_le = thm "neg_0_le_iff_le"; 

1167 
val neg_less_iff_less = thm "neg_less_iff_less"; 

1168 
val neg_less_0_iff_less = thm "neg_less_0_iff_less"; 

1169 
val neg_0_less_iff_less = thm "neg_0_less_iff_less"; 

1170 
val less_minus_iff = thm "less_minus_iff"; 

1171 
val minus_less_iff = thm "minus_less_iff"; 

1172 
val le_minus_iff = thm "le_minus_iff"; 

1173 
val minus_le_iff = thm "minus_le_iff"; 

1174 
val add_diff_eq = thm "add_diff_eq"; 

1175 
val diff_add_eq = thm "diff_add_eq"; 

1176 
val diff_eq_eq = thm "diff_eq_eq"; 

1177 
val eq_diff_eq = thm "eq_diff_eq"; 

1178 
val diff_diff_eq = thm "diff_diff_eq"; 

1179 
val diff_diff_eq2 = thm "diff_diff_eq2"; 

1180 
val diff_add_cancel = thm "diff_add_cancel"; 

1181 
val add_diff_cancel = thm "add_diff_cancel"; 

1182 
val less_iff_diff_less_0 = thm "less_iff_diff_less_0"; 

1183 
val diff_less_eq = thm "diff_less_eq"; 

1184 
val less_diff_eq = thm "less_diff_eq"; 

1185 
val diff_le_eq = thm "diff_le_eq"; 

1186 
val le_diff_eq = thm "le_diff_eq"; 

1187 
val compare_rls = thms "compare_rls"; 

1188 
val eq_iff_diff_eq_0 = thm "eq_iff_diff_eq_0"; 

1189 
val le_iff_diff_le_0 = thm "le_iff_diff_le_0"; 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1190 
val add_inf_distrib_left = thm "add_inf_distrib_left"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1191 
val add_sup_distrib_left = thm "add_sup_distrib_left"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1192 
val add_sup_distrib_right = thm "add_sup_distrib_right"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1193 
val add_inf_distrib_right = thm "add_inf_distrib_right"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1194 
val add_sup_inf_distribs = thms "add_sup_inf_distribs"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1195 
val sup_eq_neg_inf = thm "sup_eq_neg_inf"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1196 
val inf_eq_neg_sup = thm "inf_eq_neg_sup"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1197 
val add_eq_inf_sup = thm "add_eq_inf_sup"; 
14738  1198 
val prts = thm "prts"; 
1199 
val zero_le_pprt = thm "zero_le_pprt"; 

1200 
val nprt_le_zero = thm "nprt_le_zero"; 

1201 
val le_eq_neg = thm "le_eq_neg"; 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1202 
val sup_0_imp_0 = thm "sup_0_imp_0"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1203 
val inf_0_imp_0 = thm "inf_0_imp_0"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1204 
val sup_0_eq_0 = thm "sup_0_eq_0"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1205 
val inf_0_eq_0 = thm "inf_0_eq_0"; 
14738  1206 
val zero_le_double_add_iff_zero_le_single_add = thm "zero_le_double_add_iff_zero_le_single_add"; 
1207 
val double_add_le_zero_iff_single_add_le_zero = thm "double_add_le_zero_iff_single_add_le_zero"; 

1208 
val double_add_less_zero_iff_single_less_zero = thm "double_add_less_zero_iff_single_less_zero"; 

1209 
val abs_lattice = thm "abs_lattice"; 

1210 
val abs_zero = thm "abs_zero"; 

1211 
val abs_eq_0 = thm "abs_eq_0"; 

1212 
val abs_0_eq = thm "abs_0_eq"; 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1213 
val neg_inf_eq_sup = thm "neg_inf_eq_sup"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1214 
val neg_sup_eq_inf = thm "neg_sup_eq_inf"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1215 
val sup_eq_if = thm "sup_eq_if"; 
14738  1216 
val abs_if_lattice = thm "abs_if_lattice"; 
1217 
val abs_ge_zero = thm "abs_ge_zero"; 

1218 
val abs_le_zero_iff = thm "abs_le_zero_iff"; 

1219 
val zero_less_abs_iff = thm "zero_less_abs_iff"; 

1220 
val abs_not_less_zero = thm "abs_not_less_zero"; 

1221 
val abs_ge_self = thm "abs_ge_self"; 

1222 
val abs_ge_minus_self = thm "abs_ge_minus_self"; 

22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1223 
val le_imp_join_eq = thm "sup_absorb2"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1224 
val ge_imp_join_eq = thm "sup_absorb1"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1225 
val le_imp_meet_eq = thm "inf_absorb1"; 
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22390
diff
changeset

1226 
val ge_imp_meet_eq = thm "inf_absorb2"; 
14738  1227 
val abs_prts = thm "abs_prts"; 
1228 
val abs_minus_cancel = thm "abs_minus_cancel"; 

1229 
val abs_idempotent = thm "abs_idempotent"; 

1230 
val zero_le_iff_zero_nprt = thm "zero_le_iff_zero_nprt"; 

1231 
val le_zero_iff_zero_pprt = thm "le_zero_iff_zero_pprt"; 

1232 
val le_zero_iff_pprt_id = thm "le_zero_iff_pprt_id"; 

1233 
val zero_le_iff_nprt_id = thm "zero_le_iff_nprt_id"; 

1234 
val iff2imp = thm "iff2imp"; 

1235 
val abs_leI = thm "abs_leI"; 

1236 
val le_minus_self_iff = thm "le_minus_self_iff"; 

1237 
val minus_le_self_iff = thm "minus_le_self_iff"; 

1238 
val abs_le_D1 = thm "abs_le_D1"; 

1239 
val abs_le_D2 = thm "abs_le_D2"; 

1240 
val abs_le_iff = thm "abs_le_iff"; 

1241 
val abs_triangle_ineq = thm "abs_triangle_ineq"; 

1242 
val abs_diff_triangle_ineq = thm "abs_diff_triangle_ineq"; 

1243 
*} 

1244 

1245 
end 