| author | wenzelm | 
| Fri, 07 Dec 2007 22:19:45 +0100 | |
| changeset 25577 | d739f48ef40c | 
| parent 25564 | 4ca31a3706a4 | 
| child 25762 | c03e9d04b3e4 | 
| permissions | -rw-r--r-- | 
| 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: 
23413diff
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: 
16568diff
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: 
20633diff
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: 
20633diff
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: 
20633diff
changeset | 49 | fix a :: 'a | 
| 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
20633diff
changeset | 50 | have "0 * a + 0 * a = 0 * a + 0" | 
| 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
20633diff
changeset | 51 | by (simp add: left_distrib [symmetric]) | 
| 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
20633diff
changeset | 52 | thus "0 * a = 0" | 
| 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
20633diff
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: 
20633diff
changeset | 56 | have "a * 0 + a * 0 = a * 0 + 0" | 
| 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
20633diff
changeset | 57 | by (simp add: right_distrib [symmetric]) | 
| 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
20633diff
changeset | 58 | thus "a * 0 = 0" | 
| 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
20633diff
changeset | 59 | by (simp only: add_left_cancel) | 
| 
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
 krauss parents: 
20633diff
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: 
25450diff
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: 
25450diff
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: 
20633diff
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: 
25450diff
changeset | 103 | subclass semiring_1 by intro_locales | 
| 25152 | 104 | |
| 105 | end | |
| 14421 
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
 paulson parents: 
14398diff
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: 
25450diff
changeset | 114 | subclass semiring_0_cancel by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 115 | |
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
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: 
20633diff
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: 
25450diff
changeset | 124 | subclass semiring_1_cancel by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 125 | subclass comm_semiring_0_cancel by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
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: 
25450diff
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: 
25450diff
changeset | 182 | subclass ring by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
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: 
25450diff
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: 
25450diff
changeset | 198 | subclass ring_1 by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
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 (non-commutative version of idom);
 huffman parents: 
22987diff
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 (non-commutative version of idom);
 huffman parents: 
22987diff
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 (non-commutative version of idom);
 huffman parents: 
22987diff
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: 
14398diff
changeset | 221 | |
| 25512 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 222 | subclass ring_1_no_zero_divisors by intro_locales | 
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
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: 
19404diff
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: 
22842diff
changeset | 233 | fix a b :: 'a | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
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: 
22842diff
changeset | 235 | show "a * b \<noteq> 0" | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 236 | proof | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 237 | assume ab: "a * b = 0" | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 238 | hence "0 = inverse a * (a * b) * inverse b" | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 239 | by simp | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
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: 
22842diff
changeset | 241 | by (simp only: mult_assoc) | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 242 | also have "\<dots> = 1" | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 243 | using a b by simp | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 244 | finally show False | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 245 | by simp | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 246 | qed | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
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: 
19404diff
changeset | 248 | |
| 25186 | 249 | end | 
| 25152 | 250 | |
| 22987 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
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: 
19404diff
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: 
22842diff
changeset | 258 | fix a :: 'a | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
changeset | 259 | assume "a \<noteq> 0" | 
| 
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
 huffman parents: 
22842diff
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: 
22842diff
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: 
25450diff
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: 
14266diff
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: 
20633diff
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: 
22842diff
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: 
14267diff
changeset | 333 | |
| 25512 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 334 | subclass semiring_0_cancel by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
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: 
25450diff
changeset | 354 | subclass pordered_cancel_semiring by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 355 | |
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 356 | subclass pordered_comm_monoid_add by intro_locales | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
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: 
14334diff
changeset | 372 | |
| 25512 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
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: 
20633diff
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: 
20633diff
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: 
25450diff
changeset | 446 | subclass pordered_comm_semiring by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
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: 
14270diff
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: 
14270diff
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: 
25450diff
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 | |
| 25564 | 525 | lemma (in sgn_if) sgn0[simp]: "sgn 0 = 0" | 
| 526 | by(simp add:sgn_if) | |
| 527 | ||
| 25230 | 528 | class ordered_ring = ring + ordered_semiring | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 529 | + ordered_ab_group_add + abs_if | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 530 | begin | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 531 | |
| 25512 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 532 | subclass pordered_ring by intro_locales | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 533 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 534 | subclass pordered_ab_group_add_abs | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 535 | proof unfold_locales | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 536 | fix a b | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 537 | show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 538 | 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: 
25267diff
changeset | 539 | (auto simp del: minus_add_distrib simp add: minus_add_distrib [symmetric] | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 540 | neg_less_eq_nonneg less_eq_neg_nonpos, auto intro: add_nonneg_nonneg, | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 541 | auto intro!: less_imp_le add_neg_neg) | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 542 | qed (auto simp add: abs_if less_eq_neg_nonpos neg_equal_zero) | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 543 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 544 | end | 
| 23521 | 545 | |
| 25230 | 546 | (* The "strict" suffix can be seen as describing the combination of ordered_ring and no_zero_divisors. | 
| 547 | Basically, ordered_ring + no_zero_divisors = ordered_ring_strict. | |
| 548 | *) | |
| 549 | class ordered_ring_strict = ring + ordered_semiring_strict | |
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 550 | + ordered_ab_group_add + abs_if | 
| 25230 | 551 | begin | 
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
14341diff
changeset | 552 | |
| 25512 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 553 | subclass ordered_ring by intro_locales | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 554 | |
| 14265 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 555 | lemma mult_strict_left_mono_neg: | 
| 25230 | 556 | "b < a \<Longrightarrow> c < 0 \<Longrightarrow> c * a < c * b" | 
| 557 | apply (drule mult_strict_left_mono [of _ _ "uminus c"]) | |
| 558 | apply (simp_all add: minus_mult_left [symmetric]) | |
| 559 | done | |
| 14738 | 560 | |
| 14265 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 561 | lemma mult_strict_right_mono_neg: | 
| 25230 | 562 | "b < a \<Longrightarrow> c < 0 \<Longrightarrow> a * c < b * c" | 
| 563 | apply (drule mult_strict_right_mono [of _ _ "uminus c"]) | |
| 564 | apply (simp_all add: minus_mult_right [symmetric]) | |
| 565 | done | |
| 14738 | 566 | |
| 25230 | 567 | lemma mult_neg_neg: | 
| 568 | "a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> 0 < a * b" | |
| 569 | by (drule mult_strict_right_mono_neg, auto) | |
| 14738 | 570 | |
| 25230 | 571 | end | 
| 14738 | 572 | |
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 573 | instance ordered_ring_strict \<subseteq> ring_no_zero_divisors | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 574 | apply intro_classes | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 575 | apply (auto simp add: linorder_not_less order_le_less linorder_neq_iff) | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 576 | apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono)+ | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 577 | done | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 578 | |
| 14265 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 579 | lemma zero_less_mult_iff: | 
| 25230 | 580 | fixes a :: "'a::ordered_ring_strict" | 
| 581 | shows "0 < a * b \<longleftrightarrow> 0 < a \<and> 0 < b \<or> a < 0 \<and> b < 0" | |
| 582 | apply (auto simp add: le_less not_less mult_pos_pos mult_neg_neg) | |
| 583 | apply (blast dest: zero_less_mult_pos) | |
| 584 | apply (blast dest: zero_less_mult_pos2) | |
| 585 | done | |
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 586 | |
| 14265 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 587 | lemma zero_le_mult_iff: | 
| 14738 | 588 | "((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 | 589 | 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 | 590 | zero_less_mult_iff) | 
| 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 591 | |
| 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 592 | lemma mult_less_0_iff: | 
| 14738 | 593 | "(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 | 594 | 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 | 595 | 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 | 596 | done | 
| 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 597 | |
| 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 598 | lemma mult_le_0_iff: | 
| 14738 | 599 | "(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 | 600 | 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 | 601 | 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 | 602 | done | 
| 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 603 | |
| 23095 | 604 | lemma zero_le_square[simp]: "(0::'a::ordered_ring_strict) \<le> a*a" | 
| 605 | by (simp add: zero_le_mult_iff linorder_linear) | |
| 606 | ||
| 607 | lemma not_square_less_zero[simp]: "\<not> (a * a < (0::'a::ordered_ring_strict))" | |
| 608 | by (simp add: not_less) | |
| 14265 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 609 | |
| 25230 | 610 | text{*This list of rewrites simplifies ring terms by multiplying
 | 
| 611 | everything out and bringing sums and products into a canonical form | |
| 612 | (by ordered rewriting). As a result it decides ring equalities but | |
| 613 | also helps with inequalities. *} | |
| 614 | lemmas ring_simps = group_simps ring_distribs | |
| 615 | ||
| 616 | ||
| 617 | class pordered_comm_ring = comm_ring + pordered_comm_semiring | |
| 25267 | 618 | begin | 
| 25230 | 619 | |
| 25512 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 620 | subclass pordered_ring by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 621 | subclass pordered_cancel_comm_semiring by intro_locales | 
| 25230 | 622 | |
| 25267 | 623 | end | 
| 25230 | 624 | |
| 625 | class ordered_semidom = comm_semiring_1_cancel + ordered_comm_semiring_strict + | |
| 626 | (*previously ordered_semiring*) | |
| 627 | assumes zero_less_one [simp]: "0 < 1" | |
| 628 | begin | |
| 629 | ||
| 630 | lemma pos_add_strict: | |
| 631 | shows "0 < a \<Longrightarrow> b < c \<Longrightarrow> b < a + c" | |
| 632 | using add_strict_mono [of zero a b c] by simp | |
| 633 | ||
| 634 | end | |
| 635 | ||
| 636 | class ordered_idom = | |
| 637 | comm_ring_1 + | |
| 638 | ordered_comm_semiring_strict + | |
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 639 | ordered_ab_group_add + | 
| 25230 | 640 | abs_if + sgn_if | 
| 641 | (*previously ordered_ring*) | |
| 642 | ||
| 643 | instance ordered_idom \<subseteq> ordered_ring_strict .. | |
| 644 | ||
| 645 | instance ordered_idom \<subseteq> pordered_comm_ring .. | |
| 646 | ||
| 647 | class ordered_field = field + ordered_idom | |
| 648 | ||
| 649 | lemma linorder_neqE_ordered_idom: | |
| 650 | fixes x y :: "'a :: ordered_idom" | |
| 651 | assumes "x \<noteq> y" obtains "x < y" | "y < x" | |
| 652 | using assms by (rule linorder_neqE) | |
| 653 | ||
| 654 | ||
| 14738 | 655 | text{*Proving axiom @{text zero_less_one} makes all @{text ordered_semidom}
 | 
| 656 |       theorems available to members of @{term ordered_idom} *}
 | |
| 657 | ||
| 658 | instance ordered_idom \<subseteq> ordered_semidom | |
| 14421 
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
 paulson parents: 
14398diff
changeset | 659 | proof | 
| 
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
 paulson parents: 
14398diff
changeset | 660 | 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: 
14421diff
changeset | 661 | thus "(0::'a) < 1" by (simp add: order_le_less) | 
| 14421 
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
 paulson parents: 
14398diff
changeset | 662 | qed | 
| 
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
 paulson parents: 
14398diff
changeset | 663 | |
| 14738 | 664 | instance ordered_idom \<subseteq> idom .. | 
| 665 | ||
| 14387 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 666 | text{*All three types of comparision involving 0 and 1 are covered.*}
 | 
| 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 667 | |
| 17085 | 668 | lemmas one_neq_zero = zero_neq_one [THEN not_sym] | 
| 669 | declare one_neq_zero [simp] | |
| 14387 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 670 | |
| 14738 | 671 | 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: 
14267diff
changeset | 672 | 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: 
14267diff
changeset | 673 | |
| 14738 | 674 | lemma not_one_le_zero [simp]: "~ (1::'a::ordered_semidom) \<le> 0" | 
| 675 | by (simp add: linorder_not_le) | |
| 14387 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 676 | |
| 14738 | 677 | lemma not_one_less_zero [simp]: "~ (1::'a::ordered_semidom) < 0" | 
| 678 | by (simp add: linorder_not_less) | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 679 | |
| 23389 | 680 | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 681 | subsection{*More Monotonicity*}
 | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 682 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 683 | text{*Strict monotonicity in both arguments*}
 | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 684 | lemma mult_strict_mono: | 
| 14738 | 685 | "[|a<b; c<d; 0<b; 0\<le>c|] ==> a * c < b * (d::'a::ordered_semiring_strict)" | 
| 21328 | 686 | apply (cases "c=0") | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 687 | apply (simp add: mult_pos_pos) | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 688 | 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: 
14267diff
changeset | 689 | apply (force simp add: order_le_less) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 690 | apply (erule mult_strict_left_mono, assumption) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 691 | done | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 692 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 693 | text{*This weaker variant has more natural premises*}
 | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 694 | lemma mult_strict_mono': | 
