author | nipkow |
Wed, 28 Jan 2009 16:57:12 +0100 | |
changeset 29668 | 33ba3faeaa0e |
parent 29653 | ece6a0e9f8af |
parent 29667 | 53103fc8ffa3 |
child 29700 | 22faf21db3df |
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:
23413
diff
changeset
|
3 |
Author: Gertrud Bauer, Steven Obua, Tobias Nipkow, Lawrence C Paulson, and Markus Wenzel, |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
4 |
with contributions by Jeremy Avigad |
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
5 |
*) |
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
6 |
|
14738 | 7 |
header {* (Ordered) Rings and Fields *} |
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
8 |
|
15229 | 9 |
theory Ring_and_Field |
15140 | 10 |
imports OrderedGroup |
15131 | 11 |
begin |
14504 | 12 |
|
14738 | 13 |
text {* |
14 |
The theory of partially ordered rings is taken from the books: |
|
15 |
\begin{itemize} |
|
16 |
\item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979 |
|
17 |
\item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963 |
|
18 |
\end{itemize} |
|
19 |
Most of the used notions can also be looked up in |
|
20 |
\begin{itemize} |
|
14770 | 21 |
\item \url{http://www.mathworld.com} by Eric Weisstein et. al. |
14738 | 22 |
\item \emph{Algebra I} by van der Waerden, Springer. |
23 |
\end{itemize} |
|
24 |
*} |
|
14504 | 25 |
|
22390 | 26 |
class semiring = ab_semigroup_add + semigroup_mult + |
29667 | 27 |
assumes left_distrib[algebra_simps]: "(a + b) * c = a * c + b * c" |
28 |
assumes right_distrib[algebra_simps]: "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" |
|
29667 | 34 |
by (simp add: left_distrib add_ac) |
25152 | 35 |
|
36 |
end |
|
14504 | 37 |
|
22390 | 38 |
class mult_zero = times + zero + |
25062 | 39 |
assumes mult_zero_left [simp]: "0 * a = 0" |
40 |
assumes mult_zero_right [simp]: "a * 0 = 0" |
|
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
41 |
|
22390 | 42 |
class semiring_0 = semiring + comm_monoid_add + mult_zero |
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
43 |
|
22390 | 44 |
class semiring_0_cancel = semiring + comm_monoid_add + cancel_ab_semigroup_add |
25186 | 45 |
begin |
14504 | 46 |
|
25186 | 47 |
subclass semiring_0 |
28823 | 48 |
proof |
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
49 |
fix a :: 'a |
29667 | 50 |
have "0 * a + 0 * a = 0 * a + 0" by (simp add: left_distrib [symmetric]) |
51 |
thus "0 * a = 0" by (simp only: add_left_cancel) |
|
25152 | 52 |
next |
53 |
fix a :: 'a |
|
29667 | 54 |
have "a * 0 + a * 0 = a * 0 + 0" by (simp add: right_distrib [symmetric]) |
55 |
thus "a * 0 = 0" by (simp only: add_left_cancel) |
|
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
56 |
qed |
14940 | 57 |
|
25186 | 58 |
end |
25152 | 59 |
|
22390 | 60 |
class comm_semiring = ab_semigroup_add + ab_semigroup_mult + |
25062 | 61 |
assumes distrib: "(a + b) * c = a * c + b * c" |
25152 | 62 |
begin |
14504 | 63 |
|
25152 | 64 |
subclass semiring |
28823 | 65 |
proof |
14738 | 66 |
fix a b c :: 'a |
67 |
show "(a + b) * c = a * c + b * c" by (simp add: distrib) |
|
68 |
have "a * (b + c) = (b + c) * a" by (simp add: mult_ac) |
|
69 |
also have "... = b * a + c * a" by (simp only: distrib) |
|
70 |
also have "... = a * b + a * c" by (simp add: mult_ac) |
|
71 |
finally show "a * (b + c) = a * b + a * c" by blast |
|
14504 | 72 |
qed |
73 |
||
25152 | 74 |
end |
14504 | 75 |
|
25152 | 76 |
class comm_semiring_0 = comm_semiring + comm_monoid_add + mult_zero |
77 |
begin |
|
78 |
||
27516 | 79 |
subclass semiring_0 .. |
25152 | 80 |
|
81 |
end |
|
14504 | 82 |
|
22390 | 83 |
class comm_semiring_0_cancel = comm_semiring + comm_monoid_add + cancel_ab_semigroup_add |
25186 | 84 |
begin |
14940 | 85 |
|
27516 | 86 |
subclass semiring_0_cancel .. |
14940 | 87 |
|
28141
193c3ea0f63b
instances comm_semiring_0_cancel < comm_semiring_0, comm_ring < comm_semiring_0_cancel
huffman
parents:
27651
diff
changeset
|
88 |
subclass comm_semiring_0 .. |
193c3ea0f63b
instances comm_semiring_0_cancel < comm_semiring_0, comm_ring < comm_semiring_0_cancel
huffman
parents:
27651
diff
changeset
|
89 |
|
25186 | 90 |
end |
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
91 |
|
22390 | 92 |
class zero_neq_one = zero + one + |
25062 | 93 |
assumes zero_neq_one [simp]: "0 \<noteq> 1" |
26193 | 94 |
begin |
95 |
||
96 |
lemma one_neq_zero [simp]: "1 \<noteq> 0" |
|
29667 | 97 |
by (rule not_sym) (rule zero_neq_one) |
26193 | 98 |
|
99 |
end |
|
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
100 |
|
22390 | 101 |
class semiring_1 = zero_neq_one + semiring_0 + monoid_mult |
14504 | 102 |
|
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
103 |
text {* Abstract divisibility *} |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
104 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
105 |
class dvd = times |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
106 |
begin |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
107 |
|
28559 | 108 |
definition dvd :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "dvd" 50) where |
109 |
[code del]: "b dvd a \<longleftrightarrow> (\<exists>k. a = b * k)" |
|
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
110 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
111 |
lemma dvdI [intro?]: "a = b * k \<Longrightarrow> b dvd a" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
112 |
unfolding dvd_def .. |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
113 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
114 |
lemma dvdE [elim?]: "b dvd a \<Longrightarrow> (\<And>k. a = b * k \<Longrightarrow> P) \<Longrightarrow> P" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
115 |
unfolding dvd_def by blast |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
116 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
117 |
end |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
118 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
119 |
class comm_semiring_1 = zero_neq_one + comm_semiring_0 + comm_monoid_mult + dvd |
22390 | 120 |
(*previously almost_semiring*) |
25152 | 121 |
begin |
14738 | 122 |
|
27516 | 123 |
subclass semiring_1 .. |
25152 | 124 |
|
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
125 |
lemma dvd_refl: "a dvd a" |
28559 | 126 |
proof |
127 |
show "a = a * 1" by simp |
|
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
128 |
qed |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
129 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
130 |
lemma dvd_trans: |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
131 |
assumes "a dvd b" and "b dvd c" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
132 |
shows "a dvd c" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
133 |
proof - |
28559 | 134 |
from assms obtain v where "b = a * v" by (auto elim!: dvdE) |
135 |
moreover from assms obtain w where "c = b * w" by (auto elim!: dvdE) |
|
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
136 |
ultimately have "c = a * (v * w)" by (simp add: mult_assoc) |
28559 | 137 |
then show ?thesis .. |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
138 |
qed |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
139 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
140 |
lemma dvd_0_left_iff [noatp, simp]: "0 dvd a \<longleftrightarrow> a = 0" |
29667 | 141 |
by (auto intro: dvd_refl elim!: dvdE) |
28559 | 142 |
|
143 |
lemma dvd_0_right [iff]: "a dvd 0" |
|
144 |
proof |
|
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
145 |
show "0 = a * 0" by simp |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
146 |
qed |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
147 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
148 |
lemma one_dvd [simp]: "1 dvd a" |
29667 | 149 |
by (auto intro!: dvdI) |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
150 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
151 |
lemma dvd_mult: "a dvd c \<Longrightarrow> a dvd (b * c)" |
29667 | 152 |
by (auto intro!: mult_left_commute dvdI elim!: dvdE) |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
153 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
154 |
lemma dvd_mult2: "a dvd b \<Longrightarrow> a dvd (b * c)" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
155 |
apply (subst mult_commute) |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
156 |
apply (erule dvd_mult) |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
157 |
done |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
158 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
159 |
lemma dvd_triv_right [simp]: "a dvd b * a" |
29667 | 160 |
by (rule dvd_mult) (rule dvd_refl) |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
161 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
162 |
lemma dvd_triv_left [simp]: "a dvd a * b" |
29667 | 163 |
by (rule dvd_mult2) (rule dvd_refl) |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
164 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
165 |
lemma mult_dvd_mono: |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
166 |
assumes ab: "a dvd b" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
167 |
and "cd": "c dvd d" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
168 |
shows "a * c dvd b * d" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
169 |
proof - |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
170 |
from ab obtain b' where "b = a * b'" .. |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
171 |
moreover from "cd" obtain d' where "d = c * d'" .. |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
172 |
ultimately have "b * d = (a * c) * (b' * d')" by (simp add: mult_ac) |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
173 |
then show ?thesis .. |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
174 |
qed |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
175 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
176 |
lemma dvd_mult_left: "a * b dvd c \<Longrightarrow> a dvd c" |
29667 | 177 |
by (simp add: dvd_def mult_assoc, blast) |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
178 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
179 |
lemma dvd_mult_right: "a * b dvd c \<Longrightarrow> b dvd c" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
180 |
unfolding mult_ac [of a] by (rule dvd_mult_left) |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
181 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
182 |
lemma dvd_0_left: "0 dvd a \<Longrightarrow> a = 0" |
29667 | 183 |
by simp |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
184 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
185 |
lemma dvd_add: |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
186 |
assumes ab: "a dvd b" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
187 |
and ac: "a dvd c" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
188 |
shows "a dvd (b + c)" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
189 |
proof - |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
190 |
from ab obtain b' where "b = a * b'" .. |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
191 |
moreover from ac obtain c' where "c = a * c'" .. |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
192 |
ultimately have "b + c = a * (b' + c')" by (simp add: right_distrib) |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
193 |
then show ?thesis .. |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
194 |
qed |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
195 |
|
25152 | 196 |
end |
14421
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14398
diff
changeset
|
197 |
|
22390 | 198 |
class no_zero_divisors = zero + times + |
25062 | 199 |
assumes no_zero_divisors: "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> a * b \<noteq> 0" |
14504 | 200 |
|
22390 | 201 |
class semiring_1_cancel = semiring + comm_monoid_add + zero_neq_one |
202 |
+ cancel_ab_semigroup_add + monoid_mult |
|
25267 | 203 |
begin |
14940 | 204 |
|
27516 | 205 |
subclass semiring_0_cancel .. |
25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset
|
206 |
|
27516 | 207 |
subclass semiring_1 .. |
25267 | 208 |
|
209 |
end |
|
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
210 |
|
22390 | 211 |
class comm_semiring_1_cancel = comm_semiring + comm_monoid_add + comm_monoid_mult |
212 |
+ zero_neq_one + cancel_ab_semigroup_add |
|
25267 | 213 |
begin |
14738 | 214 |
|
27516 | 215 |
subclass semiring_1_cancel .. |
216 |
subclass comm_semiring_0_cancel .. |
|
217 |
subclass comm_semiring_1 .. |
|
25267 | 218 |
|
219 |
end |
|
25152 | 220 |
|
22390 | 221 |
class ring = semiring + ab_group_add |
25267 | 222 |
begin |
25152 | 223 |
|
27516 | 224 |
subclass semiring_0_cancel .. |
25152 | 225 |
|
226 |
text {* Distribution rules *} |
|
227 |
||
228 |
lemma minus_mult_left: "- (a * b) = - a * b" |
|
29667 | 229 |
by (rule equals_zero_I) (simp add: left_distrib [symmetric]) |
25152 | 230 |
|
231 |
lemma minus_mult_right: "- (a * b) = a * - b" |
|
29667 | 232 |
by (rule equals_zero_I) (simp add: right_distrib [symmetric]) |
25152 | 233 |
|
29407
5ef7e97fd9e4
move lemmas mult_minus{left,right} inside class ring
huffman
parents:
29406
diff
changeset
|
234 |
text{*Extract signs from products*} |
5ef7e97fd9e4
move lemmas mult_minus{left,right} inside class ring
huffman
parents:
29406
diff
changeset
|
235 |
lemmas mult_minus_left [simp] = minus_mult_left [symmetric] |
5ef7e97fd9e4
move lemmas mult_minus{left,right} inside class ring
huffman
parents:
29406
diff
changeset
|
236 |
lemmas mult_minus_right [simp] = minus_mult_right [symmetric] |
5ef7e97fd9e4
move lemmas mult_minus{left,right} inside class ring
huffman
parents:
29406
diff
changeset
|
237 |
|
25152 | 238 |
lemma minus_mult_minus [simp]: "- a * - b = a * b" |
29667 | 239 |
by simp |
25152 | 240 |
|
241 |
lemma minus_mult_commute: "- a * b = a * - b" |
|
29667 | 242 |
by simp |
243 |
||
244 |
lemma right_diff_distrib[algebra_simps]: "a * (b - c) = a * b - a * c" |
|
245 |
by (simp add: right_distrib diff_minus) |
|
246 |
||
247 |
lemma left_diff_distrib[algebra_simps]: "(a - b) * c = a * c - b * c" |
|
248 |
by (simp add: left_distrib diff_minus) |
|
25152 | 249 |
|
250 |
lemmas ring_distribs = |
|
251 |
right_distrib left_distrib left_diff_distrib right_diff_distrib |
|
252 |
||
29667 | 253 |
text{*Legacy - use @{text algebra_simps} *} |
254 |
lemmas ring_simps = algebra_simps |
|
25230 | 255 |
|
256 |
lemma eq_add_iff1: |
|
257 |
"a * e + c = b * e + d \<longleftrightarrow> (a - b) * e + c = d" |
|
29667 | 258 |
by (simp add: algebra_simps) |
25230 | 259 |
|
260 |
lemma eq_add_iff2: |
|
261 |
"a * e + c = b * e + d \<longleftrightarrow> c = (b - a) * e + d" |
|
29667 | 262 |
by (simp add: algebra_simps) |
25230 | 263 |
|
25152 | 264 |
end |
265 |
||
266 |
lemmas ring_distribs = |
|
267 |
right_distrib left_distrib left_diff_distrib right_diff_distrib |
|
268 |
||
22390 | 269 |
class comm_ring = comm_semiring + ab_group_add |
25267 | 270 |
begin |
14738 | 271 |
|
27516 | 272 |
subclass ring .. |
28141
193c3ea0f63b
instances comm_semiring_0_cancel < comm_semiring_0, comm_ring < comm_semiring_0_cancel
huffman
parents:
27651
diff
changeset
|
273 |
subclass comm_semiring_0_cancel .. |
25267 | 274 |
|
275 |
end |
|
14738 | 276 |
|
22390 | 277 |
class ring_1 = ring + zero_neq_one + monoid_mult |
25267 | 278 |
begin |
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
279 |
|
27516 | 280 |
subclass semiring_1_cancel .. |
25267 | 281 |
|
282 |
end |
|
25152 | 283 |
|
22390 | 284 |
class comm_ring_1 = comm_ring + zero_neq_one + comm_monoid_mult |
285 |
(*previously ring*) |
|
25267 | 286 |
begin |
14738 | 287 |
|
27516 | 288 |
subclass ring_1 .. |
289 |
subclass comm_semiring_1_cancel .. |
|
25267 | 290 |
|
29465
b2cfb5d0a59e
change dvd_minus_iff, minus_dvd_iff from [iff] to [simp] (due to problems with Library/Primes.thy)
huffman
parents:
29461
diff
changeset
|
291 |
lemma dvd_minus_iff [simp]: "x dvd - y \<longleftrightarrow> x dvd y" |
29408
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
292 |
proof |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
293 |
assume "x dvd - y" |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
294 |
then have "x dvd - 1 * - y" by (rule dvd_mult) |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
295 |
then show "x dvd y" by simp |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
296 |
next |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
297 |
assume "x dvd y" |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
298 |
then have "x dvd - 1 * y" by (rule dvd_mult) |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
299 |
then show "x dvd - y" by simp |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
300 |
qed |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
301 |
|
29465
b2cfb5d0a59e
change dvd_minus_iff, minus_dvd_iff from [iff] to [simp] (due to problems with Library/Primes.thy)
huffman
parents:
29461
diff
changeset
|
302 |
lemma minus_dvd_iff [simp]: "- x dvd y \<longleftrightarrow> x dvd y" |
29408
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
303 |
proof |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
304 |
assume "- x dvd y" |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
305 |
then obtain k where "y = - x * k" .. |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
306 |
then have "y = x * - k" by simp |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
307 |
then show "x dvd y" .. |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
308 |
next |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
309 |
assume "x dvd y" |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
310 |
then obtain k where "y = x * k" .. |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
311 |
then have "y = - x * - k" by simp |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
312 |
then show "- x dvd y" .. |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
313 |
qed |
6d10cf26b5dc
add lemmas dvd_minus_iff and minus_dvd_iff in class comm_ring_1
huffman
parents:
29407
diff
changeset
|
314 |
|
29409 | 315 |
lemma dvd_diff: "x dvd y \<Longrightarrow> x dvd z \<Longrightarrow> x dvd (y - z)" |
29667 | 316 |
by (simp add: diff_minus dvd_add dvd_minus_iff) |
29409 | 317 |
|
25267 | 318 |
end |
25152 | 319 |
|
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
huffman
parents:
22987
diff
changeset
|
320 |
class ring_no_zero_divisors = ring + no_zero_divisors |
25230 | 321 |
begin |
322 |
||
323 |
lemma mult_eq_0_iff [simp]: |
|
324 |
shows "a * b = 0 \<longleftrightarrow> (a = 0 \<or> b = 0)" |
|
325 |
proof (cases "a = 0 \<or> b = 0") |
|
326 |
case False then have "a \<noteq> 0" and "b \<noteq> 0" by auto |
|
327 |
then show ?thesis using no_zero_divisors by simp |
|
328 |
next |
|
329 |
case True then show ?thesis by auto |
|
330 |
qed |
|
331 |
||
26193 | 332 |
text{*Cancellation of equalities with a common factor*} |
333 |
lemma mult_cancel_right [simp, noatp]: |
|
334 |
"a * c = b * c \<longleftrightarrow> c = 0 \<or> a = b" |
|
335 |
proof - |
|
336 |
have "(a * c = b * c) = ((a - b) * c = 0)" |
|
29667 | 337 |
by (simp add: algebra_simps right_minus_eq) |
338 |
thus ?thesis by (simp add: disj_commute right_minus_eq) |
|
26193 | 339 |
qed |
340 |
||
341 |
lemma mult_cancel_left [simp, noatp]: |
|
342 |
"c * a = c * b \<longleftrightarrow> c = 0 \<or> a = b" |
|
343 |
proof - |
|
344 |
have "(c * a = c * b) = (c * (a - b) = 0)" |
|
29667 | 345 |
by (simp add: algebra_simps right_minus_eq) |
346 |
thus ?thesis by (simp add: right_minus_eq) |
|
26193 | 347 |
qed |
348 |
||
25230 | 349 |
end |
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
huffman
parents:
22987
diff
changeset
|
350 |
|
23544 | 351 |
class ring_1_no_zero_divisors = ring_1 + ring_no_zero_divisors |
26274 | 352 |
begin |
353 |
||
354 |
lemma mult_cancel_right1 [simp]: |
|
355 |
"c = b * c \<longleftrightarrow> c = 0 \<or> b = 1" |
|
29667 | 356 |
by (insert mult_cancel_right [of 1 c b], force) |
26274 | 357 |
|
358 |
lemma mult_cancel_right2 [simp]: |
|
359 |
"a * c = c \<longleftrightarrow> c = 0 \<or> a = 1" |
|
29667 | 360 |
by (insert mult_cancel_right [of a c 1], simp) |
26274 | 361 |
|
362 |
lemma mult_cancel_left1 [simp]: |
|
363 |
"c = c * b \<longleftrightarrow> c = 0 \<or> b = 1" |
|
29667 | 364 |
by (insert mult_cancel_left [of c 1 b], force) |
26274 | 365 |
|
366 |
lemma mult_cancel_left2 [simp]: |
|
367 |
"c * a = c \<longleftrightarrow> c = 0 \<or> a = 1" |
|
29667 | 368 |
by (insert mult_cancel_left [of c a 1], simp) |
26274 | 369 |
|
370 |
end |
|
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
huffman
parents:
22987
diff
changeset
|
371 |
|
22390 | 372 |
class idom = comm_ring_1 + no_zero_divisors |
25186 | 373 |
begin |
14421
ee97b6463cb4
new Ring_and_Field hierarchy, eliminating redundant axioms
paulson
parents:
14398
diff
changeset
|
374 |
|
27516 | 375 |
subclass ring_1_no_zero_divisors .. |
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
huffman
parents:
22987
diff
changeset
|
376 |
|
25186 | 377 |
end |
25152 | 378 |
|
22390 | 379 |
class division_ring = ring_1 + inverse + |
25062 | 380 |
assumes left_inverse [simp]: "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1" |
381 |
assumes right_inverse [simp]: "a \<noteq> 0 \<Longrightarrow> a * inverse a = 1" |
|
25186 | 382 |
begin |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
383 |
|
25186 | 384 |
subclass ring_1_no_zero_divisors |
28823 | 385 |
proof |
22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
386 |
fix a b :: 'a |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
387 |
assume a: "a \<noteq> 0" and b: "b \<noteq> 0" |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
388 |
show "a * b \<noteq> 0" |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
389 |
proof |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
390 |
assume ab: "a * b = 0" |
29667 | 391 |
hence "0 = inverse a * (a * b) * inverse b" by simp |
22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
392 |
also have "\<dots> = (inverse a * a) * (b * inverse b)" |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
393 |
by (simp only: mult_assoc) |
29667 | 394 |
also have "\<dots> = 1" using a b by simp |
395 |
finally show False by simp |
|
22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
396 |
qed |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
397 |
qed |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
398 |
|
26274 | 399 |
lemma nonzero_imp_inverse_nonzero: |
400 |
"a \<noteq> 0 \<Longrightarrow> inverse a \<noteq> 0" |
|
401 |
proof |
|
402 |
assume ianz: "inverse a = 0" |
|
403 |
assume "a \<noteq> 0" |
|
404 |
hence "1 = a * inverse a" by simp |
|
405 |
also have "... = 0" by (simp add: ianz) |
|
406 |
finally have "1 = 0" . |
|
407 |
thus False by (simp add: eq_commute) |
|
408 |
qed |
|
409 |
||
410 |
lemma inverse_zero_imp_zero: |
|
411 |
"inverse a = 0 \<Longrightarrow> a = 0" |
|
412 |
apply (rule classical) |
|
413 |
apply (drule nonzero_imp_inverse_nonzero) |
|
414 |
apply auto |
|
415 |
done |
|
416 |
||
417 |
lemma inverse_unique: |
|
418 |
assumes ab: "a * b = 1" |
|
419 |
shows "inverse a = b" |
|
420 |
proof - |
|
421 |
have "a \<noteq> 0" using ab by (cases "a = 0") simp_all |
|
29406 | 422 |
moreover have "inverse a * (a * b) = inverse a" by (simp add: ab) |
423 |
ultimately show ?thesis by (simp add: mult_assoc [symmetric]) |
|
26274 | 424 |
qed |
425 |
||
29406 | 426 |
lemma nonzero_inverse_minus_eq: |
427 |
"a \<noteq> 0 \<Longrightarrow> inverse (- a) = - inverse a" |
|
29667 | 428 |
by (rule inverse_unique) simp |
29406 | 429 |
|
430 |
lemma nonzero_inverse_inverse_eq: |
|
431 |
"a \<noteq> 0 \<Longrightarrow> inverse (inverse a) = a" |
|
29667 | 432 |
by (rule inverse_unique) simp |
29406 | 433 |
|
434 |
lemma nonzero_inverse_eq_imp_eq: |
|
435 |
assumes "inverse a = inverse b" and "a \<noteq> 0" and "b \<noteq> 0" |
|
436 |
shows "a = b" |
|
437 |
proof - |
|
438 |
from `inverse a = inverse b` |
|
29667 | 439 |
have "inverse (inverse a) = inverse (inverse b)" by (rule arg_cong) |
29406 | 440 |
with `a \<noteq> 0` and `b \<noteq> 0` show "a = b" |
441 |
by (simp add: nonzero_inverse_inverse_eq) |
|
442 |
qed |
|
443 |
||
444 |
lemma inverse_1 [simp]: "inverse 1 = 1" |
|
29667 | 445 |
by (rule inverse_unique) simp |
29406 | 446 |
|
26274 | 447 |
lemma nonzero_inverse_mult_distrib: |
29406 | 448 |
assumes "a \<noteq> 0" and "b \<noteq> 0" |
26274 | 449 |
shows "inverse (a * b) = inverse b * inverse a" |
450 |
proof - |
|
29667 | 451 |
have "a * (b * inverse b) * inverse a = 1" using assms by simp |
452 |
hence "a * b * (inverse b * inverse a) = 1" by (simp only: mult_assoc) |
|
453 |
thus ?thesis by (rule inverse_unique) |
|
26274 | 454 |
qed |
455 |
||
456 |
lemma division_ring_inverse_add: |
|
457 |
"a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> inverse a + inverse b = inverse a * (a + b) * inverse b" |
|
29667 | 458 |
by (simp add: algebra_simps) |
26274 | 459 |
|
460 |
lemma division_ring_inverse_diff: |
|
461 |
"a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> inverse a - inverse b = inverse a * (b - a) * inverse b" |
|
29667 | 462 |
by (simp add: algebra_simps) |
26274 | 463 |
|
25186 | 464 |
end |
25152 | 465 |
|
22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
466 |
class field = comm_ring_1 + inverse + |
25062 | 467 |
assumes field_inverse: "a \<noteq> 0 \<Longrightarrow> inverse a * a = 1" |
468 |
assumes divide_inverse: "a / b = a * inverse b" |
|
25267 | 469 |
begin |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
470 |
|
25267 | 471 |
subclass division_ring |
28823 | 472 |
proof |
22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
473 |
fix a :: 'a |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
474 |
assume "a \<noteq> 0" |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
475 |
thus "inverse a * a = 1" by (rule field_inverse) |
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
476 |
thus "a * inverse a = 1" by (simp only: mult_commute) |
14738 | 477 |
qed |
25230 | 478 |
|
27516 | 479 |
subclass idom .. |
25230 | 480 |
|
481 |
lemma right_inverse_eq: "b \<noteq> 0 \<Longrightarrow> a / b = 1 \<longleftrightarrow> a = b" |
|
482 |
proof |
|
483 |
assume neq: "b \<noteq> 0" |
|
484 |
{ |
|
485 |
hence "a = (a / b) * b" by (simp add: divide_inverse mult_ac) |
|
486 |
also assume "a / b = 1" |
|
487 |
finally show "a = b" by simp |
|
488 |
next |
|
489 |
assume "a = b" |
|
490 |
with neq show "a / b = 1" by (simp add: divide_inverse) |
|
491 |
} |
|
492 |
qed |
|
493 |
||
494 |
lemma nonzero_inverse_eq_divide: "a \<noteq> 0 \<Longrightarrow> inverse a = 1 / a" |
|
29667 | 495 |
by (simp add: divide_inverse) |
25230 | 496 |
|
497 |
lemma divide_self [simp]: "a \<noteq> 0 \<Longrightarrow> a / a = 1" |
|
29667 | 498 |
by (simp add: divide_inverse) |
25230 | 499 |
|
500 |
lemma divide_zero_left [simp]: "0 / a = 0" |
|
29667 | 501 |
by (simp add: divide_inverse) |
25230 | 502 |
|
503 |
lemma inverse_eq_divide: "inverse a = 1 / a" |
|
29667 | 504 |
by (simp add: divide_inverse) |
25230 | 505 |
|
506 |
lemma add_divide_distrib: "(a+b) / c = a/c + b/c" |
|
29667 | 507 |
by (simp add: divide_inverse algebra_simps) |
25230 | 508 |
|
509 |
end |
|
510 |
||
22390 | 511 |
class division_by_zero = zero + inverse + |
25062 | 512 |
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
|
513 |
|
25230 | 514 |
lemma divide_zero [simp]: |
515 |
"a / 0 = (0::'a::{field,division_by_zero})" |
|
29667 | 516 |
by (simp add: divide_inverse) |
25230 | 517 |
|
518 |
lemma divide_self_if [simp]: |
|
519 |
"a / (a::'a::{field,division_by_zero}) = (if a=0 then 0 else 1)" |
|
29667 | 520 |
by simp |
25230 | 521 |
|
22390 | 522 |
class mult_mono = times + zero + ord + |
25062 | 523 |
assumes mult_left_mono: "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b" |
524 |
assumes mult_right_mono: "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * c" |
|
14267
b963e9cee2a0
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
paulson
parents:
14266
diff
changeset
|
525 |
|
22390 | 526 |
class pordered_semiring = mult_mono + semiring_0 + pordered_ab_semigroup_add |
25230 | 527 |
begin |
528 |
||
529 |
lemma mult_mono: |
|
530 |
"a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> c |
|
531 |
\<Longrightarrow> a * c \<le> b * d" |
|
532 |
apply (erule mult_right_mono [THEN order_trans], assumption) |
|
533 |
apply (erule mult_left_mono, assumption) |
|
534 |
done |
|
535 |
||
536 |
lemma mult_mono': |
|
537 |
"a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> a \<Longrightarrow> 0 \<le> c |
|
538 |
\<Longrightarrow> a * c \<le> b * d" |
|
539 |
apply (rule mult_mono) |
|
540 |
apply (fast intro: order_trans)+ |
|
541 |
done |
|
542 |
||
543 |
end |
|
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
544 |
|
22390 | 545 |
class pordered_cancel_semiring = mult_mono + pordered_ab_semigroup_add |
22987
550709aa8e66
instance division_ring < no_zero_divisors; clean up field instance proofs
huffman
parents:
22842
diff
changeset
|
546 |
+ semiring + comm_monoid_add + cancel_ab_semigroup_add |
25267 | 547 |
begin |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
548 |
|
27516 | 549 |
subclass semiring_0_cancel .. |
550 |
subclass pordered_semiring .. |
|
23521 | 551 |
|
25230 | 552 |
lemma mult_nonneg_nonneg: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * b" |
29667 | 553 |
by (drule mult_left_mono [of zero b], auto) |
25230 | 554 |
|
555 |
lemma mult_nonneg_nonpos: "0 \<le> a \<Longrightarrow> b \<le> 0 \<Longrightarrow> a * b \<le> 0" |
|
29667 | 556 |
by (drule mult_left_mono [of b zero], auto) |
25230 | 557 |
|
558 |
lemma mult_nonneg_nonpos2: "0 \<le> a \<Longrightarrow> b \<le> 0 \<Longrightarrow> b * a \<le> 0" |
|
29667 | 559 |
by (drule mult_right_mono [of b zero], auto) |
25230 | 560 |
|
26234 | 561 |
lemma split_mult_neg_le: "(0 \<le> a & b \<le> 0) | (a \<le> 0 & 0 \<le> b) \<Longrightarrow> a * b \<le> 0" |
29667 | 562 |
by (auto simp add: mult_nonneg_nonpos mult_nonneg_nonpos2) |
25230 | 563 |
|
564 |
end |
|
565 |
||
566 |
class ordered_semiring = semiring + comm_monoid_add + ordered_cancel_ab_semigroup_add + mult_mono |
|
25267 | 567 |
begin |
25230 | 568 |
|
27516 | 569 |
subclass pordered_cancel_semiring .. |
25512
4134f7c782e2
using intro_locales instead of unfold_locales if appropriate
haftmann
parents:
25450
diff
changeset
|
570 |
|
27516 | 571 |
subclass pordered_comm_monoid_add .. |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
572 |
|
25230 | 573 |
lemma mult_left_less_imp_less: |
574 |
"c * a < c * b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b" |
|
29667 | 575 |
by (force simp add: mult_left_mono not_le [symmetric]) |
25230 | 576 |
|
577 |
lemma mult_right_less_imp_less: |
|
578 |
"a * c < b * c \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b" |
|
29667 | 579 |
by (force simp add: mult_right_mono not_le [symmetric]) |
23521 | 580 |
|
25186 | 581 |
end |
25152 | 582 |
|
22390 | 583 |
class ordered_semiring_strict = semiring + comm_monoid_add + ordered_cancel_ab_semigroup_add + |
25062 | 584 |
assumes mult_strict_left_mono: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c * a < c * b" |
585 |
assumes mult_strict_right_mono: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> a * c < b * c" |
|
25267 | 586 |
begin |
14341
a09441bd4f1e
Ring_and_Field now requires axiom add_left_imp_eq for semirings.
paulson
parents:
14334
diff
changeset
|
587 |
|
27516 | 588 |
subclass semiring_0_cancel .. |
14940 | 589 |
|
25267 | 590 |
subclass ordered_semiring |
28823 | 591 |
proof |
23550 | 592 |
fix a b c :: 'a |
593 |
assume A: "a \<le> b" "0 \<le> c" |
|
594 |
from A show "c * a \<le> c * b" |
|
25186 | 595 |
unfolding le_less |
596 |
using mult_strict_left_mono by (cases "c = 0") auto |
|
23550 | 597 |
from A show "a * c \<le> b * c" |
25152 | 598 |
unfolding le_less |
25186 | 599 |
using mult_strict_right_mono by (cases "c = 0") auto |
25152 | 600 |
qed |
601 |
||
25230 | 602 |
lemma mult_left_le_imp_le: |
603 |
"c * a \<le> c * b \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b" |
|
29667 | 604 |
by (force simp add: mult_strict_left_mono _not_less [symmetric]) |
25230 | 605 |
|
606 |
lemma mult_right_le_imp_le: |
|
607 |
"a * c \<le> b * c \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b" |
|
29667 | 608 |
by (force simp add: mult_strict_right_mono not_less [symmetric]) |
25230 | 609 |
|
610 |
lemma mult_pos_pos: |
|
611 |
"0 < a \<Longrightarrow> 0 < b \<Longrightarrow> 0 < a * b" |
|
29667 | 612 |
by (drule mult_strict_left_mono [of zero b], auto) |
25230 | 613 |
|
614 |
lemma mult_pos_neg: |
|
615 |
"0 < a \<Longrightarrow> b < 0 \<Longrightarrow> a * b < 0" |
|
29667 | 616 |
by (drule mult_strict_left_mono [of b zero], auto) |
25230 | 617 |
|
618 |
lemma mult_pos_neg2: |
|
619 |
"0 < a \<Longrightarrow> b < 0 \<Longrightarrow> b * a < 0" |
|
29667 | 620 |
by (drule mult_strict_right_mono [of b zero], auto) |
25230 | 621 |
|
622 |
lemma zero_less_mult_pos: |
|
623 |
"0 < a * b \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b" |
|
624 |
apply (cases "b\<le>0") |
|
625 |
apply (auto simp add: le_less not_less) |
|
626 |
apply (drule_tac mult_pos_neg [of a b]) |
|
627 |
apply (auto dest: less_not_sym) |
|
628 |
done |
|
629 |
||
630 |
lemma zero_less_mult_pos2: |
|
631 |
"0 < b * a \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b" |
|
632 |
apply (cases "b\<le>0") |
|
633 |
apply (auto simp add: le_less not_less) |
|
634 |
apply (drule_tac mult_pos_neg2 [of a b]) |
|
635 |
apply (auto dest: less_not_sym) |
|
636 |
done |
|
637 |
||
26193 | 638 |
text{*Strict monotonicity in both arguments*} |
639 |
lemma mult_strict_mono: |
|
640 |
assumes "a < b" and "c < d" and "0 < b" and "0 \<le> c" |
|
641 |
shows "a * c < b * d" |
|
642 |
using assms apply (cases "c=0") |
|
643 |
apply (simp add: mult_pos_pos) |
|
644 |
apply (erule mult_strict_right_mono [THEN less_trans]) |
|
645 |
apply (force simp add: le_less) |
|
646 |
apply (erule mult_strict_left_mono, assumption) |
|
647 |
done |
|
648 |
||
649 |
text{*This weaker variant has more natural premises*} |
|
650 |
lemma mult_strict_mono': |
|
651 |
assumes "a < b" and "c < d" and "0 \<le> a" and "0 \<le> c" |
|
652 |
shows "a * c < b * d" |
|
29667 | 653 |
by (rule mult_strict_mono) (insert assms, auto) |
26193 | 654 |
|
655 |
lemma mult_less_le_imp_less: |
|
656 |
assumes "a < b" and "c \<le> d" and "0 \<le> a" and "0 < c" |
|
657 |
shows "a * c < b * d" |
|
658 |
using assms apply (subgoal_tac "a * c < b * c") |
|
659 |
apply (erule less_le_trans) |
|
660 |
apply (erule mult_left_mono) |
|
661 |
apply simp |
|
662 |
apply (erule mult_strict_right_mono) |
|
663 |
apply assumption |
|
664 |
done |
|
665 |
||
666 |
lemma mult_le_less_imp_less: |
|
667 |
assumes "a \<le> b" and "c < d" and "0 < a" and "0 \<le> c" |
|
668 |
shows "a * c < b * d" |
|
669 |
using assms apply (subgoal_tac "a * c \<le> b * c") |
|
670 |
apply (erule le_less_trans) |
|
671 |
apply (erule mult_strict_left_mono) |
|
672 |
apply simp |
|
673 |
apply (erule mult_right_mono) |
|
674 |
apply simp |
|
675 |
done |
|
676 |
||
677 |
lemma mult_less_imp_less_left: |
|
678 |
assumes less: "c * a < c * b" and nonneg: "0 \<le> c" |
|
679 |
shows "a < b" |
|
680 |
proof (rule ccontr) |
|
681 |
assume "\<not> a < b" |
|
682 |
hence "b \<le> a" by (simp add: linorder_not_less) |
|
683 |
hence "c * b \<le> c * a" using nonneg by (rule mult_left_mono) |
|
29667 | 684 |
with this and less show False by (simp add: not_less [symmetric]) |
26193 | 685 |
qed |
686 |
||
687 |
lemma mult_less_imp_less_right: |
|
688 |
assumes less: "a * c < b * c" and nonneg: "0 \<le> c" |
|
689 |
shows "a < b" |
|
690 |
proof (rule ccontr) |
|
691 |
assume "\<not> a < b" |
|
692 |
hence "b \<le> a" by (simp add: linorder_not_less) |
|
693 |
hence "b * c \<le> a * c" using nonneg by (rule mult_right_mono) |
|
29667 | 694 |
with this and less show False by (simp add: not_less [symmetric]) |
26193 | 695 |
qed |
696 |
||
25230 | 697 |
end |
698 |
||
22390 | 699 |
class mult_mono1 = times + zero + ord + |
25230 | 700 |
assumes mult_mono1: "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b" |
14270 | 701 |
|
22390 | 702 |
class pordered_comm_semiring = comm_semiring_0 |
703 |
+ pordered_ab_semigroup_add + mult_mono1 |
|
25186 | 704 |
begin |
25152 | 705 |
|
25267 | 706 |
subclass pordered_semiring |
28823 | 707 |
proof |
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
708 |
fix a b c :: 'a |
23550 | 709 |
assume "a \<le> b" "0 \<le> c" |
25230 | 710 |
thus "c * a \<le> c * b" by (rule mult_mono1) |
23550 | 711 |
thus "a * c \<le> b * c" by (simp only: mult_commute) |
21199
2d83f93c3580
* Added annihilation axioms ("x * 0 = 0") to axclass semiring_0.
krauss
parents:
20633
diff
changeset
|
712 |
qed |
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
713 |
|
25267 | 714 |
end |
715 |
||
716 |
class pordered_cancel_comm_semiring = comm_semiring_0_cancel |
|
717 |
+ pordered_ab_semigroup_add + mult_mono1 |
|
718 |
begin |
|
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
719 |
|
27516 | 720 |
subclass pordered_comm_semiring .. |
721 |
subclass pordered_cancel_semiring .. |
|
25267 | 722 |
|
723 |
end |
|
724 |
||
725 |
class ordered_comm_semiring_strict = comm_semiring_0 + ordered_cancel_ab_semigroup_add + |
|
26193 | 726 |
assumes mult_strict_left_mono_comm: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c * a < c * b" |
25267 | 727 |
begin |
728 |
||
729 |
subclass ordered_semiring_strict |
|
28823 | 730 |
proof |
23550 | 731 |
fix a b c :: 'a |
732 |
assume "a < b" "0 < c" |
|
26193 | 733 |
thus "c * a < c * b" by (rule mult_strict_left_mono_comm) |
23550 | 734 |
thus "a * c < b * c" by (simp only: mult_commute) |
735 |
qed |
|
14272
5efbb548107d
Tidying of the integer development; towards removing the
paulson
parents:
14270
diff
changeset
|
736 |
|
25267 | 737 |
subclass pordered_cancel_comm_semiring |
28823 | 738 |
proof |
23550 | 739 |
fix a b c :: 'a |
740 |
assume "a \<le> b" "0 \<le> c" |
|
741 |
thus "c * a \<le> c * b" |
|
25186 | 742 |
unfolding le_less |
26193 | 743 |
using mult_strict_left_mono by (cases "c = 0") auto |
23550 | 744 |
qed |
14272
5efbb548107d
Tidying of the integer development; towards removing the
paulson
parents:
14270
diff
changeset
|
745 |
|
25267 | 746 |
end |
25230 | 747 |
|
25267 | 748 |
class pordered_ring = ring + pordered_cancel_semiring |
749 |
begin |
|
25230 | 750 |
|
27516 | 751 |
subclass pordered_ab_group_add .. |
14270 | 752 |
|
29667 | 753 |
text{*Legacy - use @{text algebra_simps} *} |
754 |
lemmas ring_simps = algebra_simps |
|
25230 | 755 |
|
756 |
lemma less_add_iff1: |
|
757 |
"a * e + c < b * e + d \<longleftrightarrow> (a - b) * e + c < d" |
|
29667 | 758 |
by (simp add: algebra_simps) |
25230 | 759 |
|
760 |
lemma less_add_iff2: |
|
761 |
"a * e + c < b * e + d \<longleftrightarrow> c < (b - a) * e + d" |
|
29667 | 762 |
by (simp add: algebra_simps) |
25230 | 763 |
|
764 |
lemma le_add_iff1: |
|
765 |
"a * e + c \<le> b * e + d \<longleftrightarrow> (a - b) * e + c \<le> d" |
|
29667 | 766 |
by (simp add: algebra_simps) |
25230 | 767 |
|
768 |
lemma le_add_iff2: |
|
769 |
"a * e + c \<le> b * e + d \<longleftrightarrow> c \<le> (b - a) * e + d" |
|
29667 | 770 |
by (simp add: algebra_simps) |
25230 | 771 |
|
772 |
lemma mult_left_mono_neg: |
|
773 |
"b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> c * a \<le> c * b" |
|
774 |
apply (drule mult_left_mono [of _ _ "uminus c"]) |
|
775 |
apply (simp_all add: minus_mult_left [symmetric]) |
|
776 |
done |
|
777 |
||
778 |
lemma mult_right_mono_neg: |
|
779 |
"b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> a * c \<le> b * c" |
|
780 |
apply (drule mult_right_mono [of _ _ "uminus c"]) |
|
781 |
apply (simp_all add: minus_mult_right [symmetric]) |
|
782 |
done |
|
783 |
||
784 |
lemma mult_nonpos_nonpos: |
|
785 |
"a \<le> 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> 0 \<le> a * b" |
|
29667 | 786 |
by (drule mult_right_mono_neg [of a zero b]) auto |
25230 | 787 |
|
788 |
lemma split_mult_pos_le: |
|
789 |
"(0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0) \<Longrightarrow> 0 \<le> a * b" |
|
29667 | 790 |
by (auto simp add: mult_nonneg_nonneg mult_nonpos_nonpos) |
25186 | 791 |
|
792 |
end |
|
14270 | 793 |
|
25762 | 794 |
class abs_if = minus + uminus + ord + zero + abs + |
795 |
assumes abs_if: "\<bar>a\<bar> = (if a < 0 then - a else a)" |
|
796 |
||
797 |
class sgn_if = minus + uminus + zero + one + ord + sgn + |
|
25186 | 798 |
assumes sgn_if: "sgn x = (if x = 0 then 0 else if 0 < x then 1 else - 1)" |
24506 | 799 |
|
25564 | 800 |
lemma (in sgn_if) sgn0[simp]: "sgn 0 = 0" |
801 |
by(simp add:sgn_if) |
|
802 |
||
25230 | 803 |
class ordered_ring = ring + ordered_semiring |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
804 |
+ ordered_ab_group_add + abs_if |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
805 |
begin |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
806 |
|
27516 | 807 |
subclass pordered_ring .. |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
808 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
809 |
subclass pordered_ab_group_add_abs |
28823 | 810 |
proof |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
811 |
fix a b |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
812 |
show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" |
29667 | 813 |
by (auto simp add: abs_if not_less neg_less_eq_nonneg less_eq_neg_nonpos) |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
814 |
(auto simp del: minus_add_distrib simp add: minus_add_distrib [symmetric] |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
815 |
neg_less_eq_nonneg less_eq_neg_nonpos, auto intro: add_nonneg_nonneg, |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
816 |
auto intro!: less_imp_le add_neg_neg) |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
817 |
qed (auto simp add: abs_if less_eq_neg_nonpos neg_equal_zero) |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
818 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
819 |
end |
23521 | 820 |
|
25230 | 821 |
(* The "strict" suffix can be seen as describing the combination of ordered_ring and no_zero_divisors. |
822 |
Basically, ordered_ring + no_zero_divisors = ordered_ring_strict. |
|
823 |
*) |
|
824 |
class ordered_ring_strict = ring + ordered_semiring_strict |
|
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
825 |
+ ordered_ab_group_add + abs_if |
25230 | 826 |
begin |
14348
744c868ee0b7
Defining the type class "ringpower" and deleting superseded theorems for
paulson
parents:
14341
diff
changeset
|
827 |
|
27516 | 828 |
subclass ordered_ring .. |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
829 |
|
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
830 |
lemma mult_strict_left_mono_neg: |
25230 | 831 |
"b < a \<Longrightarrow> c < 0 \<Longrightarrow> c * a < c * b" |
832 |
apply (drule mult_strict_left_mono [of _ _ "uminus c"]) |
|
833 |
apply (simp_all add: minus_mult_left [symmetric]) |
|
834 |
done |
|
14738 | 835 |
|
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
836 |
lemma mult_strict_right_mono_neg: |
25230 | 837 |
"b < a \<Longrightarrow> c < 0 \<Longrightarrow> a * c < b * c" |
838 |
apply (drule mult_strict_right_mono [of _ _ "uminus c"]) |
|
839 |
apply (simp_all add: minus_mult_right [symmetric]) |
|
840 |
done |
|
14738 | 841 |
|
25230 | 842 |
lemma mult_neg_neg: |
843 |
"a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> 0 < a * b" |
|
29667 | 844 |
by (drule mult_strict_right_mono_neg, auto) |
14738 | 845 |
|
25917 | 846 |
subclass ring_no_zero_divisors |
28823 | 847 |
proof |
25917 | 848 |
fix a b |
849 |
assume "a \<noteq> 0" then have A: "a < 0 \<or> 0 < a" by (simp add: neq_iff) |
|
850 |
assume "b \<noteq> 0" then have B: "b < 0 \<or> 0 < b" by (simp add: neq_iff) |
|
851 |
have "a * b < 0 \<or> 0 < a * b" |
|
852 |
proof (cases "a < 0") |
|
853 |
case True note A' = this |
|
854 |
show ?thesis proof (cases "b < 0") |
|
855 |
case True with A' |
|
856 |
show ?thesis by (auto dest: mult_neg_neg) |
|
857 |
next |
|
858 |
case False with B have "0 < b" by auto |
|
859 |
with A' show ?thesis by (auto dest: mult_strict_right_mono) |
|
860 |
qed |
|
861 |
next |
|
862 |
case False with A have A': "0 < a" by auto |
|
863 |
show ?thesis proof (cases "b < 0") |
|
864 |
case True with A' |
|
865 |
show ?thesis by (auto dest: mult_strict_right_mono_neg) |
|
866 |
next |
|
867 |
case False with B have "0 < b" by auto |
|
868 |
with A' show ?thesis by (auto dest: mult_pos_pos) |
|
869 |
qed |
|
870 |
qed |
|
871 |
then show "a * b \<noteq> 0" by (simp add: neq_iff) |
|
872 |
qed |
|
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
873 |
|
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
874 |
lemma zero_less_mult_iff: |
25917 | 875 |
"0 < a * b \<longleftrightarrow> 0 < a \<and> 0 < b \<or> a < 0 \<and> b < 0" |
876 |
apply (auto simp add: mult_pos_pos mult_neg_neg) |
|
877 |
apply (simp_all add: not_less le_less) |
|
878 |
apply (erule disjE) apply assumption defer |
|
879 |
apply (erule disjE) defer apply (drule sym) apply simp |
|
880 |
apply (erule disjE) defer apply (drule sym) apply simp |
|
881 |
apply (erule disjE) apply assumption apply (drule sym) apply simp |
|
882 |
apply (drule sym) apply simp |
|
883 |
apply (blast dest: zero_less_mult_pos) |
|
25230 | 884 |
apply (blast dest: zero_less_mult_pos2) |
885 |
done |
|
22990
775e9de3db48
added classes ring_no_zero_divisors and dom (non-commutative version of idom);
huffman
parents:
22987
diff
changeset
|
886 |
|
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
887 |
lemma zero_le_mult_iff: |
25917 | 888 |
"0 \<le> a * b \<longleftrightarrow> 0 \<le> a \<and> 0 \<le> b \<or> a \<le> 0 \<and> b \<le> 0" |
29667 | 889 |
by (auto simp add: eq_commute [of 0] le_less not_less zero_less_mult_iff) |
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
890 |
|
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
891 |
lemma mult_less_0_iff: |
25917 | 892 |
"a * b < 0 \<longleftrightarrow> 0 < a \<and> b < 0 \<or> a < 0 \<and> 0 < b" |
893 |
apply (insert zero_less_mult_iff [of "-a" b]) |
|
894 |
apply (force simp add: minus_mult_left[symmetric]) |
|
895 |
done |
|
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
896 |
|
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
897 |
lemma mult_le_0_iff: |
25917 | 898 |
"a * b \<le> 0 \<longleftrightarrow> 0 \<le> a \<and> b \<le> 0 \<or> a \<le> 0 \<and> 0 \<le> b" |
899 |
apply (insert zero_le_mult_iff [of "-a" b]) |
|
900 |
apply (force simp add: minus_mult_left[symmetric]) |
|
901 |
done |
|
902 |
||
903 |
lemma zero_le_square [simp]: "0 \<le> a * a" |
|
29667 | 904 |
by (simp add: zero_le_mult_iff linear) |
25917 | 905 |
|
906 |
lemma not_square_less_zero [simp]: "\<not> (a * a < 0)" |
|
29667 | 907 |
by (simp add: not_less) |
25917 | 908 |
|
26193 | 909 |
text{*Cancellation laws for @{term "c*a < c*b"} and @{term "a*c < b*c"}, |
910 |
also with the relations @{text "\<le>"} and equality.*} |
|
911 |
||
912 |
text{*These ``disjunction'' versions produce two cases when the comparison is |
|
913 |
an assumption, but effectively four when the comparison is a goal.*} |
|
914 |
||
915 |
lemma mult_less_cancel_right_disj: |
|
916 |
"a * c < b * c \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and> b < a" |
|
917 |
apply (cases "c = 0") |
|
918 |
apply (auto simp add: neq_iff mult_strict_right_mono |
|
919 |
mult_strict_right_mono_neg) |
|
920 |
apply (auto simp add: not_less |
|
921 |
not_le [symmetric, of "a*c"] |
|
922 |
not_le [symmetric, of a]) |
|
923 |
apply (erule_tac [!] notE) |
|
924 |
apply (auto simp add: less_imp_le mult_right_mono |
|
925 |
mult_right_mono_neg) |
|
926 |
done |
|
927 |
||
928 |
lemma mult_less_cancel_left_disj: |
|
929 |
"c * a < c * b \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and> b < a" |
|
930 |
apply (cases "c = 0") |
|
931 |
apply (auto simp add: neq_iff mult_strict_left_mono |
|
932 |
mult_strict_left_mono_neg) |
|
933 |
apply (auto simp add: not_less |
|
934 |
not_le [symmetric, of "c*a"] |
|
935 |
not_le [symmetric, of a]) |
|
936 |
apply (erule_tac [!] notE) |
|
937 |
apply (auto simp add: less_imp_le mult_left_mono |
|
938 |
mult_left_mono_neg) |
|
939 |
done |
|
940 |
||
941 |
text{*The ``conjunction of implication'' lemmas produce two cases when the |
|
942 |
comparison is a goal, but give four when the comparison is an assumption.*} |
|
943 |
||
944 |
lemma mult_less_cancel_right: |
|
945 |
"a * c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)" |
|
946 |
using mult_less_cancel_right_disj [of a c b] by auto |
|
947 |
||
948 |
lemma mult_less_cancel_left: |
|
949 |
"c * a < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)" |
|
950 |
using mult_less_cancel_left_disj [of c a b] by auto |
|
951 |
||
952 |
lemma mult_le_cancel_right: |
|
953 |
"a * c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)" |
|
29667 | 954 |
by (simp add: not_less [symmetric] mult_less_cancel_right_disj) |
26193 | 955 |
|
956 |
lemma mult_le_cancel_left: |
|
957 |
"c * a \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)" |
|
29667 | 958 |
by (simp add: not_less [symmetric] mult_less_cancel_left_disj) |
26193 | 959 |
|
25917 | 960 |
end |
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
961 |
|
29667 | 962 |
text{*Legacy - use @{text algebra_simps} *} |
963 |
lemmas ring_simps = algebra_simps |
|
25230 | 964 |
|
965 |
||
966 |
class pordered_comm_ring = comm_ring + pordered_comm_semiring |
|
25267 | 967 |
begin |
25230 | 968 |
|
27516 | 969 |
subclass pordered_ring .. |
970 |
subclass pordered_cancel_comm_semiring .. |
|
25230 | 971 |
|
25267 | 972 |
end |
25230 | 973 |
|
974 |
class ordered_semidom = comm_semiring_1_cancel + ordered_comm_semiring_strict + |
|
975 |
(*previously ordered_semiring*) |
|
976 |
assumes zero_less_one [simp]: "0 < 1" |
|
977 |
begin |
|
978 |
||
979 |
lemma pos_add_strict: |
|
980 |
shows "0 < a \<Longrightarrow> b < c \<Longrightarrow> b < a + c" |
|
981 |
using add_strict_mono [of zero a b c] by simp |
|
982 |
||
26193 | 983 |
lemma zero_le_one [simp]: "0 \<le> 1" |
29667 | 984 |
by (rule zero_less_one [THEN less_imp_le]) |
26193 | 985 |
|
986 |
lemma not_one_le_zero [simp]: "\<not> 1 \<le> 0" |
|
29667 | 987 |
by (simp add: not_le) |
26193 | 988 |
|
989 |
lemma not_one_less_zero [simp]: "\<not> 1 < 0" |
|
29667 | 990 |
by (simp add: not_less) |
26193 | 991 |
|
992 |
lemma less_1_mult: |
|
993 |
assumes "1 < m" and "1 < n" |
|
994 |
shows "1 < m * n" |
|
995 |
using assms mult_strict_mono [of 1 m 1 n] |
|
996 |
by (simp add: less_trans [OF zero_less_one]) |
|
997 |
||
25230 | 998 |
end |
999 |
||
26193 | 1000 |
class ordered_idom = comm_ring_1 + |
1001 |
ordered_comm_semiring_strict + ordered_ab_group_add + |
|
25230 | 1002 |
abs_if + sgn_if |
1003 |
(*previously ordered_ring*) |
|
25917 | 1004 |
begin |
1005 |
||
27516 | 1006 |
subclass ordered_ring_strict .. |
1007 |
subclass pordered_comm_ring .. |
|
1008 |
subclass idom .. |
|
25917 | 1009 |
|
1010 |
subclass ordered_semidom |
|
28823 | 1011 |
proof |
26193 | 1012 |
have "0 \<le> 1 * 1" by (rule zero_le_square) |
1013 |
thus "0 < 1" by (simp add: le_less) |
|
25917 | 1014 |
qed |
1015 |
||
26193 | 1016 |
lemma linorder_neqE_ordered_idom: |
1017 |
assumes "x \<noteq> y" obtains "x < y" | "y < x" |
|
1018 |
using assms by (rule neqE) |
|
1019 |
||
26274 | 1020 |
text {* These cancellation simprules also produce two cases when the comparison is a goal. *} |
1021 |
||
1022 |
lemma mult_le_cancel_right1: |
|
1023 |
"c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)" |
|
29667 | 1024 |
by (insert mult_le_cancel_right [of 1 c b], simp) |
26274 | 1025 |
|
1026 |
lemma mult_le_cancel_right2: |
|
1027 |
"a * c \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)" |
|
29667 | 1028 |
by (insert mult_le_cancel_right [of a c 1], simp) |
26274 | 1029 |
|
1030 |
lemma mult_le_cancel_left1: |
|
1031 |
"c \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)" |
|
29667 | 1032 |
by (insert mult_le_cancel_left [of c 1 b], simp) |
26274 | 1033 |
|
1034 |
lemma mult_le_cancel_left2: |
|
1035 |
"c * a \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)" |
|
29667 | 1036 |
by (insert mult_le_cancel_left [of c a 1], simp) |
26274 | 1037 |
|
1038 |
lemma mult_less_cancel_right1: |
|
1039 |
"c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)" |
|
29667 | 1040 |
by (insert mult_less_cancel_right [of 1 c b], simp) |
26274 | 1041 |
|
1042 |
lemma mult_less_cancel_right2: |
|
1043 |
"a * c < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)" |
|
29667 | 1044 |
by (insert mult_less_cancel_right [of a c 1], simp) |
26274 | 1045 |
|
1046 |
lemma mult_less_cancel_left1: |
|
1047 |
"c < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)" |
|
29667 | 1048 |
by (insert mult_less_cancel_left [of c 1 b], simp) |
26274 | 1049 |
|
1050 |
lemma mult_less_cancel_left2: |
|
1051 |
"c * a < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)" |
|
29667 | 1052 |
by (insert mult_less_cancel_left [of c a 1], simp) |
26274 | 1053 |
|
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1054 |
lemma sgn_sgn [simp]: |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1055 |
"sgn (sgn a) = sgn a" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1056 |
unfolding sgn_if by simp |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1057 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1058 |
lemma sgn_0_0: |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1059 |
"sgn a = 0 \<longleftrightarrow> a = 0" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1060 |
unfolding sgn_if by simp |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1061 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1062 |
lemma sgn_1_pos: |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1063 |
"sgn a = 1 \<longleftrightarrow> a > 0" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1064 |
unfolding sgn_if by (simp add: neg_equal_zero) |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1065 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1066 |
lemma sgn_1_neg: |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1067 |
"sgn a = - 1 \<longleftrightarrow> a < 0" |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1068 |
unfolding sgn_if by (auto simp add: equal_neg_zero) |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1069 |
|
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1070 |
lemma sgn_times: |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1071 |
"sgn (a * b) = sgn a * sgn b" |
29667 | 1072 |
by (auto simp add: sgn_if zero_less_mult_iff) |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27516
diff
changeset
|
1073 |
|
29653 | 1074 |
lemma abs_sgn: "abs k = k * sgn k" |
1075 |
unfolding sgn_if abs_if by auto |
|
1076 |
||
25917 | 1077 |
end |
25230 | 1078 |
|
1079 |
class ordered_field = field + ordered_idom |
|
1080 |
||
26274 | 1081 |
text {* Simprules for comparisons where common factors can be cancelled. *} |
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1082 |
|
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1083 |
lemmas mult_compare_simps = |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1084 |
mult_le_cancel_right mult_le_cancel_left |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1085 |
mult_le_cancel_right1 mult_le_cancel_right2 |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1086 |
mult_le_cancel_left1 mult_le_cancel_left2 |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1087 |
mult_less_cancel_right mult_less_cancel_left |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1088 |
mult_less_cancel_right1 mult_less_cancel_right2 |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1089 |
mult_less_cancel_left1 mult_less_cancel_left2 |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1090 |
mult_cancel_right mult_cancel_left |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1091 |
mult_cancel_right1 mult_cancel_right2 |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1092 |
mult_cancel_left1 mult_cancel_left2 |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1093 |
|
26274 | 1094 |
-- {* FIXME continue localization here *} |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1095 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1096 |
lemma inverse_nonzero_iff_nonzero [simp]: |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
1097 |
"(inverse a = 0) = (a = (0::'a::{division_ring,division_by_zero}))" |
26274 | 1098 |
by (force dest: inverse_zero_imp_zero) |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1099 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1100 |
lemma inverse_minus_eq [simp]: |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
1101 |
"inverse(-a) = -inverse(a::'a::{division_ring,division_by_zero})" |
14377 | 1102 |
proof cases |
1103 |
assume "a=0" thus ?thesis by (simp add: inverse_zero) |
|
1104 |
next |
|
1105 |
assume "a\<noteq>0" |
|
1106 |
thus ?thesis by (simp add: nonzero_inverse_minus_eq) |
|
1107 |
qed |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1108 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1109 |
lemma inverse_eq_imp_eq: |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
1110 |
"inverse a = inverse b ==> a = (b::'a::{division_ring,division_by_zero})" |
21328 | 1111 |
apply (cases "a=0 | b=0") |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1112 |
apply (force dest!: inverse_zero_imp_zero |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1113 |
simp add: eq_commute [of "0::'a"]) |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1114 |
apply (force dest!: nonzero_inverse_eq_imp_eq) |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1115 |
done |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1116 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1117 |
lemma inverse_eq_iff_eq [simp]: |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
1118 |
"(inverse a = inverse b) = (a = (b::'a::{division_ring,division_by_zero}))" |
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
1119 |
by (force dest!: inverse_eq_imp_eq) |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1120 |
|
14270 | 1121 |
lemma inverse_inverse_eq [simp]: |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
1122 |
"inverse(inverse (a::'a::{division_ring,division_by_zero})) = a" |
14270 | 1123 |
proof cases |
1124 |
assume "a=0" thus ?thesis by simp |
|
1125 |
next |
|
1126 |
assume "a\<noteq>0" |
|
1127 |
thus ?thesis by (simp add: nonzero_inverse_inverse_eq) |
|
1128 |
qed |
|
1129 |
||
1130 |
text{*This version builds in division by zero while also re-orienting |
|
1131 |
the right-hand side.*} |
|
1132 |
lemma inverse_mult_distrib [simp]: |
|
1133 |
"inverse(a*b) = inverse(a) * inverse(b::'a::{field,division_by_zero})" |
|
1134 |
proof cases |
|
1135 |
assume "a \<noteq> 0 & b \<noteq> 0" |
|
29667 | 1136 |
thus ?thesis by (simp add: nonzero_inverse_mult_distrib mult_commute) |
14270 | 1137 |
next |
1138 |
assume "~ (a \<noteq> 0 & b \<noteq> 0)" |
|
29667 | 1139 |
thus ?thesis by force |
14270 | 1140 |
qed |
1141 |
||
1142 |
text{*There is no slick version using division by zero.*} |
|
1143 |
lemma inverse_add: |
|
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1144 |
"[|a \<noteq> 0; b \<noteq> 0|] |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1145 |
==> inverse a + inverse b = (a+b) * inverse a * inverse (b::'a::field)" |
20496
23eb6034c06d
added axclass division_ring (like field without commutativity; includes e.g. quaternions) and generalized some theorems from field to division_ring
huffman
parents:
19404
diff
changeset
|
1146 |
by (simp add: division_ring_inverse_add mult_ac) |
14270 | 1147 |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1148 |
lemma inverse_divide [simp]: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1149 |
"inverse (a/b) = b / (a::'a::{field,division_by_zero})" |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1150 |
by (simp add: divide_inverse mult_commute) |
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1151 |
|
23389 | 1152 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1153 |
subsection {* Calculations with fractions *} |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1154 |
|
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1155 |
text{* There is a whole bunch of simp-rules just for class @{text |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1156 |
field} but none for class @{text field} and @{text nonzero_divides} |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1157 |
because the latter are covered by a simproc. *} |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1158 |
|
24427 | 1159 |
lemma nonzero_mult_divide_mult_cancel_left[simp,noatp]: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1160 |
assumes [simp]: "b\<noteq>0" and [simp]: "c\<noteq>0" shows "(c*a)/(c*b) = a/(b::'a::field)" |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1161 |
proof - |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1162 |
have "(c*a)/(c*b) = c * a * (inverse b * inverse c)" |
23482 | 1163 |
by (simp add: divide_inverse nonzero_inverse_mult_distrib) |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1164 |
also have "... = a * inverse b * (inverse c * c)" |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1165 |
by (simp only: mult_ac) |
29667 | 1166 |
also have "... = a * inverse b" by simp |
1167 |
finally show ?thesis by (simp add: divide_inverse) |
|
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1168 |
qed |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1169 |
|
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1170 |
lemma mult_divide_mult_cancel_left: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1171 |
"c\<noteq>0 ==> (c*a) / (c*b) = a / (b::'a::{field,division_by_zero})" |
21328 | 1172 |
apply (cases "b = 0") |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1173 |
apply (simp_all add: nonzero_mult_divide_mult_cancel_left) |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1174 |
done |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1175 |
|
24427 | 1176 |
lemma nonzero_mult_divide_mult_cancel_right [noatp]: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1177 |
"[|b\<noteq>0; c\<noteq>0|] ==> (a*c) / (b*c) = a/(b::'a::field)" |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1178 |
by (simp add: mult_commute [of _ c] nonzero_mult_divide_mult_cancel_left) |
14321 | 1179 |
|
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1180 |
lemma mult_divide_mult_cancel_right: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1181 |
"c\<noteq>0 ==> (a*c) / (b*c) = a / (b::'a::{field,division_by_zero})" |
21328 | 1182 |
apply (cases "b = 0") |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1183 |
apply (simp_all add: nonzero_mult_divide_mult_cancel_right) |
14321 | 1184 |
done |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1185 |
|
14284
f1abe67c448a
re-organisation of Real/RealArith0.ML; more `Isar scripts
paulson
parents:
14277
diff
changeset
|
1186 |
lemma divide_1 [simp]: "a/1 = (a::'a::field)" |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1187 |
by (simp add: divide_inverse) |
14284
f1abe67c448a
re-organisation of Real/RealArith0.ML; more `Isar scripts
paulson
parents:
14277
diff
changeset
|
1188 |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1189 |
lemma times_divide_eq_right: "a * (b/c) = (a*b) / (c::'a::field)" |
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
1190 |
by (simp add: divide_inverse mult_assoc) |
14288 | 1191 |
|
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
1192 |
lemma times_divide_eq_left: "(b/c) * a = (b*a) / (c::'a::field)" |
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
1193 |
by (simp add: divide_inverse mult_ac) |
14288 | 1194 |
|
23482 | 1195 |
lemmas times_divide_eq = times_divide_eq_right times_divide_eq_left |
1196 |
||
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1197 |
lemma divide_divide_eq_right [simp,noatp]: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1198 |
"a / (b/c) = (a*c) / (b::'a::{field,division_by_zero})" |
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
1199 |
by (simp add: divide_inverse mult_ac) |
14288 | 1200 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1201 |
lemma divide_divide_eq_left [simp,noatp]: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1202 |
"(a / b) / (c::'a::{field,division_by_zero}) = a / (b*c)" |
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
1203 |
by (simp add: divide_inverse mult_assoc) |
14288 | 1204 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1205 |
lemma add_frac_eq: "(y::'a::field) ~= 0 ==> z ~= 0 ==> |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1206 |
x / y + w / z = (x * z + w * y) / (y * z)" |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1207 |
apply (subgoal_tac "x / y = (x * z) / (y * z)") |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1208 |
apply (erule ssubst) |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1209 |
apply (subgoal_tac "w / z = (w * y) / (y * z)") |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1210 |
apply (erule ssubst) |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1211 |
apply (rule add_divide_distrib [THEN sym]) |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1212 |
apply (subst mult_commute) |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1213 |
apply (erule nonzero_mult_divide_mult_cancel_left [THEN sym]) |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1214 |
apply assumption |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1215 |
apply (erule nonzero_mult_divide_mult_cancel_right [THEN sym]) |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1216 |
apply assumption |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1217 |
done |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1218 |
|
23389 | 1219 |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1220 |
subsubsection{*Special Cancellation Simprules for Division*} |
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1221 |
|
24427 | 1222 |
lemma mult_divide_mult_cancel_left_if[simp,noatp]: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1223 |
fixes c :: "'a :: {field,division_by_zero}" |
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1224 |
shows "(c*a) / (c*b) = (if c=0 then 0 else a/b)" |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1225 |
by (simp add: mult_divide_mult_cancel_left) |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1226 |
|
24427 | 1227 |
lemma nonzero_mult_divide_cancel_right[simp,noatp]: |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1228 |
"b \<noteq> 0 \<Longrightarrow> a * b / b = (a::'a::field)" |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1229 |
using nonzero_mult_divide_mult_cancel_right[of 1 b a] by simp |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1230 |
|
24427 | 1231 |
lemma nonzero_mult_divide_cancel_left[simp,noatp]: |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1232 |
"a \<noteq> 0 \<Longrightarrow> a * b / a = (b::'a::field)" |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1233 |
using nonzero_mult_divide_mult_cancel_left[of 1 a b] by simp |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1234 |
|
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1235 |
|
24427 | 1236 |
lemma nonzero_divide_mult_cancel_right[simp,noatp]: |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1237 |
"\<lbrakk> a\<noteq>0; b\<noteq>0 \<rbrakk> \<Longrightarrow> b / (a * b) = 1/(a::'a::field)" |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1238 |
using nonzero_mult_divide_mult_cancel_right[of a b 1] by simp |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1239 |
|
24427 | 1240 |
lemma nonzero_divide_mult_cancel_left[simp,noatp]: |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1241 |
"\<lbrakk> a\<noteq>0; b\<noteq>0 \<rbrakk> \<Longrightarrow> a / (a * b) = 1/(b::'a::field)" |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1242 |
using nonzero_mult_divide_mult_cancel_left[of b a 1] by simp |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1243 |
|
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1244 |
|
24427 | 1245 |
lemma nonzero_mult_divide_mult_cancel_left2[simp,noatp]: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1246 |
"[|b\<noteq>0; c\<noteq>0|] ==> (c*a) / (b*c) = a/(b::'a::field)" |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1247 |
using nonzero_mult_divide_mult_cancel_left[of b c a] by(simp add:mult_ac) |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1248 |
|
24427 | 1249 |
lemma nonzero_mult_divide_mult_cancel_right2[simp,noatp]: |
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1250 |
"[|b\<noteq>0; c\<noteq>0|] ==> (a*c) / (c*b) = a/(b::'a::field)" |
23413
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1251 |
using nonzero_mult_divide_mult_cancel_right[of b c a] by(simp add:mult_ac) |
5caa2710dd5b
tuned laws for cancellation in divisions for fields.
nipkow
parents:
23406
diff
changeset
|
1252 |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1253 |
|
14293 | 1254 |
subsection {* Division and Unary Minus *} |
1255 |
||
1256 |
lemma nonzero_minus_divide_left: "b \<noteq> 0 ==> - (a/b) = (-a) / (b::'a::field)" |
|
29407
5ef7e97fd9e4
move lemmas mult_minus{left,right} inside class ring
huffman
parents:
29406
diff
changeset
|
1257 |
by (simp add: divide_inverse) |
14293 | 1258 |
|
1259 |
lemma nonzero_minus_divide_right: "b \<noteq> 0 ==> - (a/b) = a / -(b::'a::field)" |
|
29407
5ef7e97fd9e4
move lemmas mult_minus{left,right} inside class ring
huffman
parents:
29406
diff
changeset
|
1260 |
by (simp add: divide_inverse nonzero_inverse_minus_eq) |
14293 | 1261 |
|
1262 |
lemma nonzero_minus_divide_divide: "b \<noteq> 0 ==> (-a)/(-b) = a / (b::'a::field)" |
|
1263 |
by (simp add: divide_inverse nonzero_inverse_minus_eq) |
|
1264 |
||
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
1265 |
lemma minus_divide_left: "- (a/b) = (-a) / (b::'a::field)" |
29407
5ef7e97fd9e4
move lemmas mult_minus{left,right} inside class ring
huffman
parents:
29406
diff
changeset
|
1266 |
by (simp add: divide_inverse) |
14293 | 1267 |
|
1268 |
lemma minus_divide_right: "- (a/b) = a / -(b::'a::{field,division_by_zero})" |
|
29407
5ef7e97fd9e4
move lemmas mult_minus{left,right} inside class ring
huffman
parents:
29406
diff
changeset
|
1269 |
by (simp add: divide_inverse) |
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
1270 |
|
14293 | 1271 |
|
1272 |
text{*The effect is to extract signs from divisions*} |
|
17085 | 1273 |
lemmas divide_minus_left = minus_divide_left [symmetric] |
1274 |
lemmas divide_minus_right = minus_divide_right [symmetric] |
|
1275 |
declare divide_minus_left [simp] divide_minus_right [simp] |
|
14293 | 1276 |
|
1277 |
lemma minus_divide_divide [simp]: |
|
23477
f4b83f03cac9
tuned and renamed group_eq_simps and ring_eq_simps
nipkow
parents:
23413
diff
changeset
|
1278 |
"(-a)/(-b) = a / (b::'a::{field,division_by_zero})" |
21328 | 1279 |
apply (cases "b=0", simp) |
14293 | 1280 |
apply (simp add: nonzero_minus_divide_divide) |
1281 |
done |
|
1282 |
||
14430
5cb24165a2e1
new material from Avigad, and simplified treatment of division by 0
paulson
parents:
14421
diff
changeset
|
1283 |
lemma diff_divide_distrib: "(a-b)/(c::'a::field) = a/c - b/c" |
14387
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
1284 |
by (simp add: diff_minus add_divide_distrib) |
e96d5c42c4b0
Polymorphic treatment of binary arithmetic using axclasses
paulson
parents:
14377
diff
changeset
|
1285 |
|
23482 | 1286 |
lemma add_divide_eq_iff: |
1287 |
"(z::'a::field) \<noteq> 0 \<Longrightarrow> x + y/z = (z*x + y)/z" |
|
1288 |
by(simp add:add_divide_distrib nonzero_mult_divide_cancel_left) |
|
1289 |
||
1290 |
lemma divide_add_eq_iff: |
|
1291 |
"(z::'a::field) \<noteq> 0 \<Longrightarrow> x/z + y = (x + z*y)/z" |
|
1292 |
by(simp add:add_divide_distrib nonzero_mult_divide_cancel_left) |
|
1293 |
||
1294 |
lemma diff_divide_eq_iff: |
|
1295 |
"(z::'a::field) \<noteq> 0 \<Longrightarrow> x - y/z = (z*x - y)/z" |
|
1296 |
by(simp add:diff_divide_distrib nonzero_mult_divide_cancel_left) |
|
1297 |
||
1298 |
lemma divide_diff_eq_iff: |
|
1299 |
"(z::'a::field) \<noteq> 0 \<Longrightarrow> x/z - y = (x - z*y)/z" |
|
1300 |
by(simp add:diff_divide_distrib nonzero_mult_divide_cancel_left) |
|
1301 |
||
1302 |
lemma nonzero_eq_divide_eq: "c\<noteq>0 ==> ((a::'a::field) = b/c) = (a*c = b)" |
|
1303 |
proof - |
|
1304 |
assume [simp]: "c\<noteq>0" |
|
23496 | 1305 |
have "(a = b/c) = (a*c = (b/c)*c)" by simp |
1306 |
also have "... = (a*c = b)" by (simp add: divide_inverse mult_assoc) |
|
23482 | 1307 |
finally show ?thesis . |
1308 |
qed |
|
1309 |
||
1310 |
lemma nonzero_divide_eq_eq: "c\<noteq>0 ==> (b/c = (a::'a::field)) = (b = a*c)" |
|
1311 |
proof - |
|
1312 |
assume [simp]: "c\<noteq>0" |
|
23496 | 1313 |
have "(b/c = a) = ((b/c)*c = a*c)" by simp |
1314 |
also have "... = (b = a*c)" by (simp add: divide_inverse mult_assoc) |
|
23482 | 1315 |
finally show ?thesis . |
1316 |
qed |
|
1317 |
||
1318 |
lemma eq_divide_eq: |
|
1319 |
"((a::'a::{field,division_by_zero}) = b/c) = (if c\<noteq>0 then a*c = b else a=0)" |
|
1320 |
by (simp add: nonzero_eq_divide_eq) |
|
1321 |
||
1322 |
lemma divide_eq_eq: |
|
1323 |
"(b/c = (a::'a::{field,division_by_zero})) = (if c\<noteq>0 then b = a*c else a=0)" |
|
1324 |
by (force simp add: nonzero_divide_eq_eq) |
|
1325 |
||
1326 |
lemma divide_eq_imp: "(c::'a::{division_by_zero,field}) ~= 0 ==> |
|
1327 |
b = a * c ==> b / c = a" |
|
29667 | 1328 |
by (subst divide_eq_eq, simp) |
23482 | 1329 |
|
1330 |
lemma eq_divide_imp: "(c::'a::{division_by_zero,field}) ~= 0 ==> |
|
1331 |
a * c = b ==> a = b / c" |
|
29667 | 1332 |
by (subst eq_divide_eq, simp) |
1333 |
||
1334 |
||
1335 |
lemmas field_eq_simps = algebra_simps |
|
23482 | 1336 |
(* pull / out*) |
1337 |
add_divide_eq_iff divide_add_eq_iff |
|
1338 |
diff_divide_eq_iff divide_diff_eq_iff |
|
1339 |
(* multiply eqn *) |
|
1340 |
nonzero_eq_divide_eq nonzero_divide_eq_eq |
|
1341 |
(* is added later: |
|
1342 |
times_divide_eq_left times_divide_eq_right |
|
1343 |
*) |
|
1344 |
||
1345 |
text{*An example:*} |
|
1346 |
lemma fixes a b c d e f :: "'a::field" |
|
1347 |
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" |
|
1348 |
apply(subgoal_tac "(c-d)*(e-f)*(a-b) \<noteq> 0") |
|
1349 |
apply(simp add:field_eq_simps) |
|
1350 |
apply(simp) |
|
1351 |
done |
|
1352 |
||
1353 |
||
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1354 |
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:
16568
diff
changeset
|
1355 |
x / y - w / z = (x * z - w * y) / (y * z)" |
23482 | 1356 |
by (simp add:field_eq_simps times_divide_eq) |
1357 |
||
1358 |
lemma frac_eq_eq: "(y::'a::field) ~= 0 ==> z ~= 0 ==> |
|
1359 |
(x / y = w / z) = (x * z = w * y)" |
|
1360 |
by (simp add:field_eq_simps times_divide_eq) |
|
14293 | 1361 |
|
23389 | 1362 |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1363 |
subsection {* Ordered Fields *} |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1364 |
|
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1365 |
lemma positive_imp_inverse_positive: |
23482 | 1366 |
assumes a_gt_0: "0 < a" shows "0 < inverse (a::'a::ordered_field)" |
1367 |
proof - |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1368 |
have "0 < a * inverse a" |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1369 |
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:
14267
diff
changeset
|
1370 |
thus "0 < inverse a" |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1371 |
by (simp add: a_gt_0 [THEN order_less_not_sym] zero_less_mult_iff) |
23482 | 1372 |
qed |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1373 |
|
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1374 |
lemma negative_imp_inverse_negative: |
23482 | 1375 |
"a < 0 ==> inverse a < (0::'a::ordered_field)" |
1376 |
by (insert positive_imp_inverse_positive [of "-a"], |
|
1377 |
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:
14267
diff
changeset
|
1378 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1379 |
lemma inverse_le_imp_le: |
23482 | 1380 |
assumes invle: "inverse a \<le> inverse b" and apos: "0 < a" |
1381 |
shows "b \<le> (a::'a::ordered_field)" |
|
1382 |
proof (rule classical) |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1383 |
assume "~ b \<le> a" |
23482 | 1384 |
hence "a < b" by (simp add: linorder_not_le) |
1385 |
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:
14267
diff
changeset
|
1386 |
hence "a * inverse a \<le> a * inverse b" |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1387 |
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:
14267
diff
changeset
|
1388 |
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:
14267
diff
changeset
|
1389 |
by (simp add: bpos order_less_imp_le mult_right_mono) |
23482 | 1390 |
thus "b \<le> a" by (simp add: mult_assoc apos bpos order_less_imp_not_eq2) |
1391 |
qed |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1392 |
|
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1393 |
lemma inverse_positive_imp_positive: |
23482 | 1394 |
assumes inv_gt_0: "0 < inverse a" and nz: "a \<noteq> 0" |
1395 |
shows "0 < (a::'a::ordered_field)" |
|
23389 | 1396 |
proof - |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1397 |
have "0 < inverse (inverse a)" |
23389 | 1398 |
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:
14272
diff
changeset
|
1399 |
thus "0 < a" |
23389 | 1400 |
using nz by (simp add: nonzero_inverse_inverse_eq) |
1401 |
qed |
|
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1402 |
|
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1403 |
lemma inverse_positive_iff_positive [simp]: |
23482 | 1404 |
"(0 < inverse a) = (0 < (a::'a::{ordered_field,division_by_zero}))" |
21328 | 1405 |
apply (cases "a = 0", simp) |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1406 |
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:
14272
diff
changeset
|
1407 |
done |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1408 |
|
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1409 |
lemma inverse_negative_imp_negative: |
23482 | 1410 |
assumes inv_less_0: "inverse a < 0" and nz: "a \<noteq> 0" |
1411 |
shows "a < (0::'a::ordered_field)" |
|
23389 | 1412 |
proof - |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1413 |
have "inverse (inverse a) < 0" |
23389 | 1414 |
using inv_less_0 by (rule negative_imp_inverse_negative) |
23482 | 1415 |
thus "a < 0" using nz by (simp add: nonzero_inverse_inverse_eq) |
23389 | 1416 |
qed |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1417 |
|
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1418 |
lemma inverse_negative_iff_negative [simp]: |
23482 | 1419 |
"(inverse a < 0) = (a < (0::'a::{ordered_field,division_by_zero}))" |
21328 | 1420 |
apply (cases "a = 0", simp) |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1421 |
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:
14272
diff
changeset
|
1422 |
done |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1423 |
|
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1424 |
lemma inverse_nonnegative_iff_nonnegative [simp]: |
23482 | 1425 |
"(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:
14272
diff
changeset
|
1426 |
by (simp add: linorder_not_less [symmetric]) |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1427 |
|
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1428 |
lemma inverse_nonpositive_iff_nonpositive [simp]: |
23482 | 1429 |
"(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:
14272
diff
changeset
|
1430 |
by (simp add: linorder_not_less [symmetric]) |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1431 |
|
23406
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
chaieb
parents:
23400
diff
changeset
|
1432 |
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:
23400
diff
changeset
|
1433 |
proof |
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
chaieb
parents:
23400
diff
changeset
|
1434 |
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:
23400
diff
changeset
|
1435 |
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:
23400
diff
changeset
|
1436 |
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:
23400
diff
changeset
|
1437 |
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:
23400
diff
changeset
|
1438 |
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:
23400
diff
changeset
|
1439 |
qed |
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
chaieb
parents:
23400
diff
changeset
|
1440 |
|
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
chaieb
parents:
23400
diff
changeset
|
1441 |
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:
23400
diff
changeset
|
1442 |
proof |
167b53019d6f
added theorems nonzero_mult_divide_cancel_right' nonzero_mult_divide_cancel_left' ordered_field_no_lb ordered_field_no_ub
chaieb
parents:
23400
diff
changeset
|
1443 |
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:
23400
diff
changeset
|
1444 |
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:
23400
diff
changeset
|
1445 |
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:
23400
diff
changeset
|
1446 |
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:
23400
diff
changeset
|
1447 |
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:
23400
diff
changeset
|
1448 |
qed |
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1449 |
|
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1450 |
subsection{*Anti-Monotonicity of @{term inverse}*} |
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1451 |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1452 |
lemma less_imp_inverse_less: |
23482 | 1453 |
assumes less: "a < b" and apos: "0 < a" |
1454 |
shows "inverse b < inverse (a::'a::ordered_field)" |
|
1455 |
proof (rule ccontr) |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1456 |
assume "~ inverse b < inverse a" |
29667 | 1457 |
hence "inverse a \<le> inverse b" by (simp add: linorder_not_less) |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1458 |
hence "~ (a < b)" |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1459 |
by (simp add: linorder_not_less inverse_le_imp_le [OF _ apos]) |
29667 | 1460 |
thus False by (rule notE [OF _ less]) |
23482 | 1461 |
qed |
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1462 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1463 |
lemma inverse_less_imp_less: |
23482 | 1464 |
"[|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:
14267
diff
changeset
|
1465 |
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:
14267
diff
changeset
|
1466 |
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:
14267
diff
changeset
|
1467 |
done |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1468 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1469 |
text{*Both premises are essential. Consider -1 and 1.*} |
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1470 |
lemma inverse_less_iff_less [simp,noatp]: |
23482 | 1471 |
"[|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:
14267
diff
changeset
|
1472 |
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:
14267
diff
changeset
|
1473 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1474 |
lemma le_imp_inverse_le: |
23482 | 1475 |
"[|a \<le> b; 0 < a|] ==> inverse b \<le> inverse (a::'a::ordered_field)" |
1476 |
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:
14267
diff
changeset
|
1477 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1478 |
lemma inverse_le_iff_le [simp,noatp]: |
23482 | 1479 |
"[|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:
14267
diff
changeset
|
1480 |
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:
14267
diff
changeset
|
1481 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1482 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1483 |
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:
14267
diff
changeset
|
1484 |
case is trivial, since inverse preserves signs.*} |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1485 |
lemma inverse_le_imp_le_neg: |
23482 | 1486 |
"[|inverse a \<le> inverse b; b < 0|] ==> b \<le> (a::'a::ordered_field)" |
1487 |
apply (rule classical) |
|
1488 |
apply (subgoal_tac "a < 0") |
|
1489 |
prefer 2 apply (force simp add: linorder_not_le intro: order_less_trans) |
|
1490 |
apply (insert inverse_le_imp_le [of "-b" "-a"]) |
|
1491 |
apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) |
|
1492 |
done |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1493 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1494 |
lemma less_imp_inverse_less_neg: |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1495 |
"[|a < b; b < 0|] ==> inverse b < inverse (a::'a::ordered_field)" |
23482 | 1496 |
apply (subgoal_tac "a < 0") |
1497 |
prefer 2 apply (blast intro: order_less_trans) |
|
1498 |
apply (insert less_imp_inverse_less [of "-b" "-a"]) |
|
1499 |
apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) |
|
1500 |
done |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1501 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1502 |
lemma inverse_less_imp_less_neg: |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1503 |
"[|inverse a < inverse b; b < 0|] ==> b < (a::'a::ordered_field)" |
23482 | 1504 |
apply (rule classical) |
1505 |
apply (subgoal_tac "a < 0") |
|
1506 |
prefer 2 |
|
1507 |
apply (force simp add: linorder_not_less intro: order_le_less_trans) |
|
1508 |
apply (insert inverse_less_imp_less [of "-b" "-a"]) |
|
1509 |
apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) |
|
1510 |
done |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1511 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1512 |
lemma inverse_less_iff_less_neg [simp,noatp]: |
23482 | 1513 |
"[|a < 0; b < 0|] ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))" |
1514 |
apply (insert inverse_less_iff_less [of "-b" "-a"]) |
|
1515 |
apply (simp del: inverse_less_iff_less |
|
1516 |
add: order_less_imp_not_eq nonzero_inverse_minus_eq) |
|
1517 |
done |
|
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1518 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
14267
diff
changeset
|
1519 |
lemma le_imp_inverse_le_neg: |
23482 | 1520 |
"[|a \<le> b; b < 0|] ==> inverse b \<le> inverse (a::'a::ordered_field)" |
1521 |
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:
14267
diff
changeset
|
1522 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1523 |
lemma inverse_le_iff_le_neg [simp,noatp]: |
23482 | 1524 |
"[|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:
14267
diff
changeset
|
1525 |
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
|
1526 |
|
14277
ad66687ece6e
more field division lemmas transferred from Real to Ring_and_Field
paulson
parents:
14272
diff
changeset
|
1527 |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1528 |
subsection{*Inverses and the Number One*} |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1529 |
|
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1530 |
lemma one_less_inverse_iff: |
23482 | 1531 |
"(1 < inverse x) = (0 < x & x < (1::'a::{ordered_field,division_by_zero}))" |
1532 |
proof cases |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1533 |
assume "0 < x" |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1534 |
with inverse_less_iff_less [OF zero_less_one, of x] |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1535 |
show ?thesis by simp |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1536 |
next |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1537 |
assume notless: "~ (0 < x)" |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1538 |
have "~ (1 < inverse x)" |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1539 |
proof |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1540 |
assume "1 < inverse x" |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1541 |
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:
14353
diff
changeset
|
1542 |
also have "... < 1" by (rule zero_less_one) |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1543 |
finally show False by auto |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1544 |
qed |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1545 |
with notless show ?thesis by simp |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1546 |
qed |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1547 |
|
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1548 |
lemma inverse_eq_1_iff [simp]: |
23482 | 1549 |
"(inverse x = 1) = (x = (1::'a::{field,division_by_zero}))" |
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1550 |
by (insert inverse_eq_iff_eq [of x 1], simp) |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1551 |
|
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1552 |
lemma one_le_inverse_iff: |
23482 | 1553 |
"(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:
14353
diff
changeset
|
1554 |
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:
14353
diff
changeset
|
1555 |
eq_commute [of 1]) |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1556 |
|
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1557 |
lemma inverse_less_1_iff: |
23482 | 1558 |
"(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:
14353
diff
changeset
|
1559 |
by (simp add: linorder_not_le [symmetric] one_le_inverse_iff) |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1560 |
|
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1561 |
lemma inverse_le_1_iff: |
23482 | 1562 |
"(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:
14353
diff
changeset
|
1563 |
by (simp add: linorder_not_less [symmetric] one_less_inverse_iff) |
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
1564 |
|
23389 | 1565 |
|
14288 | 1566 |
subsection{*Simplification of Inequalities Involving Literal Divisors*} |
1567 |
||
1568 |
lemma pos_le_divide_eq: "0 < (c::'a::ordered_field) ==> (a \<le> b/c) = (a*c \<le> b)" |
|
1569 |
proof - |
|
1570 |
assume less: "0<c" |
|
1571 |
hence "(a \<le> b/c) = (a*c \<le> (b/c)*c)" |
|
1572 |
by (simp add: mult_le_cancel_right order_less_not_sym [OF less]) |
|
1573 |
also have "... = (a*c \<le> b)" |
|
1574 |
by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) |
|
1575 |
finally show ?thesis . |
|
1576 |
qed |
|
1577 |
||
1578 |
lemma neg_le_divide_eq: "c < (0::'a::ordered_field) ==> (a \<le> b/c) = (b \<le> a*c)" |
|
1579 |
proof - |
|
1580 |
assume less: "c<0" |
|
1581 |
hence "(a \<le> b/c) = ((b/c)*c \<le> a*c)" |
|
1582 |
by (simp add: mult_le_cancel_right order_less_not_sym [OF less]) |
|
1583 |
also have "... = (b \<le> a*c)" |
|
1584 |
by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) |
|
1585 |
finally show ?thesis . |
|
1586 |
qed |
|
1587 |
||
1588 |
lemma le_divide_eq: |
|
1589 |
"(a \<le> b/c) = |
|
1590 |
(if 0 < c then a*c \<le> b |
|
1591 |
else if c < 0 then b \<le> a*c |
|
1592 |
else a \<le> (0::'a::{ordered_field,division_by_zero}))" |
|
21328 | 1593 |
apply (cases "c=0", simp) |
14288 | 1594 |
apply (force simp add: pos_le_divide_eq neg_le_divide_eq linorder_neq_iff) |
1595 |
done |
|
1596 |
||
1597 |
lemma pos_divide_le_eq: "0 < (c::'a::ordered_field) ==> (b/c \<le> a) = (b \<le> a*c)" |
|
1598 |
proof - |
|
1599 |
assume less: "0<c" |
|
1600 |
hence "(b/c \<le> a) = ((b/c)*c \<le> a*c)" |
|
1601 |
by (simp add: mult_le_cancel_right order_less_not_sym [OF less]) |
|
1602 |
also have "... = (b \<le> a*c)" |
|
1603 |
by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) |
|
1604 |
finally show ?thesis . |
|
1605 |
qed |
|
1606 |
||
1607 |
lemma neg_divide_le_eq: "c < (0::'a::ordered_field) ==> (b/c \<le> a) = (a*c \<le> b)" |
|
1608 |
proof - |
|
1609 |
assume less: "c<0" |
|
1610 |
hence "(b/c \<le> a) = (a*c \<le> (b/c)*c)" |
|
1611 |
by (simp add: mult_le_cancel_right order_less_not_sym [OF less]) |
|
1612 |
also have "... = (a*c \<le> b)" |
|
1613 |
by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) |
|
1614 |
finally show ?thesis . |
|
1615 |
qed |
|
1616 |
||
1617 |
lemma divide_le_eq: |
|
1618 |
"(b/c \<le> a) = |
|
1619 |
(if 0 < c then b \<le> a*c |
|
1620 |
else if c < 0 then a*c \<le> b |
|
1621 |
else 0 \<le> (a::'a::{ordered_field,division_by_zero}))" |
|
21328 | 1622 |
apply (cases "c=0", simp) |
14288 | 1623 |
apply (force simp add: pos_divide_le_eq neg_divide_le_eq linorder_neq_iff) |
1624 |
done |
|
1625 |
||
1626 |
lemma pos_less_divide_eq: |
|
1627 |
"0 < (c::'a::ordered_field) ==> (a < b/c) = (a*c < b)" |
|
1628 |
proof - |
|
1629 |
assume less: "0<c" |
|
1630 |
hence "(a < b/c) = (a*c < (b/c)*c)" |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1631 |
by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less]) |
14288 | 1632 |
also have "... = (a*c < b)" |
1633 |
by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) |
|
1634 |
finally show ?thesis . |
|
1635 |
qed |
|
1636 |
||
1637 |
lemma neg_less_divide_eq: |
|
1638 |
"c < (0::'a::ordered_field) ==> (a < b/c) = (b < a*c)" |
|
1639 |
proof - |
|
1640 |
assume less: "c<0" |
|
1641 |
hence "(a < b/c) = ((b/c)*c < a*c)" |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1642 |
by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less]) |
14288 | 1643 |
also have "... = (b < a*c)" |
1644 |
by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) |
|
1645 |
finally show ?thesis . |
|
1646 |
qed |
|
1647 |
||
1648 |
lemma less_divide_eq: |
|
1649 |
"(a < b/c) = |
|
1650 |
(if 0 < c then a*c < b |
|
1651 |
else if c < 0 then b < a*c |
|
1652 |
else a < (0::'a::{ordered_field,division_by_zero}))" |
|
21328 | 1653 |
apply (cases "c=0", simp) |
14288 | 1654 |
apply (force simp add: pos_less_divide_eq neg_less_divide_eq linorder_neq_iff) |
1655 |
done |
|
1656 |
||
1657 |
lemma pos_divide_less_eq: |
|
1658 |
"0 < (c::'a::ordered_field) ==> (b/c < a) = (b < a*c)" |
|
1659 |
proof - |
|
1660 |
assume less: "0<c" |
|
1661 |
hence "(b/c < a) = ((b/c)*c < a*c)" |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1662 |
by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less]) |
14288 | 1663 |
also have "... = (b < a*c)" |
1664 |
by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) |
|
1665 |
finally show ?thesis . |
|
1666 |
qed |
|
1667 |
||
1668 |
lemma neg_divide_less_eq: |
|
1669 |
"c < (0::'a::ordered_field) ==> (b/c < a) = (a*c < b)" |
|
1670 |
proof - |
|
1671 |
assume less: "c<0" |
|
1672 |
hence "(b/c < a) = (a*c < (b/c)*c)" |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1673 |
by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less]) |
14288 | 1674 |
also have "... = (a*c < b)" |
1675 |
by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) |
|
1676 |
finally show ?thesis . |
|
1677 |
qed |
|
1678 |
||
1679 |
lemma divide_less_eq: |
|
1680 |
"(b/c < a) = |
|
1681 |
(if 0 < c then b < a*c |
|
1682 |
else if c < 0 then a*c < b |
|
1683 |
else 0 < (a::'a::{ordered_field,division_by_zero}))" |
|
21328 | 1684 |
apply (cases "c=0", simp) |
14288 | 1685 |
apply (force simp add: pos_divide_less_eq neg_divide_less_eq linorder_neq_iff) |
1686 |
done |
|
1687 |
||
23482 | 1688 |
|
1689 |
subsection{*Field simplification*} |
|
1690 |
||
29667 | 1691 |
text{* Lemmas @{text field_simps} multiply with denominators in in(equations) |
1692 |
if they can be proved to be non-zero (for equations) or positive/negative |
|
1693 |
(for inequations). Can be too aggressive and is therefore separate from the |
|
1694 |
more benign @{text algebra_simps}. *} |
|
14288 | 1695 |
|
23482 | 1696 |
lemmas field_simps = field_eq_simps |
1697 |
(* multiply ineqn *) |
|
1698 |
pos_divide_less_eq neg_divide_less_eq |
|
1699 |
pos_less_divide_eq neg_less_divide_eq |
|
1700 |
pos_divide_le_eq neg_divide_le_eq |
|
1701 |
pos_le_divide_eq neg_le_divide_eq |
|
14288 | 1702 |
|
23482 | 1703 |
text{* Lemmas @{text sign_simps} is a first attempt to automate proofs |
23483 | 1704 |
of positivity/negativity needed for @{text field_simps}. Have not added @{text |
23482 | 1705 |
sign_simps} to @{text field_simps} because the former can lead to case |
1706 |
explosions. *} |
|
14288 | 1707 |
|
23482 | 1708 |
lemmas sign_simps = group_simps |
1709 |
zero_less_mult_iff mult_less_0_iff |
|
14288 | 1710 |
|
23482 | 1711 |
(* Only works once linear arithmetic is installed: |
1712 |
text{*An example:*} |
|
1713 |
lemma fixes a b c d e f :: "'a::ordered_field" |
|
1714 |
shows "\<lbrakk>a>b; c<d; e<f; 0 < u \<rbrakk> \<Longrightarrow> |
|
1715 |
((a-b)*(c-d)*(e-f))/((c-d)*(e-f)*(a-b)) < |
|
1716 |
((e-f)*(a-b)*(c-d))/((e-f)*(a-b)*(c-d)) + u" |
|
1717 |
apply(subgoal_tac "(c-d)*(e-f)*(a-b) > 0") |
|
1718 |
prefer 2 apply(simp add:sign_simps) |
|
1719 |
apply(subgoal_tac "(c-d)*(e-f)*(a-b)*u > 0") |
|
1720 |
prefer 2 apply(simp add:sign_simps) |
|
1721 |
apply(simp add:field_simps) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1722 |
done |
23482 | 1723 |
*) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1724 |
|
23389 | 1725 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1726 |
subsection{*Division and Signs*} |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1727 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1728 |
lemma zero_less_divide_iff: |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1729 |
"((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:
16568
diff
changeset
|
1730 |
by (simp add: divide_inverse zero_less_mult_iff) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1731 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1732 |
lemma divide_less_0_iff: |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1733 |
"(a/b < (0::'a::{ordered_field,division_by_zero})) = |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1734 |
(0 < a & b < 0 | a < 0 & 0 < b)" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1735 |
by (simp add: divide_inverse mult_less_0_iff) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1736 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1737 |
lemma zero_le_divide_iff: |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1738 |
"((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:
16568
diff
changeset
|
1739 |
(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:
16568
diff
changeset
|
1740 |
by (simp add: divide_inverse zero_le_mult_iff) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1741 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1742 |
lemma divide_le_0_iff: |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1743 |
"(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:
16568
diff
changeset
|
1744 |
(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:
16568
diff
changeset
|
1745 |
by (simp add: divide_inverse mult_le_0_iff) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1746 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1747 |
lemma divide_eq_0_iff [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1748 |
"(a/b = 0) = (a=0 | b=(0::'a::{field,division_by_zero}))" |
23482 | 1749 |
by (simp add: divide_inverse) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1750 |
|
23482 | 1751 |
lemma divide_pos_pos: |
1752 |
"0 < (x::'a::ordered_field) ==> 0 < y ==> 0 < x / y" |
|
1753 |
by(simp add:field_simps) |
|
1754 |
||
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1755 |
|
23482 | 1756 |
lemma divide_nonneg_pos: |
1757 |
"0 <= (x::'a::ordered_field) ==> 0 < y ==> 0 <= x / y" |
|
1758 |
by(simp add:field_simps) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1759 |
|
23482 | 1760 |
lemma divide_neg_pos: |
1761 |
"(x::'a::ordered_field) < 0 ==> 0 < y ==> x / y < 0" |
|
1762 |
by(simp add:field_simps) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1763 |
|
23482 | 1764 |
lemma divide_nonpos_pos: |
1765 |
"(x::'a::ordered_field) <= 0 ==> 0 < y ==> x / y <= 0" |
|
1766 |
by(simp add:field_simps) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1767 |
|
23482 | 1768 |
lemma divide_pos_neg: |
1769 |
"0 < (x::'a::ordered_field) ==> y < 0 ==> x / y < 0" |
|
1770 |
by(simp add:field_simps) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1771 |
|
23482 | 1772 |
lemma divide_nonneg_neg: |
1773 |
"0 <= (x::'a::ordered_field) ==> y < 0 ==> x / y <= 0" |
|
1774 |
by(simp add:field_simps) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1775 |
|
23482 | 1776 |
lemma divide_neg_neg: |
1777 |
"(x::'a::ordered_field) < 0 ==> y < 0 ==> 0 < x / y" |
|
1778 |
by(simp add:field_simps) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1779 |
|
23482 | 1780 |
lemma divide_nonpos_neg: |
1781 |
"(x::'a::ordered_field) <= 0 ==> y < 0 ==> 0 <= x / y" |
|
1782 |
by(simp add:field_simps) |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
1783 |
|
23389 | 1784 |
|
14288 | 1785 |
subsection{*Cancellation Laws for Division*} |
1786 |
||
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1787 |
lemma divide_cancel_right [simp,noatp]: |
14288 | 1788 |
"(a/c = b/c) = (c = 0 | a = (b::'a::{field,division_by_zero}))" |
23482 | 1789 |
apply (cases "c=0", simp) |
23496 | 1790 |
apply (simp add: divide_inverse) |
14288 | 1791 |
done |
1792 |
||
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1793 |
lemma divide_cancel_left [simp,noatp]: |
14288 | 1794 |
"(c/a = c/b) = (c = 0 | a = (b::'a::{field,division_by_zero}))" |
23482 | 1795 |
apply (cases "c=0", simp) |
23496 | 1796 |
apply (simp add: divide_inverse) |
14288 | 1797 |
done |
1798 |
||
23389 | 1799 |
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1800 |
subsection {* Division and the Number One *} |
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1801 |
|
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1802 |
text{*Simplify expressions equated with 1*} |
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1803 |
lemma divide_eq_1_iff [simp,noatp]: |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1804 |
"(a/b = 1) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))" |
23482 | 1805 |
apply (cases "b=0", simp) |
1806 |
apply (simp add: right_inverse_eq) |
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1807 |
done |
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1808 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1809 |
lemma one_eq_divide_iff [simp,noatp]: |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1810 |
"(1 = a/b) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))" |
23482 | 1811 |
by (simp add: eq_commute [of 1]) |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1812 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1813 |
lemma zero_eq_1_divide_iff [simp,noatp]: |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1814 |
"((0::'a::{ordered_field,division_by_zero}) = 1/a) = (a = 0)" |
23482 | 1815 |
apply (cases "a=0", simp) |
1816 |
apply (auto simp add: nonzero_eq_divide_eq) |
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1817 |
done |
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1818 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1819 |
lemma one_divide_eq_0_iff [simp,noatp]: |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1820 |
"(1/a = (0::'a::{ordered_field,division_by_zero})) = (a = 0)" |
23482 | 1821 |
apply (cases "a=0", simp) |
1822 |
apply (insert zero_neq_one [THEN not_sym]) |
|
1823 |
apply (auto simp add: nonzero_divide_eq_eq) |
|
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1824 |
done |
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1825 |
|
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1826 |
text{*Simplify expressions such as @{text "0 < 1/x"} to @{text "0 < x"}*} |
18623 | 1827 |
lemmas zero_less_divide_1_iff = zero_less_divide_iff [of 1, simplified] |
1828 |
lemmas divide_less_0_1_iff = divide_less_0_iff [of 1, simplified] |
|
1829 |
lemmas zero_le_divide_1_iff = zero_le_divide_iff [of 1, simplified] |
|
1830 |
lemmas divide_le_0_1_iff = divide_le_0_iff [of 1, simplified] |
|
17085 | 1831 |
|
1832 |
declare zero_less_divide_1_iff [simp] |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1833 |
declare divide_less_0_1_iff [simp,noatp] |
17085 | 1834 |
declare zero_le_divide_1_iff [simp] |
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1835 |
declare divide_le_0_1_iff [simp,noatp] |
14353
79f9fbef9106
Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents:
14348
diff
changeset
|
1836 |
|
23389 | 1837 |
|
14293 | 1838 |
subsection {* Ordering Rules for Division *} |
1839 |
||
1840 |
lemma divide_strict_right_mono: |
|
1841 |
"[|a < b; 0 < c|] ==> a / c < b / (c::'a::ordered_field)" |
|
1842 |
by (simp add: order_less_imp_not_eq2 divide_inverse mult_strict_right_mono |
|
23482 | 1843 |
positive_imp_inverse_positive) |
14293 | 1844 |
|
1845 |
lemma divide_right_mono: |
|
1846 |
"[|a \<le> b; 0 \<le> c|] ==> a/c \<le> b/(c::'a::{ordered_field,division_by_zero})" |
|
23482 | 1847 |
by (force simp add: divide_strict_right_mono order_le_less) |
14293 | 1848 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1849 |
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:
16568
diff
changeset
|
1850 |
==> c <= 0 ==> b / c <= a / c" |
23482 | 1851 |
apply (drule divide_right_mono [of _ _ "- c"]) |
1852 |
apply auto |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1853 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1854 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1855 |
lemma divide_strict_right_mono_neg: |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1856 |
"[|b < a; c < 0|] ==> a / c < b / (c::'a::ordered_field)" |
23482 | 1857 |
apply (drule divide_strict_right_mono [of _ _ "-c"], simp) |
1858 |
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:
16568
diff
changeset
|
1859 |
done |
14293 | 1860 |
|
1861 |
text{*The last premise ensures that @{term a} and @{term b} |
|
1862 |
have the same sign*} |
|
1863 |
lemma divide_strict_left_mono: |
|
23482 | 1864 |
"[|b < a; 0 < c; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)" |
1865 |
by(auto simp: field_simps times_divide_eq zero_less_mult_iff mult_strict_right_mono) |
|
14293 | 1866 |
|
1867 |
lemma divide_left_mono: |
|
23482 | 1868 |
"[|b \<le> a; 0 \<le> c; 0 < a*b|] ==> c / a \<le> c / (b::'a::ordered_field)" |
1869 |
by(auto simp: field_simps times_divide_eq zero_less_mult_iff mult_right_mono) |
|
14293 | 1870 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1871 |
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:
16568
diff
changeset
|
1872 |
==> c <= 0 ==> 0 < a * b ==> c / a <= c / b" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1873 |
apply (drule divide_left_mono [of _ _ "- c"]) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1874 |
apply (auto simp add: mult_commute) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1875 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1876 |
|
14293 | 1877 |
lemma divide_strict_left_mono_neg: |
23482 | 1878 |
"[|a < b; c < 0; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)" |
1879 |
by(auto simp: field_simps times_divide_eq zero_less_mult_iff mult_strict_right_mono_neg) |
|
1880 |
||
14293 | 1881 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1882 |
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:
16568
diff
changeset
|
1883 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1884 |
lemma le_divide_eq_1 [noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1885 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1886 |
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:
16568
diff
changeset
|
1887 |
by (auto simp add: le_divide_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1888 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1889 |
lemma divide_le_eq_1 [noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1890 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1891 |
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:
16568
diff
changeset
|
1892 |
by (auto simp add: divide_le_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1893 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1894 |
lemma less_divide_eq_1 [noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1895 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1896 |
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:
16568
diff
changeset
|
1897 |
by (auto simp add: less_divide_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1898 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1899 |
lemma divide_less_eq_1 [noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1900 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1901 |
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:
16568
diff
changeset
|
1902 |
by (auto simp add: divide_less_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1903 |
|
23389 | 1904 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1905 |
subsection{*Conditional Simplification Rules: No Case Splits*} |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1906 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1907 |
lemma le_divide_eq_1_pos [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1908 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1909 |
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:
16568
diff
changeset
|
1910 |
by (auto simp add: le_divide_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1911 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1912 |
lemma le_divide_eq_1_neg [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1913 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1914 |
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:
16568
diff
changeset
|
1915 |
by (auto simp add: le_divide_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1916 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1917 |
lemma divide_le_eq_1_pos [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1918 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1919 |
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:
16568
diff
changeset
|
1920 |
by (auto simp add: divide_le_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1921 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1922 |
lemma divide_le_eq_1_neg [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1923 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1924 |
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:
16568
diff
changeset
|
1925 |
by (auto simp add: divide_le_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1926 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1927 |
lemma less_divide_eq_1_pos [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1928 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1929 |
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:
16568
diff
changeset
|
1930 |
by (auto simp add: less_divide_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1931 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1932 |
lemma less_divide_eq_1_neg [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1933 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1934 |
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:
16568
diff
changeset
|
1935 |
by (auto simp add: less_divide_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1936 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1937 |
lemma divide_less_eq_1_pos [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1938 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1939 |
shows "0 < a \<Longrightarrow> (b/a < 1) = (b < a)" |
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1940 |
by (auto simp add: divide_less_eq) |
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1941 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1942 |
lemma divide_less_eq_1_neg [simp,noatp]: |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1943 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1944 |
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:
16568
diff
changeset
|
1945 |
by (auto simp add: divide_less_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1946 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1947 |
lemma eq_divide_eq_1 [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1948 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1949 |
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:
16568
diff
changeset
|
1950 |
by (auto simp add: eq_divide_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1951 |
|
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23879
diff
changeset
|
1952 |
lemma divide_eq_eq_1 [simp,noatp]: |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1953 |
fixes a :: "'a :: {ordered_field,division_by_zero}" |
18649
bb99c2e705ca
tidied, and added missing thm divide_less_eq_1_neg
paulson
parents:
18623
diff
changeset
|
1954 |
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:
16568
diff
changeset
|
1955 |
by (auto simp add: divide_eq_eq) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1956 |
|
23389 | 1957 |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1958 |
subsection {* Reasoning about inequalities with division *} |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1959 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1960 |
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:
16568
diff
changeset
|
1961 |
==> x * y <= x" |
29667 | 1962 |
by (auto simp add: mult_compare_simps); |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1963 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1964 |
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:
16568
diff
changeset
|
1965 |
==> y * x <= x" |
29667 | 1966 |
by (auto simp add: mult_compare_simps); |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1967 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1968 |
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:
16568
diff
changeset
|
1969 |
x / y <= z"; |
29667 | 1970 |
by (subst pos_divide_le_eq, assumption+); |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1971 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1972 |
lemma mult_imp_le_div_pos: "0 < (y::'a::ordered_field) ==> z * y <= x ==> |
23482 | 1973 |
z <= x / y" |
1974 |
by(simp add:field_simps) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1975 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1976 |
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:
16568
diff
changeset
|
1977 |
x / y < z" |
23482 | 1978 |
by(simp add:field_simps) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1979 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1980 |
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:
16568
diff
changeset
|
1981 |
z < x / y" |
23482 | 1982 |
by(simp add:field_simps) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1983 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1984 |
lemma frac_le: "(0::'a::ordered_field) <= x ==> |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1985 |
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:
16568
diff
changeset
|
1986 |
apply (rule mult_imp_div_pos_le) |
25230 | 1987 |
apply simp |
1988 |
apply (subst times_divide_eq_left) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1989 |
apply (rule mult_imp_le_div_pos, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1990 |
apply (rule mult_mono) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1991 |
apply simp_all |
14293 | 1992 |
done |
1993 |
||
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1994 |
lemma frac_less: "(0::'a::ordered_field) <= x ==> |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1995 |
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:
16568
diff
changeset
|
1996 |
apply (rule mult_imp_div_pos_less) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1997 |
apply simp; |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1998 |
apply (subst times_divide_eq_left); |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
1999 |
apply (rule mult_imp_less_div_pos, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2000 |
apply (erule mult_less_le_imp_less) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2001 |
apply simp_all |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2002 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2003 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2004 |
lemma frac_less2: "(0::'a::ordered_field) < x ==> |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2005 |
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:
16568
diff
changeset
|
2006 |
apply (rule mult_imp_div_pos_less) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2007 |
apply simp_all |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2008 |
apply (subst times_divide_eq_left); |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2009 |
apply (rule mult_imp_less_div_pos, assumption) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2010 |
apply (erule mult_le_less_imp_less) |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2011 |
apply simp_all |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2012 |
done |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2013 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2014 |
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:
16568
diff
changeset
|
2015 |
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:
16568
diff
changeset
|
2016 |
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:
16568
diff
changeset
|
2017 |
seem to need them.*} |
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2018 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2019 |
declare times_divide_eq [simp] |
14293 | 2020 |
|
23389 | 2021 |
|
14293 | 2022 |
subsection {* Ordered Fields are Dense *} |
2023 |
||
25193 | 2024 |
context ordered_semidom |
2025 |
begin |
|
2026 |
||
2027 |
lemma less_add_one: "a < a + 1" |
|
14293 | 2028 |
proof - |
25193 | 2029 |
have "a + 0 < a + 1" |
23482 | 2030 |
by (blast intro: zero_less_one add_strict_left_mono) |
14293 | 2031 |
thus ?thesis by simp |
2032 |
qed |
|
2033 |
||
25193 | 2034 |
lemma zero_less_two: "0 < 1 + 1" |
29667 | 2035 |
by (blast intro: less_trans zero_less_one less_add_one) |
25193 | 2036 |
|
2037 |
end |
|
14365
3d4df8c166ae
replacing HOL/Real/PRat, PNat by the rational number development
paulson
parents:
14353
diff
changeset
|
2038 |
|
14293 | 2039 |
lemma less_half_sum: "a < b ==> a < (a+b) / (1+1::'a::ordered_field)" |
23482 | 2040 |
by (simp add: field_simps zero_less_two) |
14293 | 2041 |
|
2042 |
lemma gt_half_sum: "a < b ==> (a+b)/(1+1::'a::ordered_field) < b" |
|
23482 | 2043 |
by (simp add: field_simps zero_less_two) |
14293 | 2044 |
|
24422 | 2045 |
instance ordered_field < dense_linear_order |
2046 |
proof |
|
2047 |
fix x y :: 'a |
|
2048 |
have "x < x + 1" by simp |
|
2049 |
then show "\<exists>y. x < y" .. |
|
2050 |
have "x - 1 < x" by simp |
|
2051 |
then show "\<exists>y. y < x" .. |
|
2052 |
show "x < y \<Longrightarrow> \<exists>z>x. z < y" by (blast intro!: less_half_sum gt_half_sum) |
|
2053 |
qed |
|
14293 | 2054 |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
2055 |
|
14293 | 2056 |
subsection {* Absolute Value *} |
2057 |
||
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2058 |
context ordered_idom |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2059 |
begin |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2060 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2061 |
lemma mult_sgn_abs: "sgn x * abs x = x" |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2062 |
unfolding abs_if sgn_if by auto |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2063 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2064 |
end |
24491 | 2065 |
|
14738 | 2066 |
lemma abs_one [simp]: "abs 1 = (1::'a::ordered_idom)" |
29667 | 2067 |
by (simp add: abs_if zero_less_one [THEN order_less_not_sym]) |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2068 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2069 |
class pordered_ring_abs = pordered_ring + pordered_ab_group_add_abs + |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2070 |
assumes abs_eq_mult: |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2071 |
"(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:
25267
diff
changeset
|
2072 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2073 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2074 |
class lordered_ring = pordered_ring + lordered_ab_group_add_abs |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2075 |
begin |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2076 |
|
27516 | 2077 |
subclass lordered_ab_group_add_meet .. |
2078 |
subclass lordered_ab_group_add_join .. |
|
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2079 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2080 |
end |
14294
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2081 |
|
14738 | 2082 |
lemma abs_le_mult: "abs (a * b) \<le> (abs a) * (abs (b::'a::lordered_ring))" |
2083 |
proof - |
|
2084 |
let ?x = "pprt a * pprt b - pprt a * nprt b - nprt a * pprt b + nprt a * nprt b" |
|
2085 |
let ?y = "pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b" |
|
2086 |
have a: "(abs a) * (abs b) = ?x" |
|
29667 | 2087 |
by (simp only: abs_prts[of a] abs_prts[of b] algebra_simps) |
14738 | 2088 |
{ |
2089 |
fix u v :: 'a |
|
15481 | 2090 |
have bh: "\<lbrakk>u = a; v = b\<rbrakk> \<Longrightarrow> |
2091 |
u * v = pprt a * pprt b + pprt a * nprt b + |
|
2092 |
nprt a * pprt b + nprt a * nprt b" |
|
14738 | 2093 |
apply (subst prts[of u], subst prts[of v]) |
29667 | 2094 |
apply (simp add: algebra_simps) |
14738 | 2095 |
done |
2096 |
} |
|
2097 |
note b = this[OF refl[of a] refl[of b]] |
|
2098 |
note addm = add_mono[of "0::'a" _ "0::'a", simplified] |
|
2099 |
note addm2 = add_mono[of _ "0::'a" _ "0::'a", simplified] |
|
2100 |
have xy: "- ?x <= ?y" |
|
14754
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
2101 |
apply (simp) |
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
2102 |
apply (rule_tac y="0::'a" in order_trans) |
16568 | 2103 |
apply (rule addm2) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2104 |
apply (simp_all add: mult_nonneg_nonneg mult_nonpos_nonpos) |
16568 | 2105 |
apply (rule addm) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2106 |
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:
14738
diff
changeset
|
2107 |
done |
14738 | 2108 |
have yx: "?y <= ?x" |
16568 | 2109 |
apply (simp add:diff_def) |
14754
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
2110 |
apply (rule_tac y=0 in order_trans) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2111 |
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:
16568
diff
changeset
|
2112 |
apply (rule addm, (simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)+) |
14738 | 2113 |
done |
2114 |
have i1: "a*b <= abs a * abs b" by (simp only: a b yx) |
|
2115 |
have i2: "- (abs a * abs b) <= a*b" by (simp only: a b xy) |
|
2116 |
show ?thesis |
|
2117 |
apply (rule abs_leI) |
|
2118 |
apply (simp add: i1) |
|
2119 |
apply (simp add: i2[simplified minus_le_iff]) |
|
2120 |
done |
|
2121 |
qed |
|
14294
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2122 |
|
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2123 |
instance lordered_ring \<subseteq> pordered_ring_abs |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2124 |
proof |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2125 |
fix a b :: "'a\<Colon> lordered_ring" |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2126 |
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:
25267
diff
changeset
|
2127 |
show "abs (a*b) = abs a * abs b" |
14738 | 2128 |
proof - |
2129 |
have s: "(0 <= a*b) | (a*b <= 0)" |
|
2130 |
apply (auto) |
|
2131 |
apply (rule_tac split_mult_pos_le) |
|
2132 |
apply (rule_tac contrapos_np[of "a*b <= 0"]) |
|
2133 |
apply (simp) |
|
2134 |
apply (rule_tac split_mult_neg_le) |
|
2135 |
apply (insert prems) |
|
2136 |
apply (blast) |
|
2137 |
done |
|
2138 |
have mulprts: "a * b = (pprt a + nprt a) * (pprt b + nprt b)" |
|
2139 |
by (simp add: prts[symmetric]) |
|
2140 |
show ?thesis |
|
2141 |
proof cases |
|
2142 |
assume "0 <= a * b" |
|
2143 |
then show ?thesis |
|
2144 |
apply (simp_all add: mulprts abs_prts) |
|
2145 |
apply (insert prems) |
|
14754
a080eeeaec14
Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents:
14738
diff
changeset
|
2146 |
apply (auto simp add: |
29667 | 2147 |
algebra_simps |
25078 | 2148 |
iffD1[OF zero_le_iff_zero_nprt] iffD1[OF le_zero_iff_zero_pprt] |
2149 |
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:
16568
diff
changeset
|
2150 |
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:
16568
diff
changeset
|
2151 |
apply(drule (1) mult_nonneg_nonpos2[of b a], simp) |
14738 | 2152 |
done |
2153 |
next |
|
2154 |
assume "~(0 <= a*b)" |
|
2155 |
with s have "a*b <= 0" by simp |
|
2156 |
then show ?thesis |
|
2157 |
apply (simp_all add: mulprts abs_prts) |
|
2158 |
apply (insert prems) |
|
29667 | 2159 |
apply (auto simp add: algebra_simps) |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2160 |
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:
16568
diff
changeset
|
2161 |
apply(drule (1) mult_nonpos_nonpos[of a b],simp) |
14738 | 2162 |
done |
2163 |
qed |
|
2164 |
qed |
|
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2165 |
qed |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2166 |
|
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2167 |
instance ordered_idom \<subseteq> pordered_ring_abs |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2168 |
by default (auto simp add: abs_if not_less |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2169 |
equal_neg_zero neg_equal_zero mult_less_0_iff) |
14294
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2170 |
|
14738 | 2171 |
lemma abs_mult: "abs (a * b) = abs a * abs (b::'a::ordered_idom)" |
29667 | 2172 |
by (simp add: abs_eq_mult linorder_linear) |
14293 | 2173 |
|
14738 | 2174 |
lemma abs_mult_self: "abs a * abs a = a * (a::'a::ordered_idom)" |
29667 | 2175 |
by (simp add: abs_if) |
14294
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2176 |
|
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2177 |
lemma nonzero_abs_inverse: |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2178 |
"a \<noteq> 0 ==> abs (inverse (a::'a::ordered_field)) = inverse (abs a)" |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2179 |
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:
14293
diff
changeset
|
2180 |
negative_imp_inverse_negative) |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2181 |
apply (blast intro: positive_imp_inverse_positive elim: order_less_asym) |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2182 |
done |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2183 |
|
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2184 |
lemma abs_inverse [simp]: |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2185 |
"abs (inverse (a::'a::{ordered_field,division_by_zero})) = |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2186 |
inverse (abs a)" |
21328 | 2187 |
apply (cases "a=0", simp) |
14294
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2188 |
apply (simp add: nonzero_abs_inverse) |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2189 |
done |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2190 |
|
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2191 |
lemma nonzero_abs_divide: |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2192 |
"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:
14293
diff
changeset
|
2193 |
by (simp add: divide_inverse abs_mult nonzero_abs_inverse) |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2194 |
|
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset
|
2195 |
lemma abs_divide [simp]: |
14294
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2196 |
"abs (a / (b::'a::{ordered_field,division_by_zero})) = abs a / abs b" |
21328 | 2197 |
apply (cases "b=0", simp) |
14294
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2198 |
apply (simp add: nonzero_abs_divide) |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2199 |
done |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2200 |
|
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2201 |
lemma abs_mult_less: |
14738 | 2202 |
"[| 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:
14293
diff
changeset
|
2203 |
proof - |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2204 |
assume ac: "abs a < c" |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2205 |
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:
14293
diff
changeset
|
2206 |
assume "abs b < d" |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2207 |
thus ?thesis by (simp add: ac cpos mult_strict_mono) |
f4d806fd72ce
absolute value theorems moved to HOL/Ring_and_Field
paulson
parents:
14293
diff
changeset
|
2208 |
qed |
14293 | 2209 |
|
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2210 |
lemmas eq_minus_self_iff = equal_neg_zero |
14738 | 2211 |
|
2212 |
lemma less_minus_self_iff: "(a < -a) = (a < (0::'a::ordered_idom))" |
|
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2213 |
unfolding order_less_le less_eq_neg_nonpos equal_neg_zero .. |
14738 | 2214 |
|
2215 |
lemma abs_less_iff: "(abs a < b) = (a < b & -a < (b::'a::ordered_idom))" |
|
2216 |
apply (simp add: order_less_le abs_le_iff) |
|
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2217 |
apply (auto simp add: abs_if neg_less_eq_nonneg less_eq_neg_nonpos) |
14738 | 2218 |
done |
2219 |
||
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2220 |
lemma abs_mult_pos: "(0::'a::ordered_idom) <= x ==> |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2221 |
(abs y) * x = abs (y * x)" |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2222 |
apply (subst abs_mult) |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2223 |
apply simp |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2224 |
done |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2225 |
|
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2226 |
lemma abs_div_pos: "(0::'a::{division_by_zero,ordered_field}) < y ==> |
25304
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2227 |
abs x / y = abs (x / y)" |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2228 |
apply (subst abs_divide) |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2229 |
apply (simp add: order_less_imp_le) |
7491c00f0915
removed subclass edge ordered_ring < lordered_ring
haftmann
parents:
25267
diff
changeset
|
2230 |
done |
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16568
diff
changeset
|
2231 |
|
23389 | 2232 |
|
19404 | 2233 |
subsection {* Bounds of products via negative and positive Part *} |
15178 | 2234 |
|
15580 | 2235 |
lemma mult_le_prts: |
2236 |
assumes |
|
2237 |
"a1 <= (a::'a::lordered_ring)" |
|
2238 |
"a <= a2" |
|
2239 |
"b1 <= b" |
|
2240 |
"b <= b2" |
|
2241 |
shows |
|
2242 |
"a * b <= pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1" |
|
2243 |
proof - |
|
2244 |
have "a * b = (pprt a + nprt a) * (pprt b + nprt b)" |
|
2245 |
apply (subst prts[symmetric])+ |
|
2246 |
apply simp |
|
2247 |
done |
|
2248 |
then have "a * b = pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b" |
|
29667 | 2249 |
by (simp add: algebra_simps) |
15580 | 2250 |
moreover have "pprt a * pprt b <= pprt a2 * pprt b2" |
2251 |
by (simp_all add: prems mult_mono) |
|
2252 |
moreover have "pprt a * nprt b <= pprt a1 * nprt b2" |
|
2253 |
proof - |
|
2254 |
have "pprt a * nprt b <= pprt a * nprt b2" |
|
2255 |
by (simp add: mult_left_mono prems) |
|
2256 |
moreover have "pprt a * nprt b2 <= pprt a1 * nprt b2" |
|
2257 |
by (simp add: mult_right_mono_neg prems) |
|
2258 |
ultimately show ?thesis |
|
2259 |
by simp |
|
2260 |
qed |
|
2261 |
moreover have "nprt a * pprt b <= nprt a2 * pprt b1" |
|
2262 |
proof - |
|
2263 |
have "nprt a * pprt b <= nprt a2 * pprt b" |
|
2264 |
by (simp add: mult_right_mono prems) |
|
2265 |
moreover have "nprt a2 * pprt b <= nprt a2 * pprt b1" |
|
2266 |
by (simp add: mult_left_mono_neg prems) |
|
2267 |
ultimately show ?thesis |
|
2268 |
by simp |
|
2269 |
qed |
|
2270 |
moreover have "nprt a * nprt b <= nprt a1 * nprt b1" |
|
2271 |
proof - |
|
2272 |
have "nprt a * nprt b <= nprt a * nprt b1" |
|
2273 |
by (simp add: mult_left_mono_neg prems) |
|
2274 |
moreover have "nprt a * nprt b1 <= nprt a1 * nprt b1" |
|
2275 |
by (simp add: mult_right_mono_neg prems) |
|
2276 |
ultimately show ?thesis |
|
2277 |
by simp |
|
2278 |
qed |
|
2279 |
ultimately show ?thesis |
|
2280 |
by - (rule add_mono | simp)+ |
|
2281 |
qed |
|
19404 | 2282 |
|
2283 |
lemma mult_ge_prts: |
|
15178 | 2284 |
assumes |
19404 | 2285 |
"a1 <= (a::'a::lordered_ring)" |
2286 |
"a <= a2" |
|
2287 |
"b1 <= b" |
|
2288 |
"b <= b2" |
|
15178 | 2289 |
shows |
19404 | 2290 |
"a * b >= nprt a1 * pprt b2 + nprt a2 * nprt b2 + pprt a1 * pprt b1 + pprt a2 * nprt b1" |
2291 |
proof - |
|
2292 |
from prems have a1:"- a2 <= -a" by auto |
|
2293 |
from prems have a2: "-a <= -a1" by auto |
|
2294 |
from mult_le_prts[of "-a2" "-a" "-a1" "b1" b "b2", OF a1 a2 prems(3) prems(4), simplified nprt_neg pprt_neg] |
|
2295 |
have le: "- (a * b) <= - nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1" by simp |
|
2296 |
then have "-(- nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1) <= a * b" |
|
2297 |
by (simp only: minus_le_iff) |
|
2298 |
then show ?thesis by simp |
|
15178 | 2299 |
qed |
2300 |
||
14265
95b42e69436c
HOL: installation of Ring_and_Field as the basis for Naturals and Reals
paulson
parents:
diff
changeset
|
2301 |
end |