author  haftmann 
Fri, 30 Nov 2007 20:13:06 +0100  
changeset 25512  4134f7c782e2 
parent 25450  c3b26e533b21 
child 25564  4ca31a3706a4 
permissions  rwrr 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

1 
(* Title: HOL/Ring_and_Field.thy 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

2 
ID: $Id$ 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

3 
Author: Gertrud Bauer, Steven Obua, Tobias Nipkow, Lawrence C Paulson, and Markus Wenzel, 
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

4 
with contributions by Jeremy Avigad 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

5 
*) 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

6 

14738  7 
header {* (Ordered) Rings and Fields *} 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

8 

15229  9 
theory Ring_and_Field 
15140  10 
imports OrderedGroup 
15131  11 
begin 
14504  12 

14738  13 
text {* 
14 
The theory of partially ordered rings is taken from the books: 

15 
\begin{itemize} 

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

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

18 
\end{itemize} 

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

20 
\begin{itemize} 

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

24 
*} 

14504  25 

22390  26 
class semiring = ab_semigroup_add + semigroup_mult + 
25062  27 
assumes left_distrib: "(a + b) * c = a * c + b * c" 
28 
assumes right_distrib: "a * (b + c) = a * b + a * c" 

25152  29 
begin 
30 

31 
text{*For the @{text combine_numerals} simproc*} 

32 
lemma combine_common_factor: 

33 
"a * e + (b * e + c) = (a + b) * e + c" 

34 
by (simp add: left_distrib add_ac) 

35 

36 
end 

14504  37 

22390  38 
class mult_zero = times + zero + 
25062  39 
assumes mult_zero_left [simp]: "0 * a = 0" 
40 
assumes mult_zero_right [simp]: "a * 0 = 0" 

21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

41 

22390  42 
class semiring_0 = semiring + comm_monoid_add + mult_zero 
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

43 

22390  44 
class semiring_0_cancel = semiring + comm_monoid_add + cancel_ab_semigroup_add 
25186  45 
begin 
14504  46 

25186  47 
subclass semiring_0 
48 
proof unfold_locales 

21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

49 
fix a :: 'a 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

50 
have "0 * a + 0 * a = 0 * a + 0" 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

51 
by (simp add: left_distrib [symmetric]) 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

52 
thus "0 * a = 0" 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

53 
by (simp only: add_left_cancel) 
25152  54 
next 
55 
fix a :: 'a 

21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

56 
have "a * 0 + a * 0 = a * 0 + 0" 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

57 
by (simp add: right_distrib [symmetric]) 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

58 
thus "a * 0 = 0" 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

59 
by (simp only: add_left_cancel) 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

60 
qed 
14940  61 

25186  62 
end 
25152  63 

22390  64 
class comm_semiring = ab_semigroup_add + ab_semigroup_mult + 
25062  65 
assumes distrib: "(a + b) * c = a * c + b * c" 
25152  66 
begin 
14504  67 

25152  68 
subclass semiring 
69 
proof unfold_locales 

14738  70 
fix a b c :: 'a 
71 
show "(a + b) * c = a * c + b * c" by (simp add: distrib) 

72 
have "a * (b + c) = (b + c) * a" by (simp add: mult_ac) 

73 
also have "... = b * a + c * a" by (simp only: distrib) 

74 
also have "... = a * b + a * c" by (simp add: mult_ac) 

75 
finally show "a * (b + c) = a * b + a * c" by blast 

14504  76 
qed 
77 

25152  78 
end 
14504  79 

25152  80 
class comm_semiring_0 = comm_semiring + comm_monoid_add + mult_zero 
81 
begin 

82 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

83 
subclass semiring_0 by intro_locales 
25152  84 

85 
end 

14504  86 

22390  87 
class comm_semiring_0_cancel = comm_semiring + comm_monoid_add + cancel_ab_semigroup_add 
25186  88 
begin 
14940  89 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

90 
subclass semiring_0_cancel by intro_locales 
14940  91 

25186  92 
end 
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

93 

22390  94 
class zero_neq_one = zero + one + 
25062  95 
assumes zero_neq_one [simp]: "0 \<noteq> 1" 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

96 

22390  97 
class semiring_1 = zero_neq_one + semiring_0 + monoid_mult 
14504  98 

22390  99 
class comm_semiring_1 = zero_neq_one + comm_semiring_0 + comm_monoid_mult 
100 
(*previously almost_semiring*) 

25152  101 
begin 
14738  102 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

103 
subclass semiring_1 by intro_locales 
25152  104 

105 
end 

14421
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14398
diff
changeset

106 

22390  107 
class no_zero_divisors = zero + times + 
25062  108 
assumes no_zero_divisors: "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> a * b \<noteq> 0" 
14504  109 

22390  110 
class semiring_1_cancel = semiring + comm_monoid_add + zero_neq_one 
111 
+ cancel_ab_semigroup_add + monoid_mult 

25267  112 
begin 
14940  113 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

114 
subclass semiring_0_cancel by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

115 

4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

116 
subclass semiring_1 by intro_locales 
25267  117 

118 
end 

21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

119 

22390  120 
class comm_semiring_1_cancel = comm_semiring + comm_monoid_add + comm_monoid_mult 
121 
+ zero_neq_one + cancel_ab_semigroup_add 

25267  122 
begin 
14738  123 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

124 
subclass semiring_1_cancel by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

125 
subclass comm_semiring_0_cancel by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

126 
subclass comm_semiring_1 by intro_locales 
25267  127 

128 
end 

25152  129 

22390  130 
class ring = semiring + ab_group_add 
25267  131 
begin 
25152  132 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

133 
subclass semiring_0_cancel by intro_locales 
25152  134 

135 
text {* Distribution rules *} 

136 

137 
lemma minus_mult_left: " (a * b) =  a * b" 

138 
by (rule equals_zero_I) (simp add: left_distrib [symmetric]) 

139 

140 
lemma minus_mult_right: " (a * b) = a *  b" 

141 
by (rule equals_zero_I) (simp add: right_distrib [symmetric]) 

142 

143 
lemma minus_mult_minus [simp]: " a *  b = a * b" 

144 
by (simp add: minus_mult_left [symmetric] minus_mult_right [symmetric]) 

145 

146 
lemma minus_mult_commute: " a * b = a *  b" 

147 
by (simp add: minus_mult_left [symmetric] minus_mult_right [symmetric]) 

148 

149 
lemma right_diff_distrib: "a * (b  c) = a * b  a * c" 

150 
by (simp add: right_distrib diff_minus 

151 
minus_mult_left [symmetric] minus_mult_right [symmetric]) 

152 

153 
lemma left_diff_distrib: "(a  b) * c = a * c  b * c" 

154 
by (simp add: left_distrib diff_minus 

155 
minus_mult_left [symmetric] minus_mult_right [symmetric]) 

156 

157 
lemmas ring_distribs = 

158 
right_distrib left_distrib left_diff_distrib right_diff_distrib 

159 

25230  160 
lemmas ring_simps = 
161 
add_ac 

162 
add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2 

163 
diff_eq_eq eq_diff_eq diff_minus [symmetric] uminus_add_conv_diff 

164 
ring_distribs 

165 

166 
lemma eq_add_iff1: 

167 
"a * e + c = b * e + d \<longleftrightarrow> (a  b) * e + c = d" 

168 
by (simp add: ring_simps) 

169 

170 
lemma eq_add_iff2: 

171 
"a * e + c = b * e + d \<longleftrightarrow> c = (b  a) * e + d" 

172 
by (simp add: ring_simps) 

173 

25152  174 
end 
175 

176 
lemmas ring_distribs = 

177 
right_distrib left_distrib left_diff_distrib right_diff_distrib 

178 

22390  179 
class comm_ring = comm_semiring + ab_group_add 
25267  180 
begin 
14738  181 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

182 
subclass ring by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

183 
subclass comm_semiring_0 by intro_locales 
25267  184 

185 
end 

14738  186 

22390  187 
class ring_1 = ring + zero_neq_one + monoid_mult 
25267  188 
begin 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

189 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