| 14738 | 695 | "[| 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: 
14267diff
changeset | 696 | apply (rule mult_strict_mono) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 697 | apply (blast intro: order_le_less_trans)+ | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 698 | done | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 699 | |
| 14738 | 700 | 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: 
14377diff
changeset | 701 | 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: 
14421diff
changeset | 702 | apply (simp add: order_less_trans [OF zero_less_one]) | 
| 14387 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 703 | done | 
| 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 704 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 705 | 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: 
16568diff
changeset | 706 | 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: 
16568diff
changeset | 707 | apply (subgoal_tac "a * c < b * c") | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 708 | apply (erule order_less_le_trans) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 709 | apply (erule mult_left_mono) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 710 | apply simp | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 711 | apply (erule mult_strict_right_mono) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 712 | apply assumption | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 713 | done | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 714 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 715 | 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: 
16568diff
changeset | 716 | 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: 
16568diff
changeset | 717 | apply (subgoal_tac "a * c <= b * c") | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 718 | apply (erule order_le_less_trans) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 719 | apply (erule mult_strict_left_mono) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 720 | apply simp | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 721 | apply (erule mult_right_mono) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 722 | apply simp | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 723 | done | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 724 | |
| 23389 | 725 | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 726 | subsection{*Cancellation Laws for Relationships With a Common Factor*}
 | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 727 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 728 | 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: 
14267diff
changeset | 729 |    also with the relations @{text "\<le>"} and equality.*}
 | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 730 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 731 | text{*These ``disjunction'' versions produce two cases when the comparison is
 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 732 | an assumption, but effectively four when the comparison is a goal.*} | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 733 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 734 | lemma mult_less_cancel_right_disj: | 
| 14738 | 735 | "(a*c < b*c) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring_strict)))" | 
| 21328 | 736 | apply (cases "c = 0") | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 737 | 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: 
14267diff
changeset | 738 | mult_strict_right_mono_neg) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 739 | apply (auto simp add: linorder_not_less | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 740 | linorder_not_le [symmetric, of "a*c"] | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 741 | linorder_not_le [symmetric, of a]) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 742 | apply (erule_tac [!] notE) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 743 | 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: 
14267diff
changeset | 744 | mult_right_mono_neg) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 745 | done | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 746 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 747 | lemma mult_less_cancel_left_disj: | 
| 14738 | 748 | "(c*a < c*b) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring_strict)))" | 
| 21328 | 749 | apply (cases "c = 0") | 
| 14738 | 750 | apply (auto simp add: linorder_neq_iff mult_strict_left_mono | 
| 751 | mult_strict_left_mono_neg) | |
| 752 | apply (auto simp add: linorder_not_less | |
| 753 | linorder_not_le [symmetric, of "c*a"] | |
| 754 | linorder_not_le [symmetric, of a]) | |
| 755 | apply (erule_tac [!] notE) | |
| 756 | apply (auto simp add: order_less_imp_le mult_left_mono | |
| 757 | mult_left_mono_neg) | |
| 758 | done | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 759 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 760 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 761 | text{*The ``conjunction of implication'' lemmas produce two cases when the
 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 762 | comparison is a goal, but give four when the comparison is an assumption.*} | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 763 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 764 | lemma mult_less_cancel_right: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 765 | fixes c :: "'a :: ordered_ring_strict" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 766 | shows "(a*c < b*c) = ((0 \<le> c --> a < b) & (c \<le> 0 --> b < a))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 767 | by (insert mult_less_cancel_right_disj [of a c b], auto) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 768 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 769 | lemma mult_less_cancel_left: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 770 | fixes c :: "'a :: ordered_ring_strict" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 771 | shows "(c*a < c*b) = ((0 \<le> c --> a < b) & (c \<le> 0 --> b < a))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 772 | by (insert mult_less_cancel_left_disj [of c a b], auto) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 773 | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 774 | lemma mult_le_cancel_right: | 
| 14738 | 775 | "(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: 
15229diff
changeset | 776 | 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: 
14267diff
changeset | 777 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 778 | lemma mult_le_cancel_left: | 
| 14738 | 779 | "(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: 
15229diff
changeset | 780 | 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: 
14267diff
changeset | 781 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 782 | lemma mult_less_imp_less_left: | 
| 14341 
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
 paulson parents: 