190 
subclass semiring_1_cancel by intro_locales 
25267  191 

192 
end 

25152  193 

22390  194 
class comm_ring_1 = comm_ring + zero_neq_one + comm_monoid_mult 
195 
(*previously ring*) 

25267  196 
begin 
14738  197 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

198 
subclass ring_1 by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

199 
subclass comm_semiring_1_cancel by intro_locales 
25267  200 

201 
end 

25152  202 

22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

203 
class ring_no_zero_divisors = ring + no_zero_divisors 
25230  204 
begin 
205 

206 
lemma mult_eq_0_iff [simp]: 

207 
shows "a * b = 0 \<longleftrightarrow> (a = 0 \<or> b = 0)" 

208 
proof (cases "a = 0 \<or> b = 0") 

209 
case False then have "a \<noteq> 0" and "b \<noteq> 0" by auto 

210 
then show ?thesis using no_zero_divisors by simp 

211 
next 

212 
case True then show ?thesis by auto 

213 
qed 

214 

215 
end 

22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

216 

23544  217 
class ring_1_no_zero_divisors = ring_1 + ring_no_zero_divisors 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

218 

22390  219 
class idom = comm_ring_1 + no_zero_divisors 
25186  220 
begin 
14421
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14398
diff
changeset

221 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

222 
subclass ring_1_no_zero_divisors by intro_locales 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

223 

25186  224 
end 
25152  225 

22390  226 
class division_ring = ring_1 + inverse + 
25062  227 
assumes left_inverse [simp]: "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1" 
228 
assumes right_inverse [simp]: "a \<noteq> 0 \<Longrightarrow> a * inverse a = 1" 

25186  229 
begin 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

230 

25186  231 
subclass ring_1_no_zero_divisors 
232 
proof unfold_locales 

22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

233 
fix a b :: 'a 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

234 
assume a: "a \<noteq> 0" and b: "b \<noteq> 0" 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

235 
show "a * b \<noteq> 0" 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

236 
proof 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

237 
assume ab: "a * b = 0" 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

238 
hence "0 = inverse a * (a * b) * inverse b" 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

239 
by simp 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

240 
also have "\<dots> = (inverse a * a) * (b * inverse b)" 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

241 
by (simp only: mult_assoc) 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

242 
also have "\<dots> = 1" 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

243 
using a b by simp 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

244 
finally show False 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

245 
by simp 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

246 
qed 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

247 
qed 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

248 

25186  249 
end 
25152  250 

22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

251 
class field = comm_ring_1 + inverse + 
25062  252 
assumes field_inverse: "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1" 
253 
assumes divide_inverse: "a / b = a * inverse b" 

25267  254 
begin 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

255 

25267  256 
subclass division_ring 
25186  257 
proof unfold_locales 
22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

258 
fix a :: 'a 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

259 
assume "a \<noteq> 0" 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

260 
thus "inverse a * a = 1" by (rule field_inverse) 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

261 
thus "a * inverse a = 1" by (simp only: mult_commute) 
14738  262 
qed 
25230  263 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

264 
subclass idom by intro_locales 
25230  265 

266 
lemma right_inverse_eq: "b \<noteq> 0 \<Longrightarrow> a / b = 1 \<longleftrightarrow> a = b" 

267 
proof 

268 
assume neq: "b \<noteq> 0" 

269 
{ 

270 
hence "a = (a / b) * b" by (simp add: divide_inverse mult_ac) 

271 
also assume "a / b = 1" 

272 
finally show "a = b" by simp 

273 
next 

274 
assume "a = b" 

275 
with neq show "a / b = 1" by (simp add: divide_inverse) 

276 
} 

277 
qed 

278 

279 
lemma nonzero_inverse_eq_divide: "a \<noteq> 0 \<Longrightarrow> inverse a = 1 / a" 

280 
by (simp add: divide_inverse) 

281 

282 
lemma divide_self [simp]: "a \<noteq> 0 \<Longrightarrow> a / a = 1" 

283 
by (simp add: divide_inverse) 

284 

285 
lemma divide_zero_left [simp]: "0 / a = 0" 

286 
by (simp add: divide_inverse) 

287 

288 
lemma inverse_eq_divide: "inverse a = 1 / a" 

289 
by (simp add: divide_inverse) 

290 

291 
lemma add_divide_distrib: "(a+b) / c = a/c + b/c" 

292 
by (simp add: divide_inverse ring_distribs) 

293 

294 
end 

295 

22390  296 
class division_by_zero = zero + inverse + 
25062  297 
assumes inverse_zero [simp]: "inverse 0 = 0" 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

298 

25230  299 
lemma divide_zero [simp]: 
300 
"a / 0 = (0::'a::{field,division_by_zero})" 

301 
by (simp add: divide_inverse) 

302 

303 
lemma divide_self_if [simp]: 

304 
"a / (a::'a::{field,division_by_zero}) = (if a=0 then 0 else 1)" 

305 
by (simp add: divide_self) 

306 

22390  307 
class mult_mono = times + zero + ord + 
25062  308 
assumes mult_left_mono: "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b" 
309 
assumes mult_right_mono: "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * c" 

14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset

310 

22390  311 
class pordered_semiring = mult_mono + semiring_0 + pordered_ab_semigroup_add 
25230  312 
begin 
313 

314 
lemma mult_mono: 

315 
"a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> c 

316 
\<Longrightarrow> a * c \<le> b * d" 

317 
apply (erule mult_right_mono [THEN order_trans], assumption) 

318 
apply (erule mult_left_mono, assumption) 

319 
done 

320 

321 
lemma mult_mono': 

322 
"a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> a \<Longrightarrow> 0 \<le> c 

323 
\<Longrightarrow> a * c \<le> b * d" 

324 
apply (rule mult_mono) 

325 
apply (fast intro: order_trans)+ 

326 
done 

327 

328 
end 

21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

329 

22390  330 
class pordered_cancel_semiring = mult_mono + pordered_ab_semigroup_add 
22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset

331 
+ semiring + comm_monoid_add + cancel_ab_semigroup_add 
25267  332 
begin 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

333 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

334 
subclass semiring_0_cancel by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

335 
subclass pordered_semiring by intro_locales 
23521  336 

25230  337 
lemma mult_nonneg_nonneg: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * b" 
338 
by (drule mult_left_mono [of zero b], auto) 

339 

340 
lemma mult_nonneg_nonpos: "0 \<le> a \<Longrightarrow> b \<le> 0 \<Longrightarrow> a * b \<le> 0" 

341 
by (drule mult_left_mono [of b zero], auto) 

342 

343 
lemma mult_nonneg_nonpos2: "0 \<le> a \<Longrightarrow> b \<le> 0 \<Longrightarrow> b * a \<le> 0" 

344 
by (drule mult_right_mono [of b zero], auto) 

345 

346 
lemma split_mult_neg_le: "(0 \<le> a & b \<le> 0)  (a \<le> 0 & 0 \<le> b) \<Longrightarrow> a * b \<le> (0::_::pordered_cancel_semiring)" 

347 
by (auto simp add: mult_nonneg_nonpos mult_nonneg_nonpos2) 

348 

349 
end 

350 

351 
class ordered_semiring = semiring + comm_monoid_add + ordered_cancel_ab_semigroup_add + mult_mono 

25267  352 
begin 
25230  353 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

354 
subclass pordered_cancel_semiring by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

355 

4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

356 
subclass pordered_comm_monoid_add by intro_locales 
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

357 

25230  358 
lemma mult_left_less_imp_less: 
359 
"c * a < c * b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b" 

360 
by (force simp add: mult_left_mono not_le [symmetric]) 

361 

362 
lemma mult_right_less_imp_less: 

363 
"a * c < b * c \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b" 

364 
by (force simp add: mult_right_mono not_le [symmetric]) 

23521  365 

25186  366 
end 
25152  367 

22390  368 
class ordered_semiring_strict = semiring + comm_monoid_add + ordered_cancel_ab_semigroup_add + 
25062  369 
assumes mult_strict_left_mono: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c * a < c * b" 
370 
assumes mult_strict_right_mono: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> a * c < b * c" 

25267  371 
begin 
14341
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents:
14334
diff
changeset

372 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

373 
subclass semiring_0_cancel by intro_locales 
14940  374 

25267  375 
subclass ordered_semiring 
25186  376 
proof unfold_locales 
23550  377 
fix a b c :: 'a 
378 
assume A: "a \<le> b" "0 \<le> c" 

379 
from A show "c * a \<le> c * b" 

25186  380 
unfolding le_less 
381 
using mult_strict_left_mono by (cases "c = 0") auto 

23550  382 
from A show "a * c \<le> b * c" 
25152  383 
unfolding le_less 
25186  384 
using mult_strict_right_mono by (cases "c = 0") auto 
25152  385 
qed 
386 

25230  387 
lemma mult_left_le_imp_le: 
388 
"c * a \<le> c * b \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b" 

389 
by (force simp add: mult_strict_left_mono _not_less [symmetric]) 

390 

391 
lemma mult_right_le_imp_le: 

392 
"a * c \<le> b * c \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b" 

393 
by (force simp add: mult_strict_right_mono not_less [symmetric]) 

394 

395 
lemma mult_pos_pos: 

396 
"0 < a \<Longrightarrow> 0 < b \<Longrightarrow> 0 < a * b" 

397 
by (drule mult_strict_left_mono [of zero b], auto) 

398 

399 
lemma mult_pos_neg: 

400 
"0 < a \<Longrightarrow> b < 0 \<Longrightarrow> a * b < 0" 

401 
by (drule mult_strict_left_mono [of b zero], auto) 

402 

403 
lemma mult_pos_neg2: 

404 
"0 < a \<Longrightarrow> b < 0 \<Longrightarrow> b * a < 0" 

405 
by (drule mult_strict_right_mono [of b zero], auto) 

406 

407 
lemma zero_less_mult_pos: 

408 
"0 < a * b \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b" 

409 
apply (cases "b\<le>0") 

410 
apply (auto simp add: le_less not_less) 

411 
apply (drule_tac mult_pos_neg [of a b]) 

412 
apply (auto dest: less_not_sym) 

413 
done 

414 

415 
lemma zero_less_mult_pos2: 

416 
"0 < b * a \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b" 

417 
apply (cases "b\<le>0") 

418 
apply (auto simp add: le_less not_less) 

419 
apply (drule_tac mult_pos_neg2 [of a b]) 

420 
apply (auto dest: less_not_sym) 

421 
done 

422 

423 
end 

424 

22390  425 
class mult_mono1 = times + zero + ord + 
25230  426 
assumes mult_mono1: "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b" 
14270  427 

22390  428 
class pordered_comm_semiring = comm_semiring_0 
429 
+ pordered_ab_semigroup_add + mult_mono1 

25186  430 
begin 
25152  431 

25267  432 
subclass pordered_semiring 
25186  433 
proof unfold_locales 
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

434 
fix a b c :: 'a 
23550  435 
assume "a \<le> b" "0 \<le> c" 
25230  436 
thus "c * a \<le> c * b" by (rule mult_mono1) 
23550  437 
thus "a * c \<le> b * c" by (simp only: mult_commute) 
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset

438 
qed 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

439 

25267  440 
end 
441 

442 
class pordered_cancel_comm_semiring = comm_semiring_0_cancel 

443 
+ pordered_ab_semigroup_add + mult_mono1 

444 
begin 

14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

445 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

446 
subclass pordered_comm_semiring by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

447 
subclass pordered_cancel_semiring by intro_locales 
25267  448 

449 
end 

450 

451 
class ordered_comm_semiring_strict = comm_semiring_0 + ordered_cancel_ab_semigroup_add + 

452 
assumes mult_strict_mono: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c * a < c * b" 

453 
begin 

454 

455 
subclass ordered_semiring_strict 

25186  456 
proof unfold_locales 
23550  457 
fix a b c :: 'a 
458 
assume "a < b" "0 < c" 

459 
thus "c * a < c * b" by (rule mult_strict_mono) 

460 
thus "a * c < b * c" by (simp only: mult_commute) 

461 
qed 

14272
5efbb548107d
Tidying of the integer development; towards removing the
paulson
parents:
14270
diff
changeset

462 

25267  463 
subclass pordered_cancel_comm_semiring 
25186  464 
proof unfold_locales 
23550  465 
fix a b c :: 'a 
466 
assume "a \<le> b" "0 \<le> c" 

467 
thus "c * a \<le> c * b" 

25186  468 
unfolding le_less 
469 
using mult_strict_mono by (cases "c = 0") auto 

23550  470 
qed 
14272
5efbb548107d
Tidying of the integer development; towards removing the
paulson
parents:
14270
diff
changeset

471 

25267  472 
end 
25230  473 

25267  474 
class pordered_ring = ring + pordered_cancel_semiring 
475 
begin 

25230  476 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

477 
subclass pordered_ab_group_add by intro_locales 
14270  478 

25230  479 
lemmas ring_simps = ring_simps group_simps 
480 

481 
lemma less_add_iff1: 

482 
"a * e + c < b * e + d \<longleftrightarrow> (a  b) * e + c < d" 

483 
by (simp add: ring_simps) 

484 

485 
lemma less_add_iff2: 

486 
"a * e + c < b * e + d \<longleftrightarrow> c < (b  a) * e + d" 

487 
by (simp add: ring_simps) 

488 

489 
lemma le_add_iff1: 

490 
"a * e + c \<le> b * e + d \<longleftrightarrow> (a  b) * e + c \<le> d" 

491 
by (simp add: ring_simps) 

492 

493 
lemma le_add_iff2: 

494 
"a * e + c \<le> b * e + d \<longleftrightarrow> c \<le> (b  a) * e + d" 

495 
by (simp add: ring_simps) 

496 

497 
lemma mult_left_mono_neg: 

498 
"b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> c * a \<le> c * b" 

499 
apply (drule mult_left_mono [of _ _ "uminus c"]) 

500 
apply (simp_all add: minus_mult_left [symmetric]) 

501 
done 

502 

503 
lemma mult_right_mono_neg: 

504 
"b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> a * c \<le> b * c" 

505 
apply (drule mult_right_mono [of _ _ "uminus c"]) 

506 
apply (simp_all add: minus_mult_right [symmetric]) 

507 
done 

508 

509 
lemma mult_nonpos_nonpos: 

510 
"a \<le> 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> 0 \<le> a * b" 

511 
by (drule mult_right_mono_neg [of a zero b]) auto 

512 

513 
lemma split_mult_pos_le: 

514 
"(0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0) \<Longrightarrow> 0 \<le> a * b" 

515 
by (auto simp add: mult_nonneg_nonneg mult_nonpos_nonpos) 

25186  516 

517 
end 

14270  518 

23879  519 
class abs_if = minus + ord + zero + abs + 
25186  520 
assumes abs_if: "\<bar>a\<bar> = (if a < 0 then ( a) else a)" 
14270  521 

24506  522 
class sgn_if = sgn + zero + one + minus + ord + 
25186  523 
assumes sgn_if: "sgn x = (if x = 0 then 0 else if 0 < x then 1 else  1)" 
24506  524 

25230  525 
class ordered_ring = ring + ordered_semiring 
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

526 
+ ordered_ab_group_add + abs_if 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

527 
begin 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

528 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

529 
subclass pordered_ring by intro_locales 
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

530 

7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

531 
subclass pordered_ab_group_add_abs 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

532 
proof unfold_locales 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

533 
fix a b 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

534 
show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

535 
by (auto simp add: abs_if not_less neg_less_eq_nonneg less_eq_neg_nonpos) 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

536 
(auto simp del: minus_add_distrib simp add: minus_add_distrib [symmetric] 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

537 
neg_less_eq_nonneg less_eq_neg_nonpos, auto intro: add_nonneg_nonneg, 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

538 
auto intro!: less_imp_le add_neg_neg) 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

539 
qed (auto simp add: abs_if less_eq_neg_nonpos neg_equal_zero) 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

540 

7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

541 
end 
23521  542 