14334diff
changeset | 783 | assumes less: "c*a < c*b" and nonneg: "0 \<le> c" | 
| 14738 | 784 | shows "a < (b::'a::ordered_semiring_strict)" | 
| 14377 | 785 | proof (rule ccontr) | 
| 786 | assume "~ a < b" | |
| 787 | hence "b \<le> a" by (simp add: linorder_not_less) | |
| 23389 | 788 | hence "c*b \<le> c*a" using nonneg by (rule mult_left_mono) | 
| 14377 | 789 | with this and less show False | 
| 790 | by (simp add: linorder_not_less [symmetric]) | |
| 791 | qed | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 792 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 793 | lemma mult_less_imp_less_right: | 
| 14738 | 794 | assumes less: "a*c < b*c" and nonneg: "0 <= c" | 
| 795 | shows "a < (b::'a::ordered_semiring_strict)" | |
| 796 | proof (rule ccontr) | |
| 797 | assume "~ a < b" | |
| 798 | hence "b \<le> a" by (simp add: linorder_not_less) | |
| 23389 | 799 | hence "b*c \<le> a*c" using nonneg by (rule mult_right_mono) | 
| 14738 | 800 | with this and less show False | 
| 801 | by (simp add: linorder_not_less [symmetric]) | |
| 802 | qed | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 803 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 804 | text{*Cancellation of equalities with a common factor*}
 | 
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 805 | lemma mult_cancel_right [simp,noatp]: | 
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 806 | fixes a b c :: "'a::ring_no_zero_divisors" | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 807 | shows "(a * c = b * c) = (c = 0 \<or> a = b)" | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 808 | proof - | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 809 | have "(a * c = b * c) = ((a - b) * c = 0)" | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 810 | by (simp add: ring_distribs) | 
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 811 | thus ?thesis | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 812 | by (simp add: disj_commute) | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 813 | qed | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 814 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 815 | lemma mult_cancel_left [simp,noatp]: | 
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 816 | fixes a b c :: "'a::ring_no_zero_divisors" | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 817 | shows "(c * a = c * b) = (c = 0 \<or> a = b)" | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 818 | proof - | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 819 | have "(c * a = c * b) = (c * (a - b) = 0)" | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 820 | by (simp add: ring_distribs) | 
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 821 | thus ?thesis | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 822 | by simp | 
| 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 823 | qed | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 824 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 825 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 826 | subsubsection{*Special Cancellation Simprules for Multiplication*}
 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 827 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 828 | text{*These also produce two cases when the comparison is a goal.*}
 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 829 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 830 | lemma mult_le_cancel_right1: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 831 | fixes c :: "'a :: ordered_idom" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 832 | shows "(c \<le> b*c) = ((0<c --> 1\<le>b) & (c<0 --> b \<le> 1))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 833 | by (insert mult_le_cancel_right [of 1 c b], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 834 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 835 | lemma mult_le_cancel_right2: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 836 | fixes c :: "'a :: ordered_idom" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 837 | shows "(a*c \<le> c) = ((0<c --> a\<le>1) & (c<0 --> 1 \<le> a))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 838 | by (insert mult_le_cancel_right [of a c 1], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 839 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 840 | lemma mult_le_cancel_left1: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 841 | fixes c :: "'a :: ordered_idom" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 842 | shows "(c \<le> c*b) = ((0<c --> 1\<le>b) & (c<0 --> b \<le> 1))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 843 | by (insert mult_le_cancel_left [of c 1 b], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 844 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 845 | lemma mult_le_cancel_left2: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 846 | fixes c :: "'a :: ordered_idom" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 847 | shows "(c*a \<le> c) = ((0<c --> a\<le>1) & (c<0 --> 1 \<le> a))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 848 | by (insert mult_le_cancel_left [of c a 1], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 849 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 850 | lemma mult_less_cancel_right1: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 851 | fixes c :: "'a :: ordered_idom" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 852 | shows "(c < b*c) = ((0 \<le> c --> 1<b) & (c \<le> 0 --> b < 1))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 853 | by (insert mult_less_cancel_right [of 1 c b], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 854 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 855 | lemma mult_less_cancel_right2: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 856 | fixes c :: "'a :: ordered_idom" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 857 | shows "(a*c < c) = ((0 \<le> c --> a<1) & (c \<le> 0 --> 1 < a))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 858 | by (insert mult_less_cancel_right [of a c 1], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 859 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 860 | lemma mult_less_cancel_left1: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 861 | fixes c :: "'a :: ordered_idom" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 862 | shows "(c < c*b) = ((0 \<le> c --> 1<b) & (c \<le> 0 --> b < 1))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 863 | by (insert mult_less_cancel_left [of c 1 b], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 864 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 865 | lemma mult_less_cancel_left2: | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 866 | fixes c :: "'a :: ordered_idom" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 867 | shows "(c*a < c) = ((0 \<le> c --> a<1) & (c \<le> 0 --> 1 < a))" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 868 | by (insert mult_less_cancel_left [of c a 1], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 869 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 870 | lemma mult_cancel_right1 [simp]: | 
| 23544 | 871 | fixes c :: "'a :: ring_1_no_zero_divisors" | 
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 872 | shows "(c = b*c) = (c = 0 | b=1)" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 873 | by (insert mult_cancel_right [of 1 c b], force) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 874 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 875 | lemma mult_cancel_right2 [simp]: | 
| 23544 | 876 | fixes c :: "'a :: ring_1_no_zero_divisors" | 
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 877 | shows "(a*c = c) = (c = 0 | a=1)" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 878 | by (insert mult_cancel_right [of a c 1], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 879 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 880 | lemma mult_cancel_left1 [simp]: | 
| 23544 | 881 | fixes c :: "'a :: ring_1_no_zero_divisors" | 
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 882 | shows "(c = c*b) = (c = 0 | b=1)" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 883 | by (insert mult_cancel_left [of c 1 b], force) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 884 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 885 | lemma mult_cancel_left2 [simp]: | 
| 23544 | 886 | fixes c :: "'a :: ring_1_no_zero_divisors" | 
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 887 | shows "(c*a = c) = (c = 0 | a=1)" | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 888 | by (insert mult_cancel_left [of c a 1], simp) | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 889 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 890 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 891 | text{*Simprules for comparisons where common factors can be cancelled.*}
 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 892 | lemmas mult_compare_simps = | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 893 | mult_le_cancel_right mult_le_cancel_left | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 894 | mult_le_cancel_right1 mult_le_cancel_right2 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 895 | mult_le_cancel_left1 mult_le_cancel_left2 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 896 | mult_less_cancel_right mult_less_cancel_left | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 897 | mult_less_cancel_right1 mult_less_cancel_right2 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 898 | mult_less_cancel_left1 mult_less_cancel_left2 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 899 | mult_cancel_right mult_cancel_left | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 900 | mult_cancel_right1 mult_cancel_right2 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 901 | mult_cancel_left1 mult_cancel_left2 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 902 | |
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 903 | |
| 23482 | 904 | (* what ordering?? this is a straight instance of mult_eq_0_iff | 
| 14270 | 905 | text{*Compared with @{text mult_eq_0_iff}, this version removes the requirement
 | 
| 906 | 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: 
19404diff
changeset | 907 | 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: 
19404diff
changeset | 908 | "(a*b = (0::'a::division_ring)) = (a = 0 | b = 0)" | 
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 909 | by simp | 
| 23482 | 910 | *) | 
| 23496 | 911 | (* 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: 
14267diff
changeset | 912 | text{*Cancellation of equalities with a common factor*}
 | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 913 | 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: 
19404diff
changeset | 914 | 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: 
19404diff
changeset | 915 | 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: 
19404diff
changeset | 916 | shows "a=b" | 
| 14377 | 917 | proof - | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 918 | have "(a * c) * inverse c = (b * c) * inverse c" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 919 | by (simp add: eq) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 920 | thus "a=b" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 921 | by (simp add: mult_assoc cnz) | 
| 14377 | 922 | qed | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 923 | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
14341diff
changeset | 924 | 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: 
19404diff
changeset | 925 | "(a*c = b*c) = (c = (0::'a::division_ring) | a=b)" | 
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 926 | by simp | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 927 | |
| 14348 
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
 paulson parents: 
14341diff
changeset | 928 | 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: 
19404diff
changeset | 929 | "(c*a = c*b) = (c = (0::'a::division_ring) | a=b)" | 
| 22990 
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
 huffman parents: 
22987diff
changeset | 930 | by simp | 
| 23496 | 931 | *) | 
| 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: 
19404diff
changeset | 932 | 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: 
19404diff
changeset | 933 | "a \<noteq> 0 ==> inverse a \<noteq> (0::'a::division_ring)" | 
| 14377 | 934 | proof | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 935 | assume ianz: "inverse a = 0" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 936 | assume "a \<noteq> 0" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 937 | hence "1 = a * inverse a" by simp | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 938 | 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: 
19404diff
changeset | 939 | finally have "1 = (0::'a::division_ring)" . | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 940 | thus False by (simp add: eq_commute) | 
| 14377 | 941 | qed | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 942 | |
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 943 | |
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 944 | subsection{*Basic Properties of @{term inverse}*}
 | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 945 | |
| 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: 
19404diff
changeset | 946 | 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: 
14267diff
changeset | 947 | apply (rule ccontr) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 948 | apply (blast dest: nonzero_imp_inverse_nonzero) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 949 | done | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 950 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 951 | 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: 
19404diff
changeset | 952 | "inverse a = 0 ==> a = (0::'a::division_ring)" | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 953 | apply (rule ccontr) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 954 | apply (blast dest: nonzero_imp_inverse_nonzero) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 955 | done | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 956 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 957 | 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: 
19404diff
changeset | 958 |    "(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: 
14267diff
changeset | 959 | by (force dest: inverse_nonzero_imp_nonzero) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 960 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 961 | 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: 
19404diff
changeset | 962 | 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: 
19404diff
changeset | 963 | shows "inverse(-a) = -inverse(a::'a::division_ring)" | 
| 14377 | 964 | proof - | 
| 965 | have "-a * inverse (- a) = -a * - inverse a" | |
| 966 | by simp | |
| 967 | thus ?thesis | |
| 23496 | 968 | by (simp only: mult_cancel_left, simp) | 
| 14377 | 969 | qed | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 970 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 971 | 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: 
19404diff
changeset | 972 |    "inverse(-a) = -inverse(a::'a::{division_ring,division_by_zero})"
 | 
| 14377 | 973 | proof cases | 
| 974 | assume "a=0" thus ?thesis by (simp add: inverse_zero) | |
| 975 | next | |
| 976 | assume "a\<noteq>0" | |
| 977 | thus ?thesis by (simp add: nonzero_inverse_minus_eq) | |
| 978 | qed | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 979 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 980 | lemma nonzero_inverse_eq_imp_eq: | 
| 14269 | 981 | assumes inveq: "inverse a = inverse b" | 
| 982 | and anz: "a \<noteq> 0" | |
| 983 | 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: 
19404diff
changeset | 984 | shows "a = (b::'a::division_ring)" | 
| 14377 | 985 | proof - | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 986 | have "a * inverse b = a * inverse a" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 987 | by (simp add: inveq) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 988 | hence "(a * inverse b) * b = (a * inverse a) * b" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 989 | by simp | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 990 | thus "a = b" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 991 | by (simp add: mult_assoc anz bnz) | 
| 14377 | 992 | qed | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 993 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 994 | 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: 
19404diff
changeset | 995 |   "inverse a = inverse b ==> a = (b::'a::{division_ring,division_by_zero})"
 | 
| 21328 | 996 | apply (cases "a=0 | b=0") | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 997 | apply (force dest!: inverse_zero_imp_zero | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 998 | simp add: eq_commute [of "0::'a"]) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 999 | apply (force dest!: nonzero_inverse_eq_imp_eq) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1000 | done | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1001 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1002 | 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: 
19404diff
changeset | 1003 |   "(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: 
19404diff
changeset | 1004 | by (force dest!: inverse_eq_imp_eq) | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1005 | |
| 14270 | 1006 | 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: 
19404diff
changeset | 1007 | 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: 
19404diff
changeset | 1008 | shows "inverse(inverse (a::'a::division_ring)) = a" | 
| 14270 | 1009 | proof - | 
| 1010 | have "(inverse (inverse a) * inverse a) * a = a" | |
| 1011 | by (simp add: nonzero_imp_inverse_nonzero) | |
| 1012 | thus ?thesis | |
| 1013 | by (simp add: mult_assoc) | |
| 1014 | qed | |
| 1015 | ||
| 1016 | 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: 
19404diff
changeset | 1017 |      "inverse(inverse (a::'a::{division_ring,division_by_zero})) = a"
 | 
| 14270 | 1018 | proof cases | 
| 1019 | assume "a=0" thus ?thesis by simp | |
| 1020 | next | |
| 1021 | assume "a\<noteq>0" | |
| 1022 | thus ?thesis by (simp add: nonzero_inverse_inverse_eq) | |
| 1023 | qed | |
| 1024 | ||
| 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: 
19404diff
changeset | 1025 | lemma inverse_1 [simp]: "inverse 1 = (1::'a::division_ring)" | 
| 14270 | 1026 | 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: 
19404diff
changeset | 1027 | have "inverse 1 * 1 = (1::'a::division_ring)" | 
| 14270 | 1028 | by (rule left_inverse [OF zero_neq_one [symmetric]]) | 
| 1029 | thus ?thesis by simp | |
| 1030 | qed | |
| 1031 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15010diff
changeset | 1032 | lemma inverse_unique: | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15010diff
changeset | 1033 | 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: 
19404diff
changeset | 1034 | shows "inverse a = (b::'a::division_ring)" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15010diff
changeset | 1035 | proof - | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15010diff
changeset | 1036 | have "a \<noteq> 0" using ab by auto | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15010diff
changeset | 1037 | moreover have "inverse a * (a * b) = inverse a" by (simp add: ab) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15010diff
changeset | 1038 | ultimately show ?thesis by (simp add: mult_assoc [symmetric]) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15010diff
changeset | 1039 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15010diff
changeset | 1040 | |
| 14270 | 1041 | lemma nonzero_inverse_mult_distrib: | 
| 1042 | assumes anz: "a \<noteq> 0" | |
| 1043 | 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: 
19404diff
changeset | 1044 | shows "inverse(a*b) = inverse(b) * inverse(a::'a::division_ring)" | 
| 14270 | 1045 | proof - | 
| 1046 | have "inverse(a*b) * (a * b) * inverse(b) = inverse(b)" | |
| 23482 | 1047 | by (simp add: anz bnz) | 
| 14270 | 1048 | hence "inverse(a*b) * a = inverse(b)" | 
| 1049 | by (simp add: mult_assoc bnz) | |
| 1050 | hence "inverse(a*b) * a * inverse(a) = inverse(b) * inverse(a)" | |
| 1051 | by simp | |
| 1052 | thus ?thesis | |
| 1053 | by (simp add: mult_assoc anz) | |
| 1054 | qed | |
| 1055 | ||
| 1056 | text{*This version builds in division by zero while also re-orienting
 | |
| 1057 | the right-hand side.*} | |
| 1058 | lemma inverse_mult_distrib [simp]: | |
| 1059 |      "inverse(a*b) = inverse(a) * inverse(b::'a::{field,division_by_zero})"
 | |
| 1060 | proof cases | |
| 1061 | assume "a \<noteq> 0 & b \<noteq> 0" | |
| 22993 | 1062 | thus ?thesis | 
| 1063 | by (simp add: nonzero_inverse_mult_distrib mult_commute) | |
| 14270 | 1064 | next | 
| 1065 | assume "~ (a \<noteq> 0 & b \<noteq> 0)" | |
| 22993 | 1066 | thus ?thesis | 
| 1067 | by force | |
| 14270 | 1068 | qed | 
| 1069 | ||
| 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: 
19404diff
changeset | 1070 | 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: 
19404diff
changeset | 1071 | "[|(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: 
19404diff
changeset | 1072 | ==> inverse a + inverse b = inverse a * (a+b) * inverse b" | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1073 | 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: 
19404diff
changeset | 1074 | |
| 
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
 huffman parents: 
19404diff
changeset | 1075 | 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: 
19404diff
changeset | 1076 | "[|(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: 
19404diff
changeset | 1077 | ==> inverse a - inverse b = inverse a * (b-a) * inverse b" | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1078 | 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: 
19404diff
changeset | 1079 | |
| 14270 | 1080 | text{*There is no slick version using division by zero.*}
 | 
| 1081 | lemma inverse_add: | |
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1082 | "[|a \<noteq> 0; b \<noteq> 0|] | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1083 | ==> 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: 
19404diff
changeset | 1084 | by (simp add: division_ring_inverse_add mult_ac) | 
| 14270 | 1085 | |
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1086 | lemma inverse_divide [simp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1087 |   "inverse (a/b) = b / (a::'a::{field,division_by_zero})"
 | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1088 | by (simp add: divide_inverse mult_commute) | 
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1089 | |
| 23389 | 1090 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1091 | subsection {* Calculations with fractions *}
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1092 | |
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1093 | text{* There is a whole bunch of simp-rules just for class @{text
 | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1094 | field} but none for class @{text field} and @{text nonzero_divides}
 | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1095 | because the latter are covered by a simproc. *} | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1096 | |
| 24427 | 1097 | lemma nonzero_mult_divide_mult_cancel_left[simp,noatp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1098 | 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: 
14272diff
changeset | 1099 | proof - | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1100 | have "(c*a)/(c*b) = c * a * (inverse b * inverse c)" | 
| 23482 | 1101 | by (simp add: divide_inverse nonzero_inverse_mult_distrib) | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1102 | also have "... = a * inverse b * (inverse c * c)" | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1103 | by (simp only: mult_ac) | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1104 | also have "... = a * inverse b" | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1105 | by simp | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1106 | finally show ?thesis | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1107 | by (simp add: divide_inverse) | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1108 | qed | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1109 | |
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1110 | lemma mult_divide_mult_cancel_left: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1111 |   "c\<noteq>0 ==> (c*a) / (c*b) = a / (b::'a::{field,division_by_zero})"
 | 
| 21328 | 1112 | apply (cases "b = 0") | 
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1113 | 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: 
14272diff
changeset | 1114 | done | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1115 | |
| 24427 | 1116 | lemma nonzero_mult_divide_mult_cancel_right [noatp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1117 | "[|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: 
23406diff
changeset | 1118 | by (simp add: mult_commute [of _ c] nonzero_mult_divide_mult_cancel_left) | 
| 14321 | 1119 | |
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1120 | lemma mult_divide_mult_cancel_right: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1121 |   "c\<noteq>0 ==> (a*c) / (b*c) = a / (b::'a::{field,division_by_zero})"
 | 
| 21328 | 1122 | apply (cases "b = 0") | 
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1123 | apply (simp_all add: nonzero_mult_divide_mult_cancel_right) | 
| 14321 | 1124 | done | 
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1125 | |
| 14284 
f1abe67c448a
re-organisation of Real/RealArith0.ML; more `Isar scripts
 paulson parents: 
14277diff
changeset | 1126 | lemma divide_1 [simp]: "a/1 = (a::'a::field)" | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1127 | by (simp add: divide_inverse) | 
| 14284 
f1abe67c448a
re-organisation of Real/RealArith0.ML; more `Isar scripts
 paulson parents: 
14277diff
changeset | 1128 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1129 | 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: 
14421diff
changeset | 1130 | by (simp add: divide_inverse mult_assoc) | 
| 14288 | 1131 | |
| 14430 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14421diff
changeset | 1132 | 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: 
14421diff
changeset | 1133 | by (simp add: divide_inverse mult_ac) | 
| 14288 | 1134 | |
| 23482 | 1135 | lemmas times_divide_eq = times_divide_eq_right times_divide_eq_left | 
| 1136 | ||
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1137 | lemma divide_divide_eq_right [simp,noatp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1138 |   "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: 
14421diff
changeset | 1139 | by (simp add: divide_inverse mult_ac) | 
| 14288 | 1140 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1141 | lemma divide_divide_eq_left [simp,noatp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1142 |   "(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: 
14421diff
changeset | 1143 | by (simp add: divide_inverse mult_assoc) | 
| 14288 | 1144 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1145 | 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: 
16568diff
changeset | 1146 | x / y + w / z = (x * z + w * y) / (y * z)" | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1147 | apply (subgoal_tac "x / y = (x * z) / (y * z)") | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1148 | apply (erule ssubst) | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1149 | apply (subgoal_tac "w / z = (w * y) / (y * z)") | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1150 | apply (erule ssubst) | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1151 | apply (rule add_divide_distrib [THEN sym]) | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1152 | apply (subst mult_commute) | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1153 | apply (erule nonzero_mult_divide_mult_cancel_left [THEN sym]) | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1154 | apply assumption | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1155 | apply (erule nonzero_mult_divide_mult_cancel_right [THEN sym]) | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1156 | apply assumption | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1157 | done | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1158 | |
| 23389 | 1159 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1160 | subsubsection{*Special Cancellation Simprules for Division*}
 | 
| 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1161 | |
| 24427 | 1162 | lemma mult_divide_mult_cancel_left_if[simp,noatp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1163 | fixes c :: "'a :: {field,division_by_zero}"
 | 
| 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1164 | 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: 
23406diff
changeset | 1165 | by (simp add: mult_divide_mult_cancel_left) | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1166 | |
| 24427 | 1167 | lemma nonzero_mult_divide_cancel_right[simp,noatp]: | 
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1168 | "b \<noteq> 0 \<Longrightarrow> a * b / b = (a::'a::field)" | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1169 | using nonzero_mult_divide_mult_cancel_right[of 1 b a] by simp | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1170 | |
| 24427 | 1171 | lemma nonzero_mult_divide_cancel_left[simp,noatp]: | 
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1172 | "a \<noteq> 0 \<Longrightarrow> a * b / a = (b::'a::field)" | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1173 | using nonzero_mult_divide_mult_cancel_left[of 1 a b] by simp | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1174 | |
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1175 | |
| 24427 | 1176 | lemma nonzero_divide_mult_cancel_right[simp,noatp]: | 
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1177 | "\<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: 
23406diff
changeset | 1178 | using nonzero_mult_divide_mult_cancel_right[of a b 1] by simp | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1179 | |
| 24427 | 1180 | lemma nonzero_divide_mult_cancel_left[simp,noatp]: | 
| 23413 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1181 | "\<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: 
23406diff
changeset | 1182 | using nonzero_mult_divide_mult_cancel_left[of b a 1] by simp | 
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1183 | |
| 
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
 nipkow parents: 
23406diff
changeset | 1184 | |
| 24427 | 1185 | lemma nonzero_mult_divide_mult_cancel_left2[simp,noatp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1186 | "[|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: 
23406diff
changeset | 1187 | 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: 
23406diff
changeset | 1188 | |
| 24427 | 1189 | lemma nonzero_mult_divide_mult_cancel_right2[simp,noatp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1190 | "[|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: 
23406diff
changeset | 1191 | 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: 
23406diff
changeset | 1192 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1193 | |
| 14293 | 1194 | subsection {* Division and Unary Minus *}
 | 
| 1195 | ||
| 1196 | lemma nonzero_minus_divide_left: "b \<noteq> 0 ==> - (a/b) = (-a) / (b::'a::field)" | |
| 1197 | by (simp add: divide_inverse minus_mult_left) | |
| 1198 | ||
| 1199 | lemma nonzero_minus_divide_right: "b \<noteq> 0 ==> - (a/b) = a / -(b::'a::field)" | |
| 1200 | by (simp add: divide_inverse nonzero_inverse_minus_eq minus_mult_right) | |
| 1201 | ||
| 1202 | lemma nonzero_minus_divide_divide: "b \<noteq> 0 ==> (-a)/(-b) = a / (b::'a::field)" | |
| 1203 | by (simp add: divide_inverse nonzero_inverse_minus_eq) | |
| 1204 | ||
| 14430 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14421diff
changeset | 1205 | lemma minus_divide_left: "- (a/b) = (-a) / (b::'a::field)" | 
| 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14421diff
changeset | 1206 | by (simp add: divide_inverse minus_mult_left [symmetric]) | 
| 14293 | 1207 | |
| 1208 | 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: 
14421diff
changeset | 1209 | by (simp add: divide_inverse minus_mult_right [symmetric]) | 
| 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14421diff
changeset | 1210 | |
| 14293 | 1211 | |
| 1212 | text{*The effect is to extract signs from divisions*}
 | |
| 17085 | 1213 | lemmas divide_minus_left = minus_divide_left [symmetric] | 
| 1214 | lemmas divide_minus_right = minus_divide_right [symmetric] | |
| 1215 | declare divide_minus_left [simp] divide_minus_right [simp] | |
| 14293 | 1216 | |
| 14387 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 1217 | text{*Also, extract signs from products*}
 | 
| 17085 | 1218 | lemmas mult_minus_left = minus_mult_left [symmetric] | 
| 1219 | lemmas mult_minus_right = minus_mult_right [symmetric] | |
| 1220 | declare mult_minus_left [simp] mult_minus_right [simp] | |
| 14387 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 1221 | |
| 14293 | 1222 | lemma minus_divide_divide [simp]: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 1223 |   "(-a)/(-b) = a / (b::'a::{field,division_by_zero})"
 | 
| 21328 | 1224 | apply (cases "b=0", simp) | 
| 14293 | 1225 | apply (simp add: nonzero_minus_divide_divide) | 
| 1226 | done | |
| 1227 | ||
| 14430 
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
 paulson parents: 
14421diff
changeset | 1228 | lemma diff_divide_distrib: "(a-b)/(c::'a::field) = a/c - b/c" | 
| 14387 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 1229 | by (simp add: diff_minus add_divide_distrib) | 
| 
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
 paulson parents: 
14377diff
changeset | 1230 | |
| 23482 | 1231 | lemma add_divide_eq_iff: | 
| 1232 | "(z::'a::field) \<noteq> 0 \<Longrightarrow> x + y/z = (z*x + y)/z" | |
| 1233 | by(simp add:add_divide_distrib nonzero_mult_divide_cancel_left) | |
| 1234 | ||
| 1235 | lemma divide_add_eq_iff: | |
| 1236 | "(z::'a::field) \<noteq> 0 \<Longrightarrow> x/z + y = (x + z*y)/z" | |
| 1237 | by(simp add:add_divide_distrib nonzero_mult_divide_cancel_left) | |
| 1238 | ||
| 1239 | lemma diff_divide_eq_iff: | |
| 1240 | "(z::'a::field) \<noteq> 0 \<Longrightarrow> x - y/z = (z*x - y)/z" | |
| 1241 | by(simp add:diff_divide_distrib nonzero_mult_divide_cancel_left) | |
| 1242 | ||
| 1243 | lemma divide_diff_eq_iff: | |
| 1244 | "(z::'a::field) \<noteq> 0 \<Longrightarrow> x/z - y = (x - z*y)/z" | |
| 1245 | by(simp add:diff_divide_distrib nonzero_mult_divide_cancel_left) | |
| 1246 | ||
| 1247 | lemma nonzero_eq_divide_eq: "c\<noteq>0 ==> ((a::'a::field) = b/c) = (a*c = b)" | |
| 1248 | proof - | |
| 1249 | assume [simp]: "c\<noteq>0" | |
| 23496 | 1250 | have "(a = b/c) = (a*c = (b/c)*c)" by simp | 
| 1251 | also have "... = (a*c = b)" by (simp add: divide_inverse mult_assoc) | |
| 23482 | 1252 | finally show ?thesis . | 
| 1253 | qed | |
| 1254 | ||
| 1255 | lemma nonzero_divide_eq_eq: "c\<noteq>0 ==> (b/c = (a::'a::field)) = (b = a*c)" | |
| 1256 | proof - | |
| 1257 | assume [simp]: "c\<noteq>0" | |
| 23496 | 1258 | have "(b/c = a) = ((b/c)*c = a*c)" by simp | 
| 1259 | also have "... = (b = a*c)" by (simp add: divide_inverse mult_assoc) | |
| 23482 | 1260 | finally show ?thesis . | 
| 1261 | qed | |
| 1262 | ||
| 1263 | lemma eq_divide_eq: | |
| 1264 |   "((a::'a::{field,division_by_zero}) = b/c) = (if c\<noteq>0 then a*c = b else a=0)"
 | |
| 1265 | by (simp add: nonzero_eq_divide_eq) | |
| 1266 | ||
| 1267 | lemma divide_eq_eq: | |
| 1268 |   "(b/c = (a::'a::{field,division_by_zero})) = (if c\<noteq>0 then b = a*c else a=0)"
 | |
| 1269 | by (force simp add: nonzero_divide_eq_eq) | |
| 1270 | ||
| 1271 | lemma divide_eq_imp: "(c::'a::{division_by_zero,field}) ~= 0 ==>
 | |
| 1272 | b = a * c ==> b / c = a" | |
| 1273 | by (subst divide_eq_eq, simp) | |
| 1274 | ||
| 1275 | lemma eq_divide_imp: "(c::'a::{division_by_zero,field}) ~= 0 ==>
 | |
| 1276 | a * c = b ==> a = b / c" | |
| 1277 | by (subst eq_divide_eq, simp) | |
| 1278 | ||
| 1279 | ||
| 1280 | lemmas field_eq_simps = ring_simps | |
| 1281 | (* pull / out*) | |
| 1282 | add_divide_eq_iff divide_add_eq_iff | |
| 1283 | diff_divide_eq_iff divide_diff_eq_iff | |
| 1284 | (* multiply eqn *) | |
| 1285 | nonzero_eq_divide_eq nonzero_divide_eq_eq | |
| 1286 | (* is added later: | |
| 1287 | times_divide_eq_left times_divide_eq_right | |
| 1288 | *) | |
| 1289 | ||
| 1290 | text{*An example:*}
 | |
| 1291 | lemma fixes a b c d e f :: "'a::field" | |
| 1292 | shows "\<lbrakk>a\<noteq>b; c\<noteq>d; e\<noteq>f \<rbrakk> \<Longrightarrow> ((a-b)*(c-d)*(e-f))/((c-d)*(e-f)*(a-b)) = 1" | |
| 1293 | apply(subgoal_tac "(c-d)*(e-f)*(a-b) \<noteq> 0") | |
| 1294 | apply(simp add:field_eq_simps) | |
| 1295 | apply(simp) | |
| 1296 | done | |
| 1297 | ||
| 1298 | ||
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1299 | lemma diff_frac_eq: "(y::'a::field) ~= 0 ==> z ~= 0 ==> | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1300 | x / y - w / z = (x * z - w * y) / (y * z)" | 
| 23482 | 1301 | by (simp add:field_eq_simps times_divide_eq) | 
| 1302 | ||
| 1303 | lemma frac_eq_eq: "(y::'a::field) ~= 0 ==> z ~= 0 ==> | |
| 1304 | (x / y = w / z) = (x * z = w * y)" | |
| 1305 | by (simp add:field_eq_simps times_divide_eq) | |
| 14293 | 1306 | |
| 23389 | 1307 | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1308 | subsection {* Ordered Fields *}
 | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1309 | |
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1310 | lemma positive_imp_inverse_positive: | 
| 23482 | 1311 | assumes a_gt_0: "0 < a" shows "0 < inverse (a::'a::ordered_field)" | 
| 1312 | proof - | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1313 | have "0 < a * inverse a" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1314 | by (simp add: a_gt_0 [THEN order_less_imp_not_eq2] zero_less_one) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1315 | thus "0 < inverse a" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1316 | by (simp add: a_gt_0 [THEN order_less_not_sym] zero_less_mult_iff) | 
| 23482 | 1317 | qed | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1318 | |
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1319 | lemma negative_imp_inverse_negative: | 
| 23482 | 1320 | "a < 0 ==> inverse a < (0::'a::ordered_field)" | 
| 1321 | by (insert positive_imp_inverse_positive [of "-a"], | |
| 1322 | simp add: nonzero_inverse_minus_eq order_less_imp_not_eq) | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1323 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1324 | lemma inverse_le_imp_le: | 
| 23482 | 1325 | assumes invle: "inverse a \<le> inverse b" and apos: "0 < a" | 
| 1326 | shows "b \<le> (a::'a::ordered_field)" | |
| 1327 | proof (rule classical) | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1328 | assume "~ b \<le> a" | 
| 23482 | 1329 | hence "a < b" by (simp add: linorder_not_le) | 
| 1330 | hence bpos: "0 < b" by (blast intro: apos order_less_trans) | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1331 | hence "a * inverse a \<le> a * inverse b" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1332 | by (simp add: apos invle order_less_imp_le mult_left_mono) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1333 | hence "(a * inverse a) * b \<le> (a * inverse b) * b" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1334 | by (simp add: bpos order_less_imp_le mult_right_mono) | 
| 23482 | 1335 | thus "b \<le> a" by (simp add: mult_assoc apos bpos order_less_imp_not_eq2) | 
| 1336 | qed | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1337 | |
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1338 | lemma inverse_positive_imp_positive: | 
| 23482 | 1339 | assumes inv_gt_0: "0 < inverse a" and nz: "a \<noteq> 0" | 
| 1340 | shows "0 < (a::'a::ordered_field)" | |
| 23389 | 1341 | proof - | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1342 | have "0 < inverse (inverse a)" | 
| 23389 | 1343 | using inv_gt_0 by (rule positive_imp_inverse_positive) | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1344 | thus "0 < a" | 
| 23389 | 1345 | using nz by (simp add: nonzero_inverse_inverse_eq) | 
| 1346 | qed | |
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1347 | |
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1348 | lemma inverse_positive_iff_positive [simp]: | 
| 23482 | 1349 |   "(0 < inverse a) = (0 < (a::'a::{ordered_field,division_by_zero}))"
 | 
| 21328 | 1350 | apply (cases "a = 0", simp) | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1351 | apply (blast intro: inverse_positive_imp_positive positive_imp_inverse_positive) | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1352 | done | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1353 | |
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1354 | lemma inverse_negative_imp_negative: | 
| 23482 | 1355 | assumes inv_less_0: "inverse a < 0" and nz: "a \<noteq> 0" | 
| 1356 | shows "a < (0::'a::ordered_field)" | |
| 23389 | 1357 | proof - | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1358 | have "inverse (inverse a) < 0" | 
| 23389 | 1359 | using inv_less_0 by (rule negative_imp_inverse_negative) | 
| 23482 | 1360 | thus "a < 0" using nz by (simp add: nonzero_inverse_inverse_eq) | 
| 23389 | 1361 | qed | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1362 | |
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1363 | lemma inverse_negative_iff_negative [simp]: | 
| 23482 | 1364 |   "(inverse a < 0) = (a < (0::'a::{ordered_field,division_by_zero}))"
 | 
| 21328 | 1365 | apply (cases "a = 0", simp) | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1366 | apply (blast intro: inverse_negative_imp_negative negative_imp_inverse_negative) | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1367 | done | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1368 | |
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1369 | lemma inverse_nonnegative_iff_nonnegative [simp]: | 
| 23482 | 1370 |   "(0 \<le> inverse a) = (0 \<le> (a::'a::{ordered_field,division_by_zero}))"
 | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1371 | by (simp add: linorder_not_less [symmetric]) | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1372 | |
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1373 | lemma inverse_nonpositive_iff_nonpositive [simp]: | 
| 23482 | 1374 |   "(inverse a \<le> 0) = (a \<le> (0::'a::{ordered_field,division_by_zero}))"
 | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1375 | by (simp add: linorder_not_less [symmetric]) | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1376 | |
| 23406 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1377 | lemma ordered_field_no_lb: "\<forall> x. \<exists>y. y < (x::'a::ordered_field)" | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1378 | proof | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1379 | fix x::'a | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1380 | have m1: "- (1::'a) < 0" by simp | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1381 | from add_strict_right_mono[OF m1, where c=x] | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1382 | have "(- 1) + x < x" by simp | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1383 | thus "\<exists>y. y < x" by blast | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1384 | qed | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1385 | |
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1386 | lemma ordered_field_no_ub: "\<forall> x. \<exists>y. y > (x::'a::ordered_field)" | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1387 | proof | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1388 | fix x::'a | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1389 | have m1: " (1::'a) > 0" by simp | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1390 | from add_strict_right_mono[OF m1, where c=x] | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1391 | have "1 + x > x" by simp | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1392 | thus "\<exists>y. y > x" by blast | 
| 
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
 chaieb parents: 
23400diff
changeset | 1393 | qed | 
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1394 | |
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1395 | subsection{*Anti-Monotonicity of @{term inverse}*}
 | 
| 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1396 | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1397 | lemma less_imp_inverse_less: | 
| 23482 | 1398 | assumes less: "a < b" and apos: "0 < a" | 
| 1399 | shows "inverse b < inverse (a::'a::ordered_field)" | |
| 1400 | proof (rule ccontr) | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1401 | assume "~ inverse b < inverse a" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1402 | hence "inverse a \<le> inverse b" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1403 | by (simp add: linorder_not_less) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1404 | hence "~ (a < b)" | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1405 | by (simp add: linorder_not_less inverse_le_imp_le [OF _ apos]) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1406 | thus False | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1407 | by (rule notE [OF _ less]) | 
| 23482 | 1408 | qed | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1409 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1410 | lemma inverse_less_imp_less: | 
| 23482 | 1411 | "[|inverse a < inverse b; 0 < a|] ==> b < (a::'a::ordered_field)" | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1412 | apply (simp add: order_less_le [of "inverse a"] order_less_le [of "b"]) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1413 | apply (force dest!: inverse_le_imp_le nonzero_inverse_eq_imp_eq) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1414 | done | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1415 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1416 | text{*Both premises are essential. Consider -1 and 1.*}
 | 
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1417 | lemma inverse_less_iff_less [simp,noatp]: | 
| 23482 | 1418 | "[|0 < a; 0 < b|] ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))" | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1419 | by (blast intro: less_imp_inverse_less dest: inverse_less_imp_less) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1420 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1421 | lemma le_imp_inverse_le: | 
| 23482 | 1422 | "[|a \<le> b; 0 < a|] ==> inverse b \<le> inverse (a::'a::ordered_field)" | 
| 1423 | by (force simp add: order_le_less less_imp_inverse_less) | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1424 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1425 | lemma inverse_le_iff_le [simp,noatp]: | 
| 23482 | 1426 | "[|0 < a; 0 < b|] ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))" | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1427 | by (blast intro: le_imp_inverse_le dest: inverse_le_imp_le) | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1428 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1429 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1430 | text{*These results refer to both operands being negative.  The opposite-sign
 | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1431 | case is trivial, since inverse preserves signs.*} | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1432 | lemma inverse_le_imp_le_neg: | 
| 23482 | 1433 | "[|inverse a \<le> inverse b; b < 0|] ==> b \<le> (a::'a::ordered_field)" | 
| 1434 | apply (rule classical) | |
| 1435 | apply (subgoal_tac "a < 0") | |
| 1436 | prefer 2 apply (force simp add: linorder_not_le intro: order_less_trans) | |
| 1437 | apply (insert inverse_le_imp_le [of "-b" "-a"]) | |
| 1438 | apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) | |
| 1439 | done | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1440 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1441 | lemma less_imp_inverse_less_neg: | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1442 | "[|a < b; b < 0|] ==> inverse b < inverse (a::'a::ordered_field)" | 
| 23482 | 1443 | apply (subgoal_tac "a < 0") | 
| 1444 | prefer 2 apply (blast intro: order_less_trans) | |
| 1445 | apply (insert less_imp_inverse_less [of "-b" "-a"]) | |
| 1446 | apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) | |
| 1447 | done | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1448 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1449 | lemma inverse_less_imp_less_neg: | 
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1450 | "[|inverse a < inverse b; b < 0|] ==> b < (a::'a::ordered_field)" | 
| 23482 | 1451 | apply (rule classical) | 
| 1452 | apply (subgoal_tac "a < 0") | |
| 1453 | prefer 2 | |
| 1454 | apply (force simp add: linorder_not_less intro: order_le_less_trans) | |
| 1455 | apply (insert inverse_less_imp_less [of "-b" "-a"]) | |
| 1456 | apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) | |
| 1457 | done | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1458 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1459 | lemma inverse_less_iff_less_neg [simp,noatp]: | 
| 23482 | 1460 | "[|a < 0; b < 0|] ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))" | 
| 1461 | apply (insert inverse_less_iff_less [of "-b" "-a"]) | |
| 1462 | apply (simp del: inverse_less_iff_less | |
| 1463 | add: order_less_imp_not_eq nonzero_inverse_minus_eq) | |
| 1464 | done | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1465 | |
| 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1466 | lemma le_imp_inverse_le_neg: | 
| 23482 | 1467 | "[|a \<le> b; b < 0|] ==> inverse b \<le> inverse (a::'a::ordered_field)" | 
| 1468 | by (force simp add: order_le_less less_imp_inverse_less_neg) | |
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1469 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1470 | lemma inverse_le_iff_le_neg [simp,noatp]: | 
| 23482 | 1471 | "[|a < 0; b < 0|] ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))" | 
| 14268 
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
 paulson parents: 
14267diff
changeset | 1472 | by (blast intro: le_imp_inverse_le_neg dest: inverse_le_imp_le_neg) | 
| 14265 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 1473 | |
| 14277 
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
 paulson parents: 
14272diff
changeset | 1474 | |
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1475 | subsection{*Inverses and the Number One*}
 | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1476 | |
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1477 | lemma one_less_inverse_iff: | 
| 23482 | 1478 |   "(1 < inverse x) = (0 < x & x < (1::'a::{ordered_field,division_by_zero}))"
 | 
| 1479 | proof cases | |
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1480 | assume "0 < x" | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1481 | with inverse_less_iff_less [OF zero_less_one, of x] | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1482 | show ?thesis by simp | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1483 | next | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1484 | assume notless: "~ (0 < x)" | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1485 | have "~ (1 < inverse x)" | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1486 | proof | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1487 | assume "1 < inverse x" | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1488 | also with notless have "... \<le> 0" by (simp add: linorder_not_less) | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1489 | also have "... < 1" by (rule zero_less_one) | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1490 | finally show False by auto | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1491 | qed | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1492 | with notless show ?thesis by simp | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1493 | qed | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1494 | |
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1495 | lemma inverse_eq_1_iff [simp]: | 
| 23482 | 1496 |   "(inverse x = 1) = (x = (1::'a::{field,division_by_zero}))"
 | 
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1497 | by (insert inverse_eq_iff_eq [of x 1], simp) | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1498 | |
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1499 | lemma one_le_inverse_iff: | 
| 23482 | 1500 |   "(1 \<le> inverse x) = (0 < x & x \<le> (1::'a::{ordered_field,division_by_zero}))"
 | 
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1501 | by (force simp add: order_le_less one_less_inverse_iff zero_less_one | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1502 | eq_commute [of 1]) | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1503 | |
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1504 | lemma inverse_less_1_iff: | 
| 23482 | 1505 |   "(inverse x < 1) = (x \<le> 0 | 1 < (x::'a::{ordered_field,division_by_zero}))"
 | 
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1506 | by (simp add: linorder_not_le [symmetric] one_le_inverse_iff) | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1507 | |
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1508 | lemma inverse_le_1_iff: | 
| 23482 | 1509 |   "(inverse x \<le> 1) = (x \<le> 0 | 1 \<le> (x::'a::{ordered_field,division_by_zero}))"
 | 
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1510 | by (simp add: linorder_not_less [symmetric] one_less_inverse_iff) | 
| 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1511 | |
| 23389 | 1512 | |
| 14288 | 1513 | subsection{*Simplification of Inequalities Involving Literal Divisors*}
 | 
| 1514 | ||
| 1515 | lemma pos_le_divide_eq: "0 < (c::'a::ordered_field) ==> (a \<le> b/c) = (a*c \<le> b)" | |
| 1516 | proof - | |
| 1517 | assume less: "0<c" | |
| 1518 | hence "(a \<le> b/c) = (a*c \<le> (b/c)*c)" | |
| 1519 | by (simp add: mult_le_cancel_right order_less_not_sym [OF less]) | |
| 1520 | also have "... = (a*c \<le> b)" | |
| 1521 | by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) | |
| 1522 | finally show ?thesis . | |
| 1523 | qed | |
| 1524 | ||
| 1525 | lemma neg_le_divide_eq: "c < (0::'a::ordered_field) ==> (a \<le> b/c) = (b \<le> a*c)" | |
| 1526 | proof - | |
| 1527 | assume less: "c<0" | |
| 1528 | hence "(a \<le> b/c) = ((b/c)*c \<le> a*c)" | |
| 1529 | by (simp add: mult_le_cancel_right order_less_not_sym [OF less]) | |
| 1530 | also have "... = (b \<le> a*c)" | |
| 1531 | by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) | |
| 1532 | finally show ?thesis . | |
| 1533 | qed | |
| 1534 | ||
| 1535 | lemma le_divide_eq: | |
| 1536 | "(a \<le> b/c) = | |
| 1537 | (if 0 < c then a*c \<le> b | |
| 1538 | else if c < 0 then b \<le> a*c | |
| 1539 |              else  a \<le> (0::'a::{ordered_field,division_by_zero}))"
 | |
| 21328 | 1540 | apply (cases "c=0", simp) | 
| 14288 | 1541 | apply (force simp add: pos_le_divide_eq neg_le_divide_eq linorder_neq_iff) | 
| 1542 | done | |
| 1543 | ||
| 1544 | lemma pos_divide_le_eq: "0 < (c::'a::ordered_field) ==> (b/c \<le> a) = (b \<le> a*c)" | |
| 1545 | proof - | |
| 1546 | assume less: "0<c" | |
| 1547 | hence "(b/c \<le> a) = ((b/c)*c \<le> a*c)" | |
| 1548 | by (simp add: mult_le_cancel_right order_less_not_sym [OF less]) | |
| 1549 | also have "... = (b \<le> a*c)" | |
| 1550 | by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) | |
| 1551 | finally show ?thesis . | |
| 1552 | qed | |
| 1553 | ||
| 1554 | lemma neg_divide_le_eq: "c < (0::'a::ordered_field) ==> (b/c \<le> a) = (a*c \<le> b)" | |
| 1555 | proof - | |
| 1556 | assume less: "c<0" | |
| 1557 | hence "(b/c \<le> a) = (a*c \<le> (b/c)*c)" | |
| 1558 | by (simp add: mult_le_cancel_right order_less_not_sym [OF less]) | |
| 1559 | also have "... = (a*c \<le> b)" | |
| 1560 | by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) | |
| 1561 | finally show ?thesis . | |
| 1562 | qed | |
| 1563 | ||
| 1564 | lemma divide_le_eq: | |
| 1565 | "(b/c \<le> a) = | |
| 1566 | (if 0 < c then b \<le> a*c | |
| 1567 | else if c < 0 then a*c \<le> b | |
| 1568 |              else 0 \<le> (a::'a::{ordered_field,division_by_zero}))"
 | |
| 21328 | 1569 | apply (cases "c=0", simp) | 
| 14288 | 1570 | apply (force simp add: pos_divide_le_eq neg_divide_le_eq linorder_neq_iff) | 
| 1571 | done | |
| 1572 | ||
| 1573 | lemma pos_less_divide_eq: | |
| 1574 | "0 < (c::'a::ordered_field) ==> (a < b/c) = (a*c < b)" | |
| 1575 | proof - | |
| 1576 | assume less: "0<c" | |
| 1577 | hence "(a < b/c) = (a*c < (b/c)*c)" | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1578 | by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less]) | 
| 14288 | 1579 | also have "... = (a*c < b)" | 
| 1580 | by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) | |
| 1581 | finally show ?thesis . | |
| 1582 | qed | |
| 1583 | ||
| 1584 | lemma neg_less_divide_eq: | |
| 1585 | "c < (0::'a::ordered_field) ==> (a < b/c) = (b < a*c)" | |
| 1586 | proof - | |
| 1587 | assume less: "c<0" | |
| 1588 | hence "(a < b/c) = ((b/c)*c < a*c)" | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1589 | by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less]) | 
| 14288 | 1590 | also have "... = (b < a*c)" | 
| 1591 | by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) | |
| 1592 | finally show ?thesis . | |
| 1593 | qed | |
| 1594 | ||
| 1595 | lemma less_divide_eq: | |
| 1596 | "(a < b/c) = | |
| 1597 | (if 0 < c then a*c < b | |
| 1598 | else if c < 0 then b < a*c | |
| 1599 |              else  a < (0::'a::{ordered_field,division_by_zero}))"
 | |
| 21328 | 1600 | apply (cases "c=0", simp) | 
| 14288 | 1601 | apply (force simp add: pos_less_divide_eq neg_less_divide_eq linorder_neq_iff) | 
| 1602 | done | |
| 1603 | ||
| 1604 | lemma pos_divide_less_eq: | |
| 1605 | "0 < (c::'a::ordered_field) ==> (b/c < a) = (b < a*c)" | |
| 1606 | proof - | |
| 1607 | assume less: "0<c" | |
| 1608 | hence "(b/c < a) = ((b/c)*c < a*c)" | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1609 | by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less]) | 
| 14288 | 1610 | also have "... = (b < a*c)" | 
| 1611 | by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) | |
| 1612 | finally show ?thesis . | |
| 1613 | qed | |
| 1614 | ||
| 1615 | lemma neg_divide_less_eq: | |
| 1616 | "c < (0::'a::ordered_field) ==> (b/c < a) = (a*c < b)" | |
| 1617 | proof - | |
| 1618 | assume less: "c<0" | |
| 1619 | hence "(b/c < a) = (a*c < (b/c)*c)" | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1620 | by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less]) | 
| 14288 | 1621 | also have "... = (a*c < b)" | 
| 1622 | by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) | |
| 1623 | finally show ?thesis . | |
| 1624 | qed | |
| 1625 | ||
| 1626 | lemma divide_less_eq: | |
| 1627 | "(b/c < a) = | |
| 1628 | (if 0 < c then b < a*c | |
| 1629 | else if c < 0 then a*c < b | |
| 1630 |              else 0 < (a::'a::{ordered_field,division_by_zero}))"
 | |
| 21328 | 1631 | apply (cases "c=0", simp) | 
| 14288 | 1632 | apply (force simp add: pos_divide_less_eq neg_divide_less_eq linorder_neq_iff) | 
| 1633 | done | |
| 1634 | ||
| 23482 | 1635 | |
| 1636 | subsection{*Field simplification*}
 | |
| 1637 | ||
| 1638 | text{* Lemmas @{text field_simps} multiply with denominators in
 | |
| 1639 | in(equations) if they can be proved to be non-zero (for equations) or | |
| 1640 | positive/negative (for inequations). *} | |
| 14288 | 1641 | |
| 23482 | 1642 | lemmas field_simps = field_eq_simps | 
| 1643 | (* multiply ineqn *) | |
| 1644 | pos_divide_less_eq neg_divide_less_eq | |
| 1645 | pos_less_divide_eq neg_less_divide_eq | |
| 1646 | pos_divide_le_eq neg_divide_le_eq | |
| 1647 | pos_le_divide_eq neg_le_divide_eq | |
| 14288 | 1648 | |
| 23482 | 1649 | text{* Lemmas @{text sign_simps} is a first attempt to automate proofs
 | 
| 23483 | 1650 | of positivity/negativity needed for @{text field_simps}. Have not added @{text
 | 
| 23482 | 1651 | sign_simps} to @{text field_simps} because the former can lead to case
 | 
| 1652 | explosions. *} | |
| 14288 | 1653 | |
| 23482 | 1654 | lemmas sign_simps = group_simps | 
| 1655 | zero_less_mult_iff mult_less_0_iff | |
| 14288 | 1656 | |
| 23482 | 1657 | (* Only works once linear arithmetic is installed: | 
| 1658 | text{*An example:*}
 | |
| 1659 | lemma fixes a b c d e f :: "'a::ordered_field" | |
| 1660 | shows "\<lbrakk>a>b; c<d; e<f; 0 < u \<rbrakk> \<Longrightarrow> | |
| 1661 | ((a-b)*(c-d)*(e-f))/((c-d)*(e-f)*(a-b)) < | |
| 1662 | ((e-f)*(a-b)*(c-d))/((e-f)*(a-b)*(c-d)) + u" | |
| 1663 | apply(subgoal_tac "(c-d)*(e-f)*(a-b) > 0") | |
| 1664 | prefer 2 apply(simp add:sign_simps) | |
| 1665 | apply(subgoal_tac "(c-d)*(e-f)*(a-b)*u > 0") | |
| 1666 | prefer 2 apply(simp add:sign_simps) | |
| 1667 | apply(simp add:field_simps) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1668 | done | 
| 23482 | 1669 | *) | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1670 | |
| 23389 | 1671 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1672 | subsection{*Division and Signs*}
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1673 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1674 | lemma zero_less_divide_iff: | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1675 |      "((0::'a::{ordered_field,division_by_zero}) < a/b) = (0 < a & 0 < b | a < 0 & b < 0)"
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1676 | by (simp add: divide_inverse zero_less_mult_iff) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1677 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1678 | lemma divide_less_0_iff: | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1679 |      "(a/b < (0::'a::{ordered_field,division_by_zero})) = 
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1680 | (0 < a & b < 0 | a < 0 & 0 < b)" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1681 | by (simp add: divide_inverse mult_less_0_iff) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1682 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1683 | lemma zero_le_divide_iff: | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1684 |      "((0::'a::{ordered_field,division_by_zero}) \<le> a/b) =
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1685 | (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1686 | by (simp add: divide_inverse zero_le_mult_iff) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1687 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1688 | lemma divide_le_0_iff: | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1689 |      "(a/b \<le> (0::'a::{ordered_field,division_by_zero})) =
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1690 | (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1691 | by (simp add: divide_inverse mult_le_0_iff) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1692 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1693 | lemma divide_eq_0_iff [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1694 |      "(a/b = 0) = (a=0 | b=(0::'a::{field,division_by_zero}))"
 | 
| 23482 | 1695 | by (simp add: divide_inverse) | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1696 | |
| 23482 | 1697 | lemma divide_pos_pos: | 
| 1698 | "0 < (x::'a::ordered_field) ==> 0 < y ==> 0 < x / y" | |
| 1699 | by(simp add:field_simps) | |
| 1700 | ||
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1701 | |
| 23482 | 1702 | lemma divide_nonneg_pos: | 
| 1703 | "0 <= (x::'a::ordered_field) ==> 0 < y ==> 0 <= x / y" | |
| 1704 | by(simp add:field_simps) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1705 | |
| 23482 | 1706 | lemma divide_neg_pos: | 
| 1707 | "(x::'a::ordered_field) < 0 ==> 0 < y ==> x / y < 0" | |
| 1708 | by(simp add:field_simps) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1709 | |
| 23482 | 1710 | lemma divide_nonpos_pos: | 
| 1711 | "(x::'a::ordered_field) <= 0 ==> 0 < y ==> x / y <= 0" | |
| 1712 | by(simp add:field_simps) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1713 | |
| 23482 | 1714 | lemma divide_pos_neg: | 
| 1715 | "0 < (x::'a::ordered_field) ==> y < 0 ==> x / y < 0" | |
| 1716 | by(simp add:field_simps) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1717 | |
| 23482 | 1718 | lemma divide_nonneg_neg: | 
| 1719 | "0 <= (x::'a::ordered_field) ==> y < 0 ==> x / y <= 0" | |
| 1720 | by(simp add:field_simps) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1721 | |
| 23482 | 1722 | lemma divide_neg_neg: | 
| 1723 | "(x::'a::ordered_field) < 0 ==> y < 0 ==> 0 < x / y" | |
| 1724 | by(simp add:field_simps) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1725 | |
| 23482 | 1726 | lemma divide_nonpos_neg: | 
| 1727 | "(x::'a::ordered_field) <= 0 ==> y < 0 ==> 0 <= x / y" | |
| 1728 | by(simp add:field_simps) | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 1729 | |
| 23389 | 1730 | |
| 14288 | 1731 | subsection{*Cancellation Laws for Division*}
 | 
| 1732 | ||
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1733 | lemma divide_cancel_right [simp,noatp]: | 
| 14288 | 1734 |      "(a/c = b/c) = (c = 0 | a = (b::'a::{field,division_by_zero}))"
 | 
| 23482 | 1735 | apply (cases "c=0", simp) | 
| 23496 | 1736 | apply (simp add: divide_inverse) | 
| 14288 | 1737 | done | 
| 1738 | ||
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1739 | lemma divide_cancel_left [simp,noatp]: | 
| 14288 | 1740 |      "(c/a = c/b) = (c = 0 | a = (b::'a::{field,division_by_zero}))" 
 | 
| 23482 | 1741 | apply (cases "c=0", simp) | 
| 23496 | 1742 | apply (simp add: divide_inverse) | 
| 14288 | 1743 | done | 
| 1744 | ||
| 23389 | 1745 | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1746 | subsection {* Division and the Number One *}
 | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1747 | |
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1748 | text{*Simplify expressions equated with 1*}
 | 
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1749 | lemma divide_eq_1_iff [simp,noatp]: | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1750 |      "(a/b = 1) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))"
 | 
| 23482 | 1751 | apply (cases "b=0", simp) | 
| 1752 | apply (simp add: right_inverse_eq) | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1753 | done | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1754 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1755 | lemma one_eq_divide_iff [simp,noatp]: | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1756 |      "(1 = a/b) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))"
 | 
| 23482 | 1757 | by (simp add: eq_commute [of 1]) | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1758 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1759 | lemma zero_eq_1_divide_iff [simp,noatp]: | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1760 |      "((0::'a::{ordered_field,division_by_zero}) = 1/a) = (a = 0)"
 | 
| 23482 | 1761 | apply (cases "a=0", simp) | 
| 1762 | apply (auto simp add: nonzero_eq_divide_eq) | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1763 | done | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1764 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1765 | lemma one_divide_eq_0_iff [simp,noatp]: | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1766 |      "(1/a = (0::'a::{ordered_field,division_by_zero})) = (a = 0)"
 | 
| 23482 | 1767 | apply (cases "a=0", simp) | 
| 1768 | apply (insert zero_neq_one [THEN not_sym]) | |
| 1769 | apply (auto simp add: nonzero_divide_eq_eq) | |
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1770 | done | 
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1771 | |
| 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1772 | text{*Simplify expressions such as @{text "0 < 1/x"} to @{text "0 < x"}*}
 | 
| 18623 | 1773 | lemmas zero_less_divide_1_iff = zero_less_divide_iff [of 1, simplified] | 
| 1774 | lemmas divide_less_0_1_iff = divide_less_0_iff [of 1, simplified] | |
| 1775 | lemmas zero_le_divide_1_iff = zero_le_divide_iff [of 1, simplified] | |
| 1776 | lemmas divide_le_0_1_iff = divide_le_0_iff [of 1, simplified] | |
| 17085 | 1777 | |
| 1778 | declare zero_less_divide_1_iff [simp] | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1779 | declare divide_less_0_1_iff [simp,noatp] | 
| 17085 | 1780 | declare zero_le_divide_1_iff [simp] | 
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1781 | declare divide_le_0_1_iff [simp,noatp] | 
| 14353 
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
 paulson parents: 
14348diff
changeset | 1782 | |
| 23389 | 1783 | |
| 14293 | 1784 | subsection {* Ordering Rules for Division *}
 | 
| 1785 | ||
| 1786 | lemma divide_strict_right_mono: | |
| 1787 | "[|a < b; 0 < c|] ==> a / c < b / (c::'a::ordered_field)" | |
| 1788 | by (simp add: order_less_imp_not_eq2 divide_inverse mult_strict_right_mono | |
| 23482 | 1789 | positive_imp_inverse_positive) | 
| 14293 | 1790 | |
| 1791 | lemma divide_right_mono: | |
| 1792 |      "[|a \<le> b; 0 \<le> c|] ==> a/c \<le> b/(c::'a::{ordered_field,division_by_zero})"
 | |
| 23482 | 1793 | by (force simp add: divide_strict_right_mono order_le_less) | 
| 14293 | 1794 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1795 | lemma divide_right_mono_neg: "(a::'a::{division_by_zero,ordered_field}) <= b 
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1796 | ==> c <= 0 ==> b / c <= a / c" | 
| 23482 | 1797 | apply (drule divide_right_mono [of _ _ "- c"]) | 
| 1798 | apply auto | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1799 | done | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1800 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1801 | lemma divide_strict_right_mono_neg: | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1802 | "[|b < a; c < 0|] ==> a / c < b / (c::'a::ordered_field)" | 
| 23482 | 1803 | apply (drule divide_strict_right_mono [of _ _ "-c"], simp) | 
| 1804 | apply (simp add: order_less_imp_not_eq nonzero_minus_divide_right [symmetric]) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1805 | done | 
| 14293 | 1806 | |
| 1807 | text{*The last premise ensures that @{term a} and @{term b} 
 | |
| 1808 | have the same sign*} | |
| 1809 | lemma divide_strict_left_mono: | |
| 23482 | 1810 | "[|b < a; 0 < c; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)" | 
| 1811 | by(auto simp: field_simps times_divide_eq zero_less_mult_iff mult_strict_right_mono) | |
| 14293 | 1812 | |
| 1813 | lemma divide_left_mono: | |
| 23482 | 1814 | "[|b \<le> a; 0 \<le> c; 0 < a*b|] ==> c / a \<le> c / (b::'a::ordered_field)" | 
| 1815 | by(auto simp: field_simps times_divide_eq zero_less_mult_iff mult_right_mono) | |
| 14293 | 1816 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1817 | lemma divide_left_mono_neg: "(a::'a::{division_by_zero,ordered_field}) <= b 
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1818 | ==> c <= 0 ==> 0 < a * b ==> c / a <= c / b" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1819 | apply (drule divide_left_mono [of _ _ "- c"]) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1820 | apply (auto simp add: mult_commute) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1821 | done | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1822 | |
| 14293 | 1823 | lemma divide_strict_left_mono_neg: | 
| 23482 | 1824 | "[|a < b; c < 0; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)" | 
| 1825 | by(auto simp: field_simps times_divide_eq zero_less_mult_iff mult_strict_right_mono_neg) | |
| 1826 | ||
| 14293 | 1827 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1828 | text{*Simplify quotients that are compared with the value 1.*}
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1829 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1830 | lemma le_divide_eq_1 [noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1831 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1832 | shows "(1 \<le> b / a) = ((0 < a & a \<le> b) | (a < 0 & b \<le> a))" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1833 | by (auto simp add: le_divide_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1834 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1835 | lemma divide_le_eq_1 [noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1836 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1837 | shows "(b / a \<le> 1) = ((0 < a & b \<le> a) | (a < 0 & a \<le> b) | a=0)" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1838 | by (auto simp add: divide_le_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1839 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1840 | lemma less_divide_eq_1 [noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1841 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1842 | shows "(1 < b / a) = ((0 < a & a < b) | (a < 0 & b < a))" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1843 | by (auto simp add: less_divide_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1844 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1845 | lemma divide_less_eq_1 [noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1846 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1847 | shows "(b / a < 1) = ((0 < a & b < a) | (a < 0 & a < b) | a=0)" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1848 | by (auto simp add: divide_less_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1849 | |
| 23389 | 1850 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1851 | subsection{*Conditional Simplification Rules: No Case Splits*}
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1852 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1853 | lemma le_divide_eq_1_pos [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1854 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1855 | shows "0 < a \<Longrightarrow> (1 \<le> b/a) = (a \<le> b)" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1856 | by (auto simp add: le_divide_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1857 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1858 | lemma le_divide_eq_1_neg [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1859 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1860 | shows "a < 0 \<Longrightarrow> (1 \<le> b/a) = (b \<le> a)" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1861 | by (auto simp add: le_divide_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1862 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1863 | lemma divide_le_eq_1_pos [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1864 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1865 | shows "0 < a \<Longrightarrow> (b/a \<le> 1) = (b \<le> a)" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1866 | by (auto simp add: divide_le_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1867 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1868 | lemma divide_le_eq_1_neg [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1869 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1870 | shows "a < 0 \<Longrightarrow> (b/a \<le> 1) = (a \<le> b)" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1871 | by (auto simp add: divide_le_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1872 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1873 | lemma less_divide_eq_1_pos [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1874 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1875 | shows "0 < a \<Longrightarrow> (1 < b/a) = (a < b)" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1876 | by (auto simp add: less_divide_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1877 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1878 | lemma less_divide_eq_1_neg [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1879 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1880 | shows "a < 0 \<Longrightarrow> (1 < b/a) = (b < a)" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1881 | by (auto simp add: less_divide_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1882 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1883 | lemma divide_less_eq_1_pos [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1884 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1885 | shows "0 < a \<Longrightarrow> (b/a < 1) = (b < a)" | 
| 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1886 | by (auto simp add: divide_less_eq) | 
| 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1887 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1888 | lemma divide_less_eq_1_neg [simp,noatp]: | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1889 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1890 | shows "a < 0 \<Longrightarrow> b/a < 1 <-> a < b" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1891 | by (auto simp add: divide_less_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1892 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1893 | lemma eq_divide_eq_1 [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1894 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1895 | shows "(1 = b/a) = ((a \<noteq> 0 & a = b))" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1896 | by (auto simp add: eq_divide_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1897 | |
| 24286 
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
 paulson parents: 
23879diff
changeset | 1898 | lemma divide_eq_eq_1 [simp,noatp]: | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1899 |   fixes a :: "'a :: {ordered_field,division_by_zero}"
 | 
| 18649 
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
 paulson parents: 
18623diff
changeset | 1900 | shows "(b/a = 1) = ((a \<noteq> 0 & a = b))" | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1901 | by (auto simp add: divide_eq_eq) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1902 | |
| 23389 | 1903 | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1904 | subsection {* Reasoning about inequalities with division *}
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1905 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1906 | lemma mult_right_le_one_le: "0 <= (x::'a::ordered_idom) ==> 0 <= y ==> y <= 1 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1907 | ==> x * y <= x" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1908 | by (auto simp add: mult_compare_simps); | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1909 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1910 | lemma mult_left_le_one_le: "0 <= (x::'a::ordered_idom) ==> 0 <= y ==> y <= 1 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1911 | ==> y * x <= x" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1912 | by (auto simp add: mult_compare_simps); | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1913 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1914 | lemma mult_imp_div_pos_le: "0 < (y::'a::ordered_field) ==> x <= z * y ==> | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1915 | x / y <= z"; | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1916 | by (subst pos_divide_le_eq, assumption+); | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1917 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1918 | lemma mult_imp_le_div_pos: "0 < (y::'a::ordered_field) ==> z * y <= x ==> | 
| 23482 | 1919 | z <= x / y" | 
| 1920 | by(simp add:field_simps) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1921 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1922 | lemma mult_imp_div_pos_less: "0 < (y::'a::ordered_field) ==> x < z * y ==> | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1923 | x / y < z" | 
| 23482 | 1924 | by(simp add:field_simps) | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1925 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1926 | lemma mult_imp_less_div_pos: "0 < (y::'a::ordered_field) ==> z * y < x ==> | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1927 | z < x / y" | 
| 23482 | 1928 | by(simp add:field_simps) | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1929 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1930 | lemma frac_le: "(0::'a::ordered_field) <= x ==> | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1931 | x <= y ==> 0 < w ==> w <= z ==> x / z <= y / w" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1932 | apply (rule mult_imp_div_pos_le) | 
| 25230 | 1933 | apply simp | 
| 1934 | apply (subst times_divide_eq_left) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1935 | apply (rule mult_imp_le_div_pos, assumption) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1936 | apply (rule mult_mono) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1937 | apply simp_all | 
| 14293 | 1938 | done | 
| 1939 | ||
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1940 | lemma frac_less: "(0::'a::ordered_field) <= x ==> | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1941 | x < y ==> 0 < w ==> w <= z ==> x / z < y / w" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1942 | apply (rule mult_imp_div_pos_less) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1943 | apply simp; | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1944 | apply (subst times_divide_eq_left); | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1945 | apply (rule mult_imp_less_div_pos, assumption) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1946 | apply (erule mult_less_le_imp_less) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1947 | apply simp_all | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1948 | done | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1949 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1950 | lemma frac_less2: "(0::'a::ordered_field) < x ==> | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1951 | x <= y ==> 0 < w ==> w < z ==> x / z < y / w" | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1952 | apply (rule mult_imp_div_pos_less) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1953 | apply simp_all | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1954 | apply (subst times_divide_eq_left); | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1955 | apply (rule mult_imp_less_div_pos, assumption) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1956 | apply (erule mult_le_less_imp_less) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1957 | apply simp_all | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1958 | done | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1959 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1960 | text{*It's not obvious whether these should be simprules or not. 
 | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1961 | Their effect is to gather terms into one big fraction, like | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1962 | a*b*c / x*y*z. The rationale for that is unclear, but many proofs | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1963 | seem to need them.*} | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1964 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 1965 | declare times_divide_eq [simp] | 
| 14293 | 1966 | |
| 23389 | 1967 | |
| 14293 | 1968 | subsection {* Ordered Fields are Dense *}
 | 
| 1969 | ||
| 25193 | 1970 | context ordered_semidom | 
| 1971 | begin | |
| 1972 | ||
| 1973 | lemma less_add_one: "a < a + 1" | |
| 14293 | 1974 | proof - | 
| 25193 | 1975 | have "a + 0 < a + 1" | 
| 23482 | 1976 | by (blast intro: zero_less_one add_strict_left_mono) | 
| 14293 | 1977 | thus ?thesis by simp | 
| 1978 | qed | |
| 1979 | ||
| 25193 | 1980 | lemma zero_less_two: "0 < 1 + 1" | 
| 1981 | by (blast intro: less_trans zero_less_one less_add_one) | |
| 1982 | ||
| 1983 | end | |
| 14365 
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
 paulson parents: 
14353diff
changeset | 1984 | |
| 14293 | 1985 | lemma less_half_sum: "a < b ==> a < (a+b) / (1+1::'a::ordered_field)" | 
| 23482 | 1986 | by (simp add: field_simps zero_less_two) | 
| 14293 | 1987 | |
| 1988 | lemma gt_half_sum: "a < b ==> (a+b)/(1+1::'a::ordered_field) < b" | |
| 23482 | 1989 | by (simp add: field_simps zero_less_two) | 
| 14293 | 1990 | |
| 24422 | 1991 | instance ordered_field < dense_linear_order | 
| 1992 | proof | |
| 1993 | fix x y :: 'a | |
| 1994 | have "x < x + 1" by simp | |
| 1995 | then show "\<exists>y. x < y" .. | |
| 1996 | have "x - 1 < x" by simp | |
| 1997 | then show "\<exists>y. y < x" .. | |
| 1998 | show "x < y \<Longrightarrow> \<exists>z>x. z < y" by (blast intro!: less_half_sum gt_half_sum) | |
| 1999 | qed | |
| 14293 | 2000 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 2001 | |
| 14293 | 2002 | subsection {* Absolute Value *}
 | 
| 2003 | ||
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2004 | context ordered_idom | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2005 | begin | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2006 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2007 | lemma mult_sgn_abs: "sgn x * abs x = x" | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2008 | unfolding abs_if sgn_if by auto | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2009 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2010 | end | 
| 24491 | 2011 | |
| 14738 | 2012 | lemma abs_one [simp]: "abs 1 = (1::'a::ordered_idom)" | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2013 | by (simp add: abs_if zero_less_one [THEN order_less_not_sym]) | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2014 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2015 | class pordered_ring_abs = pordered_ring + pordered_ab_group_add_abs + | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2016 | assumes abs_eq_mult: | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2017 | "(0 \<le> a \<or> a \<le> 0) \<and> (0 \<le> b \<or> b \<le> 0) \<Longrightarrow> \<bar>a * b\<bar> = \<bar>a\<bar> * \<bar>b\<bar>" | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2018 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2019 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2020 | class lordered_ring = pordered_ring + lordered_ab_group_add_abs | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2021 | begin | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2022 | |
| 25512 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 2023 | subclass lordered_ab_group_add_meet by intro_locales | 
| 
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
 haftmann parents: 
25450diff
changeset | 2024 | subclass lordered_ab_group_add_join by intro_locales | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2025 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2026 | end | 
| 14294 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2027 | |
| 14738 | 2028 | lemma abs_le_mult: "abs (a * b) \<le> (abs a) * (abs (b::'a::lordered_ring))" | 
| 2029 | proof - | |
| 2030 | let ?x = "pprt a * pprt b - pprt a * nprt b - nprt a * pprt b + nprt a * nprt b" | |
| 2031 | let ?y = "pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b" | |
| 2032 | have a: "(abs a) * (abs b) = ?x" | |
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 2033 | by (simp only: abs_prts[of a] abs_prts[of b] ring_simps) | 
| 14738 | 2034 |   {
 | 
| 2035 | fix u v :: 'a | |
| 15481 | 2036 | have bh: "\<lbrakk>u = a; v = b\<rbrakk> \<Longrightarrow> | 
| 2037 | u * v = pprt a * pprt b + pprt a * nprt b + | |
| 2038 | nprt a * pprt b + nprt a * nprt b" | |
| 14738 | 2039 | apply (subst prts[of u], subst prts[of v]) | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 2040 | apply (simp add: ring_simps) | 
| 14738 | 2041 | done | 
| 2042 | } | |
| 2043 | note b = this[OF refl[of a] refl[of b]] | |
| 2044 | note addm = add_mono[of "0::'a" _ "0::'a", simplified] | |
| 2045 | note addm2 = add_mono[of _ "0::'a" _ "0::'a", simplified] | |
| 2046 | have xy: "- ?x <= ?y" | |
| 14754 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
 obua parents: 
14738diff
changeset | 2047 | apply (simp) | 
| 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
 obua parents: 
14738diff
changeset | 2048 | apply (rule_tac y="0::'a" in order_trans) | 
| 16568 | 2049 | apply (rule addm2) | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2050 | apply (simp_all add: mult_nonneg_nonneg mult_nonpos_nonpos) | 
| 16568 | 2051 | apply (rule addm) | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2052 | apply (simp_all add: mult_nonneg_nonneg mult_nonpos_nonpos) | 
| 14754 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
 obua parents: 
14738diff
changeset | 2053 | done | 
| 14738 | 2054 | have yx: "?y <= ?x" | 
| 16568 | 2055 | apply (simp add:diff_def) | 
| 14754 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
 obua parents: 
14738diff
changeset | 2056 | apply (rule_tac y=0 in order_trans) | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2057 | apply (rule addm2, (simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)+) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2058 | apply (rule addm, (simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)+) | 
| 14738 | 2059 | done | 
| 2060 | have i1: "a*b <= abs a * abs b" by (simp only: a b yx) | |
| 2061 | have i2: "- (abs a * abs b) <= a*b" by (simp only: a b xy) | |
| 2062 | show ?thesis | |
| 2063 | apply (rule abs_leI) | |
| 2064 | apply (simp add: i1) | |
| 2065 | apply (simp add: i2[simplified minus_le_iff]) | |
| 2066 | done | |
| 2067 | qed | |
| 14294 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2068 | |
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2069 | instance lordered_ring \<subseteq> pordered_ring_abs | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2070 | proof | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2071 | fix a b :: "'a\<Colon> lordered_ring" | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2072 | assume "(0 \<le> a \<or> a \<le> 0) \<and> (0 \<le> b \<or> b \<le> 0)" | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2073 | show "abs (a*b) = abs a * abs b" | 
| 14738 | 2074 | proof - | 
| 2075 | have s: "(0 <= a*b) | (a*b <= 0)" | |
| 2076 | apply (auto) | |
| 2077 | apply (rule_tac split_mult_pos_le) | |
| 2078 | apply (rule_tac contrapos_np[of "a*b <= 0"]) | |
| 2079 | apply (simp) | |
| 2080 | apply (rule_tac split_mult_neg_le) | |
| 2081 | apply (insert prems) | |
| 2082 | apply (blast) | |
| 2083 | done | |
| 2084 | have mulprts: "a * b = (pprt a + nprt a) * (pprt b + nprt b)" | |
| 2085 | by (simp add: prts[symmetric]) | |
| 2086 | show ?thesis | |
| 2087 | proof cases | |
| 2088 | assume "0 <= a * b" | |
| 2089 | then show ?thesis | |
| 2090 | apply (simp_all add: mulprts abs_prts) | |
| 2091 | apply (insert prems) | |
| 14754 
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
 obua parents: 
14738diff
changeset | 2092 | apply (auto simp add: | 
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 2093 | ring_simps | 
| 25078 | 2094 | iffD1[OF zero_le_iff_zero_nprt] iffD1[OF le_zero_iff_zero_pprt] | 
| 2095 | iffD1[OF le_zero_iff_pprt_id] iffD1[OF zero_le_iff_nprt_id]) | |
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2096 | apply(drule (1) mult_nonneg_nonpos[of a b], simp) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2097 | apply(drule (1) mult_nonneg_nonpos2[of b a], simp) | 
| 14738 | 2098 | done | 
| 2099 | next | |
| 2100 | assume "~(0 <= a*b)" | |
| 2101 | with s have "a*b <= 0" by simp | |
| 2102 | then show ?thesis | |
| 2103 | apply (simp_all add: mulprts abs_prts) | |
| 2104 | apply (insert prems) | |
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 2105 | apply (auto simp add: ring_simps) | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2106 | apply(drule (1) mult_nonneg_nonneg[of a b],simp) | 
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2107 | apply(drule (1) mult_nonpos_nonpos[of a b],simp) | 
| 14738 | 2108 | done | 
| 2109 | qed | |
| 2110 | qed | |
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2111 | qed | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2112 | |
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2113 | instance ordered_idom \<subseteq> pordered_ring_abs | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2114 | by default (auto simp add: abs_if not_less | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2115 | equal_neg_zero neg_equal_zero mult_less_0_iff) | 
| 14294 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2116 | |
| 14738 | 2117 | lemma abs_mult: "abs (a * b) = abs a * abs (b::'a::ordered_idom)" | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2118 | by (simp add: abs_eq_mult linorder_linear) | 
| 14293 | 2119 | |
| 14738 | 2120 | lemma abs_mult_self: "abs a * abs a = a * (a::'a::ordered_idom)" | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2121 | by (simp add: abs_if) | 
| 14294 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2122 | |
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2123 | lemma nonzero_abs_inverse: | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2124 | "a \<noteq> 0 ==> abs (inverse (a::'a::ordered_field)) = inverse (abs a)" | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2125 | apply (auto simp add: linorder_neq_iff abs_if nonzero_inverse_minus_eq | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2126 | negative_imp_inverse_negative) | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2127 | apply (blast intro: positive_imp_inverse_positive elim: order_less_asym) | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2128 | done | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2129 | |
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2130 | lemma abs_inverse [simp]: | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2131 |      "abs (inverse (a::'a::{ordered_field,division_by_zero})) = 
 | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2132 | inverse (abs a)" | 
| 21328 | 2133 | apply (cases "a=0", simp) | 
| 14294 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2134 | apply (simp add: nonzero_abs_inverse) | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2135 | done | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2136 | |
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2137 | lemma nonzero_abs_divide: | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2138 | "b \<noteq> 0 ==> abs (a / (b::'a::ordered_field)) = abs a / abs b" | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2139 | by (simp add: divide_inverse abs_mult nonzero_abs_inverse) | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2140 | |
| 15234 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 paulson parents: 
15229diff
changeset | 2141 | lemma abs_divide [simp]: | 
| 14294 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2142 |      "abs (a / (b::'a::{ordered_field,division_by_zero})) = abs a / abs b"
 | 
| 21328 | 2143 | apply (cases "b=0", simp) | 
| 14294 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2144 | apply (simp add: nonzero_abs_divide) | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2145 | done | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2146 | |
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2147 | lemma abs_mult_less: | 
| 14738 | 2148 | "[| abs a < c; abs b < d |] ==> abs a * abs b < c*(d::'a::ordered_idom)" | 
| 14294 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2149 | proof - | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2150 | assume ac: "abs a < c" | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2151 | hence cpos: "0<c" by (blast intro: order_le_less_trans abs_ge_zero) | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2152 | assume "abs b < d" | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2153 | thus ?thesis by (simp add: ac cpos mult_strict_mono) | 
| 
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
 paulson parents: 
14293diff
changeset | 2154 | qed | 
| 14293 | 2155 | |
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2156 | lemmas eq_minus_self_iff = equal_neg_zero | 
| 14738 | 2157 | |
| 2158 | lemma less_minus_self_iff: "(a < -a) = (a < (0::'a::ordered_idom))" | |
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2159 | unfolding order_less_le less_eq_neg_nonpos equal_neg_zero .. | 
| 14738 | 2160 | |
| 2161 | lemma abs_less_iff: "(abs a < b) = (a < b & -a < (b::'a::ordered_idom))" | |
| 2162 | apply (simp add: order_less_le abs_le_iff) | |
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2163 | apply (auto simp add: abs_if neg_less_eq_nonneg less_eq_neg_nonpos) | 
| 14738 | 2164 | done | 
| 2165 | ||
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2166 | lemma abs_mult_pos: "(0::'a::ordered_idom) <= x ==> | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2167 | (abs y) * x = abs (y * x)" | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2168 | apply (subst abs_mult) | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2169 | apply simp | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2170 | done | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2171 | |
| 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2172 | lemma abs_div_pos: "(0::'a::{division_by_zero,ordered_field}) < y ==> 
 | 
| 25304 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2173 | abs x / y = abs (x / y)" | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2174 | apply (subst abs_divide) | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2175 | apply (simp add: order_less_imp_le) | 
| 
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
 haftmann parents: 
25267diff
changeset | 2176 | done | 
| 16775 
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
 avigad parents: 
16568diff
changeset | 2177 | |
| 23389 | 2178 | |
| 19404 | 2179 | subsection {* Bounds of products via negative and positive Part *}
 | 
| 15178 | 2180 | |
| 15580 | 2181 | lemma mult_le_prts: | 
| 2182 | assumes | |
| 2183 | "a1 <= (a::'a::lordered_ring)" | |
| 2184 | "a <= a2" | |
| 2185 | "b1 <= b" | |
| 2186 | "b <= b2" | |
| 2187 | shows | |
| 2188 | "a * b <= pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1" | |
| 2189 | proof - | |
| 2190 | have "a * b = (pprt a + nprt a) * (pprt b + nprt b)" | |
| 2191 | apply (subst prts[symmetric])+ | |
| 2192 | apply simp | |
| 2193 | done | |
| 2194 | then have "a * b = pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b" | |
| 23477 
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
 nipkow parents: 
23413diff
changeset | 2195 | by (simp add: ring_simps) | 
| 15580 | 2196 | moreover have "pprt a * pprt b <= pprt a2 * pprt b2" | 
| 2197 | by (simp_all add: prems mult_mono) | |
| 2198 | moreover have "pprt a * nprt b <= pprt a1 * nprt b2" | |
| 2199 | proof - | |
| 2200 | have "pprt a * nprt b <= pprt a * nprt b2" | |
| 2201 | by (simp add: mult_left_mono prems) | |
| 2202 | moreover have "pprt a * nprt b2 <= pprt a1 * nprt b2" | |
| 2203 | by (simp add: mult_right_mono_neg prems) | |
| 2204 | ultimately show ?thesis | |
| 2205 | by simp | |
| 2206 | qed | |
| 2207 | moreover have "nprt a * pprt b <= nprt a2 * pprt b1" | |
| 2208 | proof - | |
| 2209 | have "nprt a * pprt b <= nprt a2 * pprt b" | |
| 2210 | by (simp add: mult_right_mono prems) | |
| 2211 | moreover have "nprt a2 * pprt b <= nprt a2 * pprt b1" | |
| 2212 | by (simp add: mult_left_mono_neg prems) | |
| 2213 | ultimately show ?thesis | |
| 2214 | by simp | |
| 2215 | qed | |
| 2216 | moreover have "nprt a * nprt b <= nprt a1 * nprt b1" | |
| 2217 | proof - | |
| 2218 | have "nprt a * nprt b <= nprt a * nprt b1" | |
| 2219 | by (simp add: mult_left_mono_neg prems) | |
| 2220 | moreover have "nprt a * nprt b1 <= nprt a1 * nprt b1" | |
| 2221 | by (simp add: mult_right_mono_neg prems) | |
| 2222 | ultimately show ?thesis | |
| 2223 | by simp | |
| 2224 | qed | |
| 2225 | ultimately show ?thesis | |
| 2226 | by - (rule add_mono | simp)+ | |
| 2227 | qed | |
| 19404 | 2228 | |
| 2229 | lemma mult_ge_prts: | |
| 15178 | 2230 | assumes | 
| 19404 | 2231 | "a1 <= (a::'a::lordered_ring)" | 
| 2232 | "a <= a2" | |
| 2233 | "b1 <= b" | |
| 2234 | "b <= b2" | |
| 15178 | 2235 | shows | 
| 19404 | 2236 | "a * b >= nprt a1 * pprt b2 + nprt a2 * nprt b2 + pprt a1 * pprt b1 + pprt a2 * nprt b1" | 
| 2237 | proof - | |
| 2238 | from prems have a1:"- a2 <= -a" by auto | |
| 2239 | from prems have a2: "-a <= -a1" by auto | |
| 2240 | from mult_le_prts[of "-a2" "-a" "-a1" "b1" b "b2", OF a1 a2 prems(3) prems(4), simplified nprt_neg pprt_neg] | |
| 2241 | have le: "- (a * b) <= - nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1" by simp | |
| 2242 | then have "-(- nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1) <= a * b" | |
| 2243 | by (simp only: minus_le_iff) | |
| 2244 | then show ?thesis by simp | |
| 15178 | 2245 | qed | 
| 2246 | ||
| 14265 
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
 paulson parents: diff
changeset | 2247 | end |