25230  543 
(* The "strict" suffix can be seen as describing the combination of ordered_ring and no_zero_divisors. 
544 
Basically, ordered_ring + no_zero_divisors = ordered_ring_strict. 

545 
*) 

546 
class ordered_ring_strict = ring + ordered_semiring_strict 

25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

547 
+ ordered_ab_group_add + abs_if 
25230  548 
begin 
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset

549 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

550 
subclass ordered_ring by intro_locales 
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

551 

14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

552 
lemma mult_strict_left_mono_neg: 
25230  553 
"b < a \<Longrightarrow> c < 0 \<Longrightarrow> c * a < c * b" 
554 
apply (drule mult_strict_left_mono [of _ _ "uminus c"]) 

555 
apply (simp_all add: minus_mult_left [symmetric]) 

556 
done 

14738  557 

14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

558 
lemma mult_strict_right_mono_neg: 
25230  559 
"b < a \<Longrightarrow> c < 0 \<Longrightarrow> a * c < b * c" 
560 
apply (drule mult_strict_right_mono [of _ _ "uminus c"]) 

561 
apply (simp_all add: minus_mult_right [symmetric]) 

562 
done 

14738  563 

25230  564 
lemma mult_neg_neg: 
565 
"a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> 0 < a * b" 

566 
by (drule mult_strict_right_mono_neg, auto) 

14738  567 

25230  568 
end 
14738  569 

25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

570 
instance ordered_ring_strict \<subseteq> ring_no_zero_divisors 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

571 
apply intro_classes 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

572 
apply (auto simp add: linorder_not_less order_le_less linorder_neq_iff) 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

573 
apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono)+ 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

574 
done 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

575 

14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

576 
lemma zero_less_mult_iff: 
25230  577 
fixes a :: "'a::ordered_ring_strict" 
578 
shows "0 < a * b \<longleftrightarrow> 0 < a \<and> 0 < b \<or> a < 0 \<and> b < 0" 

579 
apply (auto simp add: le_less not_less mult_pos_pos mult_neg_neg) 

580 
apply (blast dest: zero_less_mult_pos) 

581 
apply (blast dest: zero_less_mult_pos2) 

582 
done 

22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

583 

14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

584 
lemma zero_le_mult_iff: 
14738  585 
"((0::'a::ordered_ring_strict) \<le> a*b) = (0 \<le> a & 0 \<le> b  a \<le> 0 & b \<le> 0)" 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

586 
by (auto simp add: eq_commute [of 0] order_le_less linorder_not_less 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

587 
zero_less_mult_iff) 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

588 

95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

589 
lemma mult_less_0_iff: 
14738  590 
"(a*b < (0::'a::ordered_ring_strict)) = (0 < a & b < 0  a < 0 & 0 < b)" 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

591 
apply (insert zero_less_mult_iff [of "a" b]) 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

592 
apply (force simp add: minus_mult_left[symmetric]) 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

593 
done 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

594 

95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

595 
lemma mult_le_0_iff: 
14738  596 
"(a*b \<le> (0::'a::ordered_ring_strict)) = (0 \<le> a & b \<le> 0  a \<le> 0 & 0 \<le> b)" 
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

597 
apply (insert zero_le_mult_iff [of "a" b]) 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

598 
apply (force simp add: minus_mult_left[symmetric]) 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

599 
done 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

600 

23095  601 
lemma zero_le_square[simp]: "(0::'a::ordered_ring_strict) \<le> a*a" 
602 
by (simp add: zero_le_mult_iff linorder_linear) 

603 

604 
lemma not_square_less_zero[simp]: "\<not> (a * a < (0::'a::ordered_ring_strict))" 

605 
by (simp add: not_less) 

14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset

606 

25230  607 
text{*This list of rewrites simplifies ring terms by multiplying 
608 
everything out and bringing sums and products into a canonical form 

609 
(by ordered rewriting). As a result it decides ring equalities but 

610 
also helps with inequalities. *} 

611 
lemmas ring_simps = group_simps ring_distribs 

612 

613 

614 
class pordered_comm_ring = comm_ring + pordered_comm_semiring 

25267  615 
begin 
25230  616 

25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

617 
subclass pordered_ring by intro_locales 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset

618 
subclass pordered_cancel_comm_semiring by intro_locales 
25230  619 

25267  620 
end 
25230  621 

622 
class ordered_semidom = comm_semiring_1_cancel + ordered_comm_semiring_strict + 

623 
(*previously ordered_semiring*) 

624 
assumes zero_less_one [simp]: "0 < 1" 

625 
begin 

626 

627 
lemma pos_add_strict: 

628 
shows "0 < a \<Longrightarrow> b < c \<Longrightarrow> b < a + c" 

629 
using add_strict_mono [of zero a b c] by simp 

630 

631 
end 

632 

633 
class ordered_idom = 

634 
comm_ring_1 + 

635 
ordered_comm_semiring_strict + 

25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset

636 
ordered_ab_group_add + 
25230  637 
abs_if + sgn_if 
638 
(*previously ordered_ring*) 

639 

640 
instance ordered_idom \<subseteq> ordered_ring_strict .. 

641 

642 
instance ordered_idom \<subseteq> pordered_comm_ring .. 

643 

644 
class ordered_field = field + ordered_idom 

645 

646 
lemma linorder_neqE_ordered_idom: 

647 
fixes x y :: "'a :: ordered_idom" 

648 
assumes "x \<noteq> y" obtains "x < y"  "y < x" 

649 
using assms by (rule linorder_neqE) 

650 

651 

14738  652 
text{*Proving axiom @{text zero_less_one} makes all @{text ordered_semidom} 
653 
theorems available to members of @{term ordered_idom} *} 

654 

655 
instance ordered_idom \<subseteq> ordered_semidom 

14421
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14398
diff
changeset

656 
proof 
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14398
diff
changeset

657 
have "(0::'a) \<le> 1*1" by (rule zero_le_square) 
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

658 
thus "(0::'a) < 1" by (simp add: order_le_less) 
14421
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14398
diff
changeset

659 
qed 
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14398
diff
changeset

660 

14738  661 
instance ordered_idom \<subseteq> idom .. 
662 

14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

663 
text{*All three types of comparision involving 0 and 1 are covered.*} 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

664 

17085  665 
lemmas one_neq_zero = zero_neq_one [THEN not_sym] 
666 
declare one_neq_zero [simp] 

14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

667 

14738  668 
lemma zero_le_one [simp]: "(0::'a::ordered_semidom) \<le> 1" 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

669 
by (rule zero_less_one [THEN order_less_imp_le]) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

670 

14738  671 
lemma not_one_le_zero [simp]: "~ (1::'a::ordered_semidom) \<le> 0" 
672 
by (simp add: linorder_not_le) 

14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

673 

14738  674 
lemma not_one_less_zero [simp]: "~ (1::'a::ordered_semidom) < 0" 
675 
by (simp add: linorder_not_less) 

14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

676 

23389  677 

14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

678 
subsection{*More Monotonicity*} 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

679 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

680 
text{*Strict monotonicity in both arguments*} 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

681 
lemma mult_strict_mono: 
14738  682 
"[a<b; c<d; 0<b; 0\<le>c] ==> a * c < b * (d::'a::ordered_semiring_strict)" 
21328  683 
apply (cases "c=0") 
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

684 
apply (simp add: mult_pos_pos) 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

685 
apply (erule mult_strict_right_mono [THEN order_less_trans]) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

686 
apply (force simp add: order_le_less) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

687 
apply (erule mult_strict_left_mono, assumption) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

688 
done 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

689 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

690 
text{*This weaker variant has more natural premises*} 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

691 
lemma mult_strict_mono': 
14738  692 
"[ a<b; c<d; 0 \<le> a; 0 \<le> c] ==> a * c < b * (d::'a::ordered_semiring_strict)" 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

693 
apply (rule mult_strict_mono) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

694 
apply (blast intro: order_le_less_trans)+ 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

695 
done 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

696 

14738  697 
lemma less_1_mult: "[ 1 < m; 1 < n ] ==> 1 < m*(n::'a::ordered_semidom)" 
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

698 
apply (insert mult_strict_mono [of 1 m 1 n]) 
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

699 
apply (simp add: order_less_trans [OF zero_less_one]) 
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

700 
done 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

701 

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

702 
lemma mult_less_le_imp_less: "(a::'a::ordered_semiring_strict) < b ==> 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

703 
c <= d ==> 0 <= a ==> 0 < c ==> a * c < b * d" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

704 
apply (subgoal_tac "a * c < b * c") 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

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

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

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

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

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

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

711 

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

712 
lemma mult_le_less_imp_less: "(a::'a::ordered_semiring_strict) <= b ==> 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

713 
c < d ==> 0 < a ==> 0 <= c ==> a * c < b * d" 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

714 
apply (subgoal_tac "a * c <= b * c") 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

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

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

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

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

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

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

721 

23389  722 

14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

723 
subsection{*Cancellation Laws for Relationships With a Common Factor*} 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

724 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

725 
text{*Cancellation laws for @{term "c*a < c*b"} and @{term "a*c < b*c"}, 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

726 
also with the relations @{text "\<le>"} and equality.*} 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

727 

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

728 
text{*These ``disjunction'' versions produce two cases when the comparison is 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

729 
an assumption, but effectively four when the comparison is a goal.*} 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

730 

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

731 
lemma mult_less_cancel_right_disj: 
14738  732 
"(a*c < b*c) = ((0 < c & a < b)  (c < 0 & b < (a::'a::ordered_ring_strict)))" 
21328  733 
apply (cases "c = 0") 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

734 
apply (auto simp add: linorder_neq_iff mult_strict_right_mono 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

735 
mult_strict_right_mono_neg) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

736 
apply (auto simp add: linorder_not_less 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

737 
linorder_not_le [symmetric, of "a*c"] 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

738 
linorder_not_le [symmetric, of a]) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

739 
apply (erule_tac [!] notE) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

740 
apply (auto simp add: order_less_imp_le mult_right_mono 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

741 
mult_right_mono_neg) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

742 
done 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

743 

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

744 
lemma mult_less_cancel_left_disj: 
14738  745 
"(c*a < c*b) = ((0 < c & a < b)  (c < 0 & b < (a::'a::ordered_ring_strict)))" 
21328  746 
apply (cases "c = 0") 
14738  747 
apply (auto simp add: linorder_neq_iff mult_strict_left_mono 
748 
mult_strict_left_mono_neg) 

749 
apply (auto simp add: linorder_not_less 

750 
linorder_not_le [symmetric, of "c*a"] 

751 
linorder_not_le [symmetric, of a]) 

752 
apply (erule_tac [!] notE) 

753 
apply (auto simp add: order_less_imp_le mult_left_mono 

754 
mult_left_mono_neg) 

755 
done 

14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

756 

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

757 

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

758 
text{*The ``conjunction of implication'' lemmas produce two cases when the 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

759 
comparison is a goal, but give four when the comparison is an assumption.*} 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

760 

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

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

762 
fixes c :: "'a :: ordered_ring_strict" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

763 
shows "(a*c < b*c) = ((0 \<le> c > a < b) & (c \<le> 0 > b < a))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

764 
by (insert mult_less_cancel_right_disj [of a c b], auto) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

765 

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

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

767 
fixes c :: "'a :: ordered_ring_strict" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

768 
shows "(c*a < c*b) = ((0 \<le> c > a < b) & (c \<le> 0 > b < a))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

769 
by (insert mult_less_cancel_left_disj [of c a b], auto) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

770 

14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

771 
lemma mult_le_cancel_right: 
14738  772 
"(a*c \<le> b*c) = ((0<c > a\<le>b) & (c<0 > b \<le> (a::'a::ordered_ring_strict)))" 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

773 
by (simp add: linorder_not_less [symmetric] mult_less_cancel_right_disj) 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

774 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

775 
lemma mult_le_cancel_left: 
14738  776 
"(c*a \<le> c*b) = ((0<c > a\<le>b) & (c<0 > b \<le> (a::'a::ordered_ring_strict)))" 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

777 
by (simp add: linorder_not_less [symmetric] mult_less_cancel_left_disj) 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

778 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

779 
lemma mult_less_imp_less_left: 
14341
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents:
14334
diff
changeset

780 
assumes less: "c*a < c*b" and nonneg: "0 \<le> c" 
14738  781 
shows "a < (b::'a::ordered_semiring_strict)" 
14377  782 
proof (rule ccontr) 
783 
assume "~ a < b" 

784 
hence "b \<le> a" by (simp add: linorder_not_less) 

23389  785 
hence "c*b \<le> c*a" using nonneg by (rule mult_left_mono) 
14377  786 
with this and less show False 
787 
by (simp add: linorder_not_less [symmetric]) 

788 
qed 

14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

789 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

790 
lemma mult_less_imp_less_right: 
14738  791 
assumes less: "a*c < b*c" and nonneg: "0 <= c" 
792 
shows "a < (b::'a::ordered_semiring_strict)" 

793 
proof (rule ccontr) 

794 
assume "~ a < b" 

795 
hence "b \<le> a" by (simp add: linorder_not_less) 

23389  796 
hence "b*c \<le> a*c" using nonneg by (rule mult_right_mono) 
14738  797 
with this and less show False 
798 
by (simp add: linorder_not_less [symmetric]) 

799 
qed 

14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

800 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

801 
text{*Cancellation of equalities with a common factor*} 
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset

802 
lemma mult_cancel_right [simp,noatp]: 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

803 
fixes a b c :: "'a::ring_no_zero_divisors" 
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

804 
shows "(a * c = b * c) = (c = 0 \<or> a = b)" 
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

805 
proof  
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

806 
have "(a * c = b * c) = ((a  b) * c = 0)" 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

807 
by (simp add: ring_distribs) 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

808 
thus ?thesis 
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

809 
by (simp add: disj_commute) 
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

810 
qed 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

811 

24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset

812 
lemma mult_cancel_left [simp,noatp]: 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

813 
fixes a b c :: "'a::ring_no_zero_divisors" 
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

814 
shows "(c * a = c * b) = (c = 0 \<or> a = b)" 
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

815 
proof  
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

816 
have "(c * a = c * b) = (c * (a  b) = 0)" 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

817 
by (simp add: ring_distribs) 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

818 
thus ?thesis 
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

819 
by simp 
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

820 
qed 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

821 

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

822 

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

823 
subsubsection{*Special Cancellation Simprules for Multiplication*} 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

824 

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

825 
text{*These also produce two cases when the comparison is a goal.*} 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

826 

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

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

828 
fixes c :: "'a :: ordered_idom" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

829 
shows "(c \<le> b*c) = ((0<c > 1\<le>b) & (c<0 > b \<le> 1))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

830 
by (insert mult_le_cancel_right [of 1 c b], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

831 

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

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

833 
fixes c :: "'a :: ordered_idom" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

834 
shows "(a*c \<le> c) = ((0<c > a\<le>1) & (c<0 > 1 \<le> a))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

835 
by (insert mult_le_cancel_right [of a c 1], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

836 

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

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

838 
fixes c :: "'a :: ordered_idom" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

839 
shows "(c \<le> c*b) = ((0<c > 1\<le>b) & (c<0 > b \<le> 1))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

840 
by (insert mult_le_cancel_left [of c 1 b], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

841 

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

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

843 
fixes c :: "'a :: ordered_idom" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

844 
shows "(c*a \<le> c) = ((0<c > a\<le>1) & (c<0 > 1 \<le> a))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

845 
by (insert mult_le_cancel_left [of c a 1], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

846 

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

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

848 
fixes c :: "'a :: ordered_idom" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

849 
shows "(c < b*c) = ((0 \<le> c > 1<b) & (c \<le> 0 > b < 1))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

850 
by (insert mult_less_cancel_right [of 1 c b], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

851 

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

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

853 
fixes c :: "'a :: ordered_idom" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

854 
shows "(a*c < c) = ((0 \<le> c > a<1) & (c \<le> 0 > 1 < a))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

855 
by (insert mult_less_cancel_right [of a c 1], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

856 

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

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

858 
fixes c :: "'a :: ordered_idom" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

859 
shows "(c < c*b) = ((0 \<le> c > 1<b) & (c \<le> 0 > b < 1))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

860 
by (insert mult_less_cancel_left [of c 1 b], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

861 

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

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

863 
fixes c :: "'a :: ordered_idom" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

864 
shows "(c*a < c) = ((0 \<le> c > a<1) & (c \<le> 0 > 1 < a))" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

865 
by (insert mult_less_cancel_left [of c a 1], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

866 

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

867 
lemma mult_cancel_right1 [simp]: 
23544  868 
fixes c :: "'a :: ring_1_no_zero_divisors" 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

869 
shows "(c = b*c) = (c = 0  b=1)" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

870 
by (insert mult_cancel_right [of 1 c b], force) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

871 

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

872 
lemma mult_cancel_right2 [simp]: 
23544  873 
fixes c :: "'a :: ring_1_no_zero_divisors" 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

874 
shows "(a*c = c) = (c = 0  a=1)" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

875 
by (insert mult_cancel_right [of a c 1], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

876 

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

877 
lemma mult_cancel_left1 [simp]: 
23544  878 
fixes c :: "'a :: ring_1_no_zero_divisors" 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

879 
shows "(c = c*b) = (c = 0  b=1)" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

880 
by (insert mult_cancel_left [of c 1 b], force) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

881 

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

882 
lemma mult_cancel_left2 [simp]: 
23544  883 
fixes c :: "'a :: ring_1_no_zero_divisors" 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

884 
shows "(c*a = c) = (c = 0  a=1)" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

885 
by (insert mult_cancel_left [of c a 1], simp) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

886 

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

887 

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

888 
text{*Simprules for comparisons where common factors can be cancelled.*} 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

889 
lemmas mult_compare_simps = 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

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

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

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

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

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

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

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

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

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

899 

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

900 

23482  901 
(* what ordering?? this is a straight instance of mult_eq_0_iff 
14270  902 
text{*Compared with @{text mult_eq_0_iff}, this version removes the requirement 
903 
of an ordering.*} 

20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

904 
lemma field_mult_eq_0_iff [simp]: 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

905 
"(a*b = (0::'a::division_ring)) = (a = 0  b = 0)" 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

906 
by simp 
23482  907 
*) 
23496  908 
(* subsumed by mult_cancel lemmas on ring_no_zero_divisors 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

909 
text{*Cancellation of equalities with a common factor*} 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

910 
lemma field_mult_cancel_right_lemma: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

911 
assumes cnz: "c \<noteq> (0::'a::division_ring)" 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

912 
and eq: "a*c = b*c" 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

913 
shows "a=b" 
14377  914 
proof  
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

915 
have "(a * c) * inverse c = (b * c) * inverse c" 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

916 
by (simp add: eq) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

917 
thus "a=b" 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

918 
by (simp add: mult_assoc cnz) 
14377  919 
qed 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

920 

14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset

921 
lemma field_mult_cancel_right [simp]: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

922 
"(a*c = b*c) = (c = (0::'a::division_ring)  a=b)" 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

923 
by simp 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

924 

14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset

925 
lemma field_mult_cancel_left [simp]: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

926 
"(c*a = c*b) = (c = (0::'a::division_ring)  a=b)" 
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (noncommutative version of idom);
huffman
parents:
22987
diff
changeset

927 
by simp 
23496  928 
*) 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

929 
lemma nonzero_imp_inverse_nonzero: 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

930 
"a \<noteq> 0 ==> inverse a \<noteq> (0::'a::division_ring)" 
14377  931 
proof 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

932 
assume ianz: "inverse a = 0" 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

933 
assume "a \<noteq> 0" 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

934 
hence "1 = a * inverse a" by simp 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

935 
also have "... = 0" by (simp add: ianz) 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

936 
finally have "1 = (0::'a::division_ring)" . 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

937 
thus False by (simp add: eq_commute) 
14377  938 
qed 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

939 

14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

940 

ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

941 
subsection{*Basic Properties of @{term inverse}*} 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

942 

20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

943 
lemma inverse_zero_imp_zero: "inverse a = 0 ==> a = (0::'a::division_ring)" 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

944 
apply (rule ccontr) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

945 
apply (blast dest: nonzero_imp_inverse_nonzero) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

946 
done 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

947 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

948 
lemma inverse_nonzero_imp_nonzero: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

949 
"inverse a = 0 ==> a = (0::'a::division_ring)" 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

950 
apply (rule ccontr) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

951 
apply (blast dest: nonzero_imp_inverse_nonzero) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

952 
done 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

953 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

954 
lemma inverse_nonzero_iff_nonzero [simp]: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

955 
"(inverse a = 0) = (a = (0::'a::{division_ring,division_by_zero}))" 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

956 
by (force dest: inverse_nonzero_imp_nonzero) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

957 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

958 
lemma nonzero_inverse_minus_eq: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

959 
assumes [simp]: "a\<noteq>0" 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

960 
shows "inverse(a) = inverse(a::'a::division_ring)" 
14377  961 
proof  
962 
have "a * inverse ( a) = a *  inverse a" 

963 
by simp 

964 
thus ?thesis 

23496  965 
by (simp only: mult_cancel_left, simp) 
14377  966 
qed 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

967 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

968 
lemma inverse_minus_eq [simp]: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

969 
"inverse(a) = inverse(a::'a::{division_ring,division_by_zero})" 
14377  970 
proof cases 
971 
assume "a=0" thus ?thesis by (simp add: inverse_zero) 

972 
next 

973 
assume "a\<noteq>0" 

974 
thus ?thesis by (simp add: nonzero_inverse_minus_eq) 

975 
qed 

14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

976 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

977 
lemma nonzero_inverse_eq_imp_eq: 
14269  978 
assumes inveq: "inverse a = inverse b" 
979 
and anz: "a \<noteq> 0" 

980 
and bnz: "b \<noteq> 0" 

20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

981 
shows "a = (b::'a::division_ring)" 
14377  982 
proof  
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

983 
have "a * inverse b = a * inverse a" 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

984 
by (simp add: inveq) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

985 
hence "(a * inverse b) * b = (a * inverse a) * b" 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

986 
by simp 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

987 
thus "a = b" 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

988 
by (simp add: mult_assoc anz bnz) 
14377  989 
qed 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

990 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

991 
lemma inverse_eq_imp_eq: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

992 
"inverse a = inverse b ==> a = (b::'a::{division_ring,division_by_zero})" 
21328  993 
apply (cases "a=0  b=0") 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

994 
apply (force dest!: inverse_zero_imp_zero 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

995 
simp add: eq_commute [of "0::'a"]) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

996 
apply (force dest!: nonzero_inverse_eq_imp_eq) 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

997 
done 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

998 

5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

999 
lemma inverse_eq_iff_eq [simp]: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1000 
"(inverse a = inverse b) = (a = (b::'a::{division_ring,division_by_zero}))" 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1001 
by (force dest!: inverse_eq_imp_eq) 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

1002 

14270  1003 
lemma nonzero_inverse_inverse_eq: 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1004 
assumes [simp]: "a \<noteq> 0" 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1005 
shows "inverse(inverse (a::'a::division_ring)) = a" 
14270  1006 
proof  
1007 
have "(inverse (inverse a) * inverse a) * a = a" 

1008 
by (simp add: nonzero_imp_inverse_nonzero) 

1009 
thus ?thesis 

1010 
by (simp add: mult_assoc) 

1011 
qed 

1012 

1013 
lemma inverse_inverse_eq [simp]: 

20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1014 
"inverse(inverse (a::'a::{division_ring,division_by_zero})) = a" 
14270  1015 
proof cases 
1016 
assume "a=0" thus ?thesis by simp 

1017 
next 

1018 
assume "a\<noteq>0" 

1019 
thus ?thesis by (simp add: nonzero_inverse_inverse_eq) 

1020 
qed 

1021 

20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1022 
lemma inverse_1 [simp]: "inverse 1 = (1::'a::division_ring)" 
14270  1023 
proof  
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1024 
have "inverse 1 * 1 = (1::'a::division_ring)" 
14270  1025 
by (rule left_inverse [OF zero_neq_one [symmetric]]) 
1026 
thus ?thesis by simp 

1027 
qed 

1028 

15077
89840837108e
converting Hyperreal/Transcendental to Isar script
paulson
parents:
15010
diff
changeset

1029 
lemma inverse_unique: 
89840837108e
converting Hyperreal/Transcendental to Isar script
paulson
parents:
15010
diff
changeset

1030 
assumes ab: "a*b = 1" 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1031 
shows "inverse a = (b::'a::division_ring)" 
15077
89840837108e
converting Hyperreal/Transcendental to Isar script
paulson
parents:
15010
diff
changeset

1032 
proof  
89840837108e
converting Hyperreal/Transcendental to Isar script
paulson
parents:
15010
diff
changeset

1033 
have "a \<noteq> 0" using ab by auto 
89840837108e
converting Hyperreal/Transcendental to Isar script
paulson
parents:
15010
diff
changeset

1034 
moreover have "inverse a * (a * b) = inverse a" by (simp add: ab) 
89840837108e
converting Hyperreal/Transcendental to Isar script
paulson
parents:
15010
diff
changeset

1035 
ultimately show ?thesis by (simp add: mult_assoc [symmetric]) 
89840837108e
converting Hyperreal/Transcendental to Isar script
paulson
parents:
15010
diff
changeset

1036 
qed 
89840837108e
converting Hyperreal/Transcendental to Isar script
paulson
parents:
15010
diff
changeset

1037 

14270  1038 
lemma nonzero_inverse_mult_distrib: 
1039 
assumes anz: "a \<noteq> 0" 

1040 
and bnz: "b \<noteq> 0" 

20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1041 
shows "inverse(a*b) = inverse(b) * inverse(a::'a::division_ring)" 
14270  1042 
proof  
1043 
have "inverse(a*b) * (a * b) * inverse(b) = inverse(b)" 

23482  1044 
by (simp add: anz bnz) 
14270  1045 
hence "inverse(a*b) * a = inverse(b)" 
1046 
by (simp add: mult_assoc bnz) 

1047 
hence "inverse(a*b) * a * inverse(a) = inverse(b) * inverse(a)" 

1048 
by simp 

1049 
thus ?thesis 

1050 
by (simp add: mult_assoc anz) 

1051 
qed 

1052 

1053 
text{*This version builds in division by zero while also reorienting 

1054 
the righthand side.*} 

1055 
lemma inverse_mult_distrib [simp]: 

1056 
"inverse(a*b) = inverse(a) * inverse(b::'a::{field,division_by_zero})" 

1057 
proof cases 

1058 
assume "a \<noteq> 0 & b \<noteq> 0" 

22993  1059 
thus ?thesis 
1060 
by (simp add: nonzero_inverse_mult_distrib mult_commute) 

14270  1061 
next 
1062 
assume "~ (a \<noteq> 0 & b \<noteq> 0)" 

22993  1063 
thus ?thesis 
1064 
by force 

14270  1065 
qed 
1066 

20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1067 
lemma division_ring_inverse_add: 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1068 
"[(a::'a::division_ring) \<noteq> 0; b \<noteq> 0] 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1069 
==> inverse a + inverse b = inverse a * (a+b) * inverse b" 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1070 
by (simp add: ring_simps) 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1071 

23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1072 
lemma division_ring_inverse_diff: 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1073 
"[(a::'a::division_ring) \<noteq> 0; b \<noteq> 0] 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1074 
==> inverse a  inverse b = inverse a * (ba) * inverse b" 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1075 
by (simp add: ring_simps) 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1076 

14270  1077 
text{*There is no slick version using division by zero.*} 
1078 
lemma inverse_add: 

23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1079 
"[a \<noteq> 0; b \<noteq> 0] 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1080 
==> inverse a + inverse b = (a+b) * inverse a * inverse (b::'a::field)" 
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset

1081 
by (simp add: division_ring_inverse_add mult_ac) 
14270  1082 

14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset

1083 
lemma inverse_divide [simp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1084 
"inverse (a/b) = b / (a::'a::{field,division_by_zero})" 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1085 
by (simp add: divide_inverse mult_commute) 
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset

1086 

23389  1087 

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

1088 
subsection {* Calculations with fractions *} 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

1089 

23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1090 
text{* There is a whole bunch of simprules just for class @{text 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1091 
field} but none for class @{text field} and @{text nonzero_divides} 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1092 
because the latter are covered by a simproc. *} 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1093 

24427  1094 
lemma nonzero_mult_divide_mult_cancel_left[simp,noatp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1095 
assumes [simp]: "b\<noteq>0" and [simp]: "c\<noteq>0" shows "(c*a)/(c*b) = a/(b::'a::field)" 
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1096 
proof  
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1097 
have "(c*a)/(c*b) = c * a * (inverse b * inverse c)" 
23482  1098 
by (simp add: divide_inverse nonzero_inverse_mult_distrib) 
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1099 
also have "... = a * inverse b * (inverse c * c)" 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1100 
by (simp only: mult_ac) 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1101 
also have "... = a * inverse b" 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1102 
by simp 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1103 
finally show ?thesis 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1104 
by (simp add: divide_inverse) 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1105 
qed 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1106 

23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1107 
lemma mult_divide_mult_cancel_left: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1108 
"c\<noteq>0 ==> (c*a) / (c*b) = a / (b::'a::{field,division_by_zero})" 
21328  1109 
apply (cases "b = 0") 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1110 
apply (simp_all add: nonzero_mult_divide_mult_cancel_left) 
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1111 
done 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset

1112 

24427  1113 
lemma nonzero_mult_divide_mult_cancel_right [noatp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1114 
"[b\<noteq>0; c\<noteq>0] ==> (a*c) / (b*c) = a/(b::'a::field)" 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1115 
by (simp add: mult_commute [of _ c] nonzero_mult_divide_mult_cancel_left) 
14321  1116 

23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1117 
lemma mult_divide_mult_cancel_right: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1118 
"c\<noteq>0 ==> (a*c) / (b*c) = a / (b::'a::{field,division_by_zero})" 
21328  1119 
apply (cases "b = 0") 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1120 
apply (simp_all add: nonzero_mult_divide_mult_cancel_right) 
14321  1121 
done 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1122 

14284
f1abe67c448a
reorganisation of Real/RealArith0.ML; more `Isar scripts
paulson
parents:
14277
diff
changeset

1123 
lemma divide_1 [simp]: "a/1 = (a::'a::field)" 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1124 
by (simp add: divide_inverse) 
14284
f1abe67c448a
reorganisation of Real/RealArith0.ML; more `Isar scripts
paulson
parents:
14277
diff
changeset

1125 

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

1126 
lemma times_divide_eq_right: "a * (b/c) = (a*b) / (c::'a::field)" 
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1127 
by (simp add: divide_inverse mult_assoc) 
14288  1128 

14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1129 
lemma times_divide_eq_left: "(b/c) * a = (b*a) / (c::'a::field)" 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1130 
by (simp add: divide_inverse mult_ac) 
14288  1131 

23482  1132 
lemmas times_divide_eq = times_divide_eq_right times_divide_eq_left 
1133 

24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset

1134 
lemma divide_divide_eq_right [simp,noatp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1135 
"a / (b/c) = (a*c) / (b::'a::{field,division_by_zero})" 
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1136 
by (simp add: divide_inverse mult_ac) 
14288  1137 

24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset

1138 
lemma divide_divide_eq_left [simp,noatp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1139 
"(a / b) / (c::'a::{field,division_by_zero}) = a / (b*c)" 
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1140 
by (simp add: divide_inverse mult_assoc) 
14288  1141 

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

1142 
lemma add_frac_eq: "(y::'a::field) ~= 0 ==> z ~= 0 ==> 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset

1143 
x / y + w / z = (x * z + w * y) / (y * z)" 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1144 
apply (subgoal_tac "x / y = (x * z) / (y * z)") 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1145 
apply (erule ssubst) 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1146 
apply (subgoal_tac "w / z = (w * y) / (y * z)") 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1147 
apply (erule ssubst) 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1148 
apply (rule add_divide_distrib [THEN sym]) 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1149 
apply (subst mult_commute) 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1150 
apply (erule nonzero_mult_divide_mult_cancel_left [THEN sym]) 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1151 
apply assumption 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1152 
apply (erule nonzero_mult_divide_mult_cancel_right [THEN sym]) 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

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

1154 
done 
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset

1155 

23389  1156 

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

1157 
subsubsection{*Special Cancellation Simprules for Division*} 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

1158 

24427  1159 
lemma mult_divide_mult_cancel_left_if[simp,noatp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1160 
fixes c :: "'a :: {field,division_by_zero}" 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1161 
shows "(c*a) / (c*b) = (if c=0 then 0 else a/b)" 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1162 
by (simp add: mult_divide_mult_cancel_left) 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1163 

24427  1164 
lemma nonzero_mult_divide_cancel_right[simp,noatp]: 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1165 
"b \<noteq> 0 \<Longrightarrow> a * b / b = (a::'a::field)" 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1166 
using nonzero_mult_divide_mult_cancel_right[of 1 b a] by simp 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1167 

24427  1168 
lemma nonzero_mult_divide_cancel_left[simp,noatp]: 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1169 
"a \<noteq> 0 \<Longrightarrow> a * b / a = (b::'a::field)" 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1170 
using nonzero_mult_divide_mult_cancel_left[of 1 a b] by simp 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1171 

5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1172 

24427  1173 
lemma nonzero_divide_mult_cancel_right[simp,noatp]: 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1174 
"\<lbrakk> a\<noteq>0; b\<noteq>0 \<rbrakk> \<Longrightarrow> b / (a * b) = 1/(a::'a::field)" 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1175 
using nonzero_mult_divide_mult_cancel_right[of a b 1] by simp 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1176 

24427  1177 
lemma nonzero_divide_mult_cancel_left[simp,noatp]: 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1178 
"\<lbrakk> a\<noteq>0; b\<noteq>0 \<rbrakk> \<Longrightarrow> a / (a * b) = 1/(b::'a::field)" 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1179 
using nonzero_mult_divide_mult_cancel_left[of b a 1] by simp 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1180 

5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1181 

24427  1182 
lemma nonzero_mult_divide_mult_cancel_left2[simp,noatp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1183 
"[b\<noteq>0; c\<noteq>0] ==> (c*a) / (b*c) = a/(b::'a::field)" 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1184 
using nonzero_mult_divide_mult_cancel_left[of b c a] by(simp add:mult_ac) 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1185 

24427  1186 
lemma nonzero_mult_divide_mult_cancel_right2[simp,noatp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1187 
"[b\<noteq>0; c\<noteq>0] ==> (a*c) / (c*b) = a/(b::'a::field)" 
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1188 
using nonzero_mult_divide_mult_cancel_right[of b c a] by(simp add:mult_ac) 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset

1189 

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

1190 

14293  1191 
subsection {* Division and Unary Minus *} 
1192 

1193 
lemma nonzero_minus_divide_left: "b \<noteq> 0 ==>  (a/b) = (a) / (b::'a::field)" 

1194 
by (simp add: divide_inverse minus_mult_left) 

1195 

1196 
lemma nonzero_minus_divide_right: "b \<noteq> 0 ==>  (a/b) = a / (b::'a::field)" 

1197 
by (simp add: divide_inverse nonzero_inverse_minus_eq minus_mult_right) 

1198 

1199 
lemma nonzero_minus_divide_divide: "b \<noteq> 0 ==> (a)/(b) = a / (b::'a::field)" 

1200 
by (simp add: divide_inverse nonzero_inverse_minus_eq) 

1201 

14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1202 
lemma minus_divide_left: " (a/b) = (a) / (b::'a::field)" 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1203 
by (simp add: divide_inverse minus_mult_left [symmetric]) 
14293  1204 

1205 
lemma minus_divide_right: " (a/b) = a / (b::'a::{field,division_by_zero})" 

14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1206 
by (simp add: divide_inverse minus_mult_right [symmetric]) 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1207 

14293  1208 

1209 
text{*The effect is to extract signs from divisions*} 

17085  1210 
lemmas divide_minus_left = minus_divide_left [symmetric] 
1211 
lemmas divide_minus_right = minus_divide_right [symmetric] 

1212 
declare divide_minus_left [simp] divide_minus_right [simp] 

14293  1213 

14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

1214 
text{*Also, extract signs from products*} 
17085  1215 
lemmas mult_minus_left = minus_mult_left [symmetric] 
1216 
lemmas mult_minus_right = minus_mult_right [symmetric] 

1217 
declare mult_minus_left [simp] mult_minus_right [simp] 

14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

1218 

14293  1219 
lemma minus_divide_divide [simp]: 
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset

1220 
"(a)/(b) = a / (b::'a::{field,division_by_zero})" 
21328  1221 
apply (cases "b=0", simp) 
14293  1222 
apply (simp add: nonzero_minus_divide_divide) 
1223 
done 

1224 

14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset

1225 
lemma diff_divide_distrib: "(ab)/(c::'a::field) = a/c  b/c" 
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

1226 
by (simp add: diff_minus add_divide_distrib) 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset

1227 

23482  1228 
lemma add_divide_eq_iff: 
1229 
"(z::'a::field) \<noteq> 0 \<Longrightarrow> x + y/z = (z*x + y)/z" 

1230 
by(simp add:add_divide_distrib nonzero_mult_divide_cancel_left) 

1231 

1232 
lemma divide_add_eq_iff: 

1233 
"(z::'a::field) \<noteq> 0 \<Longrightarrow> x/z + y = (x + z*y)/z" 

1234 
by(simp add:add_divide_distrib nonzero_mult_divide_cancel_left) 

1235 

1236 
lemma diff_divide_eq_iff: 

1237 
"(z::'a::field) \<noteq> 0 \<Longrightarrow> x  y/z = (z*x  y)/z" 

1238 
by(simp add:diff_divide_distrib nonzero_mult_divide_cancel_left) 

1239 

1240 
lemma divide_diff_eq_iff: 

1241 
"(z::'a::field) \<noteq> 0 \<Longrightarrow> x/z  y = (x  z*y)/z" 

1242 
by(simp add:diff_divide_distrib nonzero_mult_divide_cancel_left) 

1243 

1244 
lemma nonzero_eq_divide_eq: "c\<noteq>0 ==> ((a::'a::field) = b/c) = (a*c = b)" 

1245 
proof  

1246 
assume [simp]: "c\<noteq>0" 

23496  1247 
have "(a = b/c) = (a*c = (b/c)*c)" by simp 
1248 
also have "... = (a*c = b)" by (simp add: divide_inverse mult_assoc) 

23482  1249 
finally show ?thesis . 
1250 
qed 

1251 

1252 
lemma nonzero_divide_eq_eq: "c\<noteq>0 ==> (b/c = (a::'a::field)) = (b = a*c)" 

1253 
proof  

1254 
assume [simp]: "c\<noteq>0" 

23496  1255 
have "(b/c = a) = ((b/c)*c = a*c)" by simp 
1256 
also have "... = (b = a*c)" by (simp add: divide_inverse mult_assoc) 

23482  1257 
finally show ?thesis . 
1258 
qed 

1259 

1260 
lemma eq_divide_eq: 

1261 
"((a::'a::{field,division_by_zero}) = b/c) = (if c\<noteq>0 then a*c = b else a=0)" 

1262 
by (simp add: nonzero_eq_divide_eq) 

1263 

1264 
lemma divide_eq_eq: 

1265 
"(b/c = (a::'a::{field,division_by_zero})) = (if c\<noteq>0 then b = a*c else a=0)" 

1266 
by (force simp add: nonzero_divide_eq_eq) 

1267 

1268 
lemma divide_eq_imp: "(c::'a::{division_by_zero,field}) ~= 0 ==> 

1269 
b = a * c ==> b / c = a" 

1270 
by (subst divide_eq_eq, simp) 

1271 