author wenzelm Mon Jun 20 21:40:48 2016 +0200 (2016-06-20) changeset 63325 1086d56cde86 parent 63324 1e98146f3581 child 63326 9d2470571719
misc tuning and modernization;
 src/HOL/Groups.thy file | annotate | diff | revisions src/HOL/Rings.thy file | annotate | diff | revisions
     1.1 --- a/src/HOL/Groups.thy	Mon Jun 20 17:51:47 2016 +0200
1.2 +++ b/src/HOL/Groups.thy	Mon Jun 20 21:40:48 2016 +0200
1.3 @@ -13,22 +13,26 @@
1.4  named_theorems ac_simps "associativity and commutativity simplification rules"
1.5
1.6
1.7 -text\<open>The rewrites accumulated in \<open>algebra_simps\<close> deal with the
1.8 -classical algebraic structures of groups, rings and family. They simplify
1.9 -terms by multiplying everything out (in case of a ring) and bringing sums and
1.10 -products into a canonical form (by ordered rewriting). As a result it decides
1.11 -group and ring equalities but also helps with inequalities.
1.12 +text \<open>
1.13 +  The rewrites accumulated in \<open>algebra_simps\<close> deal with the
1.14 +  classical algebraic structures of groups, rings and family. They simplify
1.15 +  terms by multiplying everything out (in case of a ring) and bringing sums and
1.16 +  products into a canonical form (by ordered rewriting). As a result it decides
1.17 +  group and ring equalities but also helps with inequalities.
1.18
1.19 -Of course it also works for fields, but it knows nothing about multiplicative
1.20 -inverses or division. This is catered for by \<open>field_simps\<close>.\<close>
1.21 +  Of course it also works for fields, but it knows nothing about multiplicative
1.22 +  inverses or division. This is catered for by \<open>field_simps\<close>.
1.23 +\<close>
1.24
1.25  named_theorems algebra_simps "algebra simplification rules"
1.26
1.27
1.28 -text\<open>Lemmas \<open>field_simps\<close> multiply with denominators in (in)equations
1.29 -if they can be proved to be non-zero (for equations) or positive/negative
1.30 -(for inequations). Can be too aggressive and is therefore separate from the
1.31 -more benign \<open>algebra_simps\<close>.\<close>
1.32 +text \<open>
1.33 +  Lemmas \<open>field_simps\<close> multiply with denominators in (in)equations
1.34 +  if they can be proved to be non-zero (for equations) or positive/negative
1.35 +  (for inequations). Can be too aggressive and is therefore separate from the
1.36 +  more benign \<open>algebra_simps\<close>.
1.37 +\<close>
1.38
1.39  named_theorems field_simps "algebra simplification rules for fields"
1.40
1.41 @@ -42,15 +46,14 @@
1.42  \<close>
1.43
1.44  locale semigroup =
1.45 -  fixes f :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^bold>*" 70)
1.46 +  fixes f :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^bold>*" 70)
1.47    assumes assoc [ac_simps]: "a \<^bold>* b \<^bold>* c = a \<^bold>* (b \<^bold>* c)"
1.48
1.49  locale abel_semigroup = semigroup +
1.50    assumes commute [ac_simps]: "a \<^bold>* b = b \<^bold>* a"
1.51  begin
1.52
1.53 -lemma left_commute [ac_simps]:
1.54 -  "b \<^bold>* (a \<^bold>* c) = a \<^bold>* (b \<^bold>* c)"
1.55 +lemma left_commute [ac_simps]: "b \<^bold>* (a \<^bold>* c) = a \<^bold>* (b \<^bold>* c)"
1.56  proof -
1.57    have "(b \<^bold>* a) \<^bold>* c = (a \<^bold>* b) \<^bold>* c"
1.58      by (simp only: commute)
1.59 @@ -238,13 +241,11 @@
1.60    assumes add_right_imp_eq: "b + a = c + a \<Longrightarrow> b = c"
1.61  begin
1.62
1.64 -  "a + b = a + c \<longleftrightarrow> b = c"
1.66 +lemma add_left_cancel [simp]: "a + b = a + c \<longleftrightarrow> b = c"
1.67 +  by (blast dest: add_left_imp_eq)
1.68
1.70 -  "b + a = c + a \<longleftrightarrow> b = c"
1.72 +lemma add_right_cancel [simp]: "b + a = c + a \<longleftrightarrow> b = c"
1.73 +  by (blast dest: add_right_imp_eq)
1.74
1.75  end
1.76
1.77 @@ -253,8 +254,7 @@
1.78    assumes diff_diff_add [algebra_simps, field_simps]: "a - b - c = a - (b + c)"
1.79  begin
1.80
1.82 -  "(a + b) - b = a"
1.83 +lemma add_diff_cancel_right' [simp]: "(a + b) - b = a"
1.85
1.87 @@ -274,16 +274,13 @@
1.88      by simp
1.89  qed
1.90
1.92 -  "(c + a) - (c + b) = a - b"
1.93 +lemma add_diff_cancel_left [simp]: "(c + a) - (c + b) = a - b"
1.94    unfolding diff_diff_add [symmetric] by simp
1.95
1.97 -  "(a + c) - (b + c) = a - b"
1.98 +lemma add_diff_cancel_right [simp]: "(a + c) - (b + c) = a - b"
1.100
1.101 -lemma diff_right_commute:
1.102 -  "a - c - b = a - b - c"
1.103 +lemma diff_right_commute: "a - c - b = a - b - c"
1.105
1.106  end
1.107 @@ -291,14 +288,13 @@
1.109  begin
1.110
1.111 -lemma diff_zero [simp]:
1.112 -  "a - 0 = a"
1.113 +lemma diff_zero [simp]: "a - 0 = a"
1.114    using add_diff_cancel_right' [of a 0] by simp
1.115
1.116 -lemma diff_cancel [simp]:
1.117 -  "a - a = 0"
1.118 +lemma diff_cancel [simp]: "a - a = 0"
1.119  proof -
1.120 -  have "(a + 0) - (a + 0) = 0" by (simp only: add_diff_cancel_left diff_zero)
1.121 +  have "(a + 0) - (a + 0) = 0"
1.122 +    by (simp only: add_diff_cancel_left diff_zero)
1.123    then show ?thesis by simp
1.124  qed
1.125
1.126 @@ -306,29 +302,29 @@
1.127    assumes "c + b = a"
1.128    shows "c = a - b"
1.129  proof -
1.130 -  from assms have "(b + c) - (b + 0) = a - b" by (simp add: add.commute)
1.131 +  from assms have "(b + c) - (b + 0) = a - b"
1.133    then show "c = a - b" by simp
1.134  qed
1.135
1.137 -  "a = a + b \<longleftrightarrow> b = 0" (is "?P \<longleftrightarrow> ?Q")
1.138 +lemma add_cancel_right_right [simp]: "a = a + b \<longleftrightarrow> b = 0"
1.139 +  (is "?P \<longleftrightarrow> ?Q")
1.140  proof
1.141 -  assume ?Q then show ?P by simp
1.142 +  assume ?Q
1.143 +  then show ?P by simp
1.144  next
1.145 -  assume ?P then have "a - a = a + b - a" by simp
1.146 +  assume ?P
1.147 +  then have "a - a = a + b - a" by simp
1.148    then show ?Q by simp
1.149  qed
1.150
1.152 -  "a = b + a \<longleftrightarrow> b = 0"
1.153 +lemma add_cancel_right_left [simp]: "a = b + a \<longleftrightarrow> b = 0"
1.155
1.157 -  "a + b = a \<longleftrightarrow> b = 0"
1.158 +lemma add_cancel_left_right [simp]: "a + b = a \<longleftrightarrow> b = 0"
1.159    by (auto dest: sym)
1.160
1.162 -  "b + a = a \<longleftrightarrow> b = 0"
1.163 +lemma add_cancel_left_left [simp]: "b + a = a \<longleftrightarrow> b = 0"
1.164    by (auto dest: sym)
1.165
1.166  end
1.167 @@ -337,11 +333,12 @@
1.168    assumes zero_diff [simp]: "0 - a = 0"
1.169  begin
1.170
1.172 -  "a - (a + b) = 0"
1.173 +lemma diff_add_zero [simp]: "a - (a + b) = 0"
1.174  proof -
1.175 -  have "a - (a + b) = (a + 0) - (a + b)" by simp
1.176 -  also have "\<dots> = 0" by (simp only: add_diff_cancel_left zero_diff)
1.177 +  have "a - (a + b) = (a + 0) - (a + b)"
1.178 +    by simp
1.179 +  also have "\<dots> = 0"
1.180 +    by (simp only: add_diff_cancel_left zero_diff)
1.181    finally show ?thesis .
1.182  qed
1.183
1.184 @@ -355,14 +352,14 @@
1.185    assumes add_uminus_conv_diff [simp]: "a + (- b) = a - b"
1.186  begin
1.187
1.189 -  "a - b = a + (- b)"
1.190 +lemma diff_conv_add_uminus: "a - b = a + (- b)"
1.191    by simp
1.192
1.193  lemma minus_unique:
1.194 -  assumes "a + b = 0" shows "- a = b"
1.195 +  assumes "a + b = 0"
1.196 +  shows "- a = b"
1.197  proof -
1.198 -  have "- a = - a + (a + b)" using assms by simp
1.199 +  from assms have "- a = - a + (a + b)" by simp
1.201    finally show ?thesis .
1.202  qed
1.203 @@ -370,13 +367,13 @@
1.204  lemma minus_zero [simp]: "- 0 = 0"
1.205  proof -
1.206    have "0 + 0 = 0" by (rule add_0_right)
1.207 -  thus "- 0 = 0" by (rule minus_unique)
1.208 +  then show "- 0 = 0" by (rule minus_unique)
1.209  qed
1.210
1.211  lemma minus_minus [simp]: "- (- a) = a"
1.212  proof -
1.213    have "- a + a = 0" by (rule left_minus)
1.214 -  thus "- (- a) = a" by (rule minus_unique)
1.215 +  then show "- (- a) = a" by (rule minus_unique)
1.216  qed
1.217
1.218  lemma right_minus: "a + - a = 0"
1.219 @@ -386,8 +383,7 @@
1.220    finally show ?thesis .
1.221  qed
1.222
1.223 -lemma diff_self [simp]:
1.224 -  "a - a = 0"
1.225 +lemma diff_self [simp]: "a - a = 0"
1.226    using right_minus [of a] by simp
1.227
1.229 @@ -404,24 +400,19 @@
1.230    then show "b = c" unfolding add.assoc by simp
1.231  qed
1.232
1.234 -  "- a + (a + b) = b"
1.235 +lemma minus_add_cancel [simp]: "- a + (a + b) = b"
1.237
1.239 -  "a + (- a + b) = b"
1.240 +lemma add_minus_cancel [simp]: "a + (- a + b) = b"
1.242
1.244 -  "a - b + b = a"
1.245 +lemma diff_add_cancel [simp]: "a - b + b = a"
1.247
1.249 -  "a + b - b = a"
1.250 +lemma add_diff_cancel [simp]: "a + b - b = a"
1.252
1.254 -  "- (a + b) = - b + - a"
1.255 +lemma minus_add: "- (a + b) = - b + - a"
1.256  proof -
1.257    have "(a + b) + (- b + - a) = 0"
1.259 @@ -429,117 +420,103 @@
1.260      by (rule minus_unique)
1.261  qed
1.262
1.263 -lemma right_minus_eq [simp]:
1.264 -  "a - b = 0 \<longleftrightarrow> a = b"
1.265 +lemma right_minus_eq [simp]: "a - b = 0 \<longleftrightarrow> a = b"
1.266  proof
1.267    assume "a - b = 0"
1.268    have "a = (a - b) + b" by (simp add: add.assoc)
1.269    also have "\<dots> = b" using \<open>a - b = 0\<close> by simp
1.270    finally show "a = b" .
1.271  next
1.272 -  assume "a = b" thus "a - b = 0" by simp
1.273 +  assume "a = b"
1.274 +  then show "a - b = 0" by simp
1.275  qed
1.276
1.277 -lemma eq_iff_diff_eq_0:
1.278 -  "a = b \<longleftrightarrow> a - b = 0"
1.279 +lemma eq_iff_diff_eq_0: "a = b \<longleftrightarrow> a - b = 0"
1.280    by (fact right_minus_eq [symmetric])
1.281
1.282 -lemma diff_0 [simp]:
1.283 -  "0 - a = - a"
1.284 +lemma diff_0 [simp]: "0 - a = - a"
1.286
1.287 -lemma diff_0_right [simp]:
1.288 -  "a - 0 = a"
1.289 +lemma diff_0_right [simp]: "a - 0 = a"
1.291
1.293 -  "a - - b = a + b"
1.294 +lemma diff_minus_eq_add [simp]: "a - - b = a + b"
1.295    by (simp only: diff_conv_add_uminus minus_minus)
1.296
1.297 -lemma neg_equal_iff_equal [simp]:
1.298 -  "- a = - b \<longleftrightarrow> a = b"
1.299 +lemma neg_equal_iff_equal [simp]: "- a = - b \<longleftrightarrow> a = b"
1.300  proof
1.301    assume "- a = - b"
1.302 -  hence "- (- a) = - (- b)" by simp
1.303 -  thus "a = b" by simp
1.304 +  then have "- (- a) = - (- b)" by simp
1.305 +  then show "a = b" by simp
1.306  next
1.307    assume "a = b"
1.308 -  thus "- a = - b" by simp
1.309 +  then show "- a = - b" by simp
1.310  qed
1.311
1.312 -lemma neg_equal_0_iff_equal [simp]:
1.313 -  "- a = 0 \<longleftrightarrow> a = 0"
1.314 +lemma neg_equal_0_iff_equal [simp]: "- a = 0 \<longleftrightarrow> a = 0"
1.315    by (subst neg_equal_iff_equal [symmetric]) simp
1.316
1.317 -lemma neg_0_equal_iff_equal [simp]:
1.318 -  "0 = - a \<longleftrightarrow> 0 = a"
1.319 +lemma neg_0_equal_iff_equal [simp]: "0 = - a \<longleftrightarrow> 0 = a"
1.320    by (subst neg_equal_iff_equal [symmetric]) simp
1.321
1.322 -text\<open>The next two equations can make the simplifier loop!\<close>
1.323 +text \<open>The next two equations can make the simplifier loop!\<close>
1.324
1.325 -lemma equation_minus_iff:
1.326 -  "a = - b \<longleftrightarrow> b = - a"
1.327 +lemma equation_minus_iff: "a = - b \<longleftrightarrow> b = - a"
1.328  proof -
1.329 -  have "- (- a) = - b \<longleftrightarrow> - a = b" by (rule neg_equal_iff_equal)
1.330 -  thus ?thesis by (simp add: eq_commute)
1.331 +  have "- (- a) = - b \<longleftrightarrow> - a = b"
1.332 +    by (rule neg_equal_iff_equal)
1.333 +  then show ?thesis
1.334 +    by (simp add: eq_commute)
1.335  qed
1.336
1.337 -lemma minus_equation_iff:
1.338 -  "- a = b \<longleftrightarrow> - b = a"
1.339 +lemma minus_equation_iff: "- a = b \<longleftrightarrow> - b = a"
1.340  proof -
1.341 -  have "- a = - (- b) \<longleftrightarrow> a = -b" by (rule neg_equal_iff_equal)
1.342 -  thus ?thesis by (simp add: eq_commute)
1.343 +  have "- a = - (- b) \<longleftrightarrow> a = -b"
1.344 +    by (rule neg_equal_iff_equal)
1.345 +  then show ?thesis
1.346 +    by (simp add: eq_commute)
1.347  qed
1.348
1.350 -  "a = - b \<longleftrightarrow> a + b = 0"
1.351 +lemma eq_neg_iff_add_eq_0: "a = - b \<longleftrightarrow> a + b = 0"
1.352  proof
1.353 -  assume "a = - b" then show "a + b = 0" by simp
1.354 +  assume "a = - b"
1.355 +  then show "a + b = 0" by simp
1.356  next
1.357    assume "a + b = 0"
1.358    moreover have "a + (b + - b) = (a + b) + - b"
1.360 -  ultimately show "a = - b" by simp
1.361 +  ultimately show "a = - b"
1.362 +    by simp
1.363  qed
1.364
1.366 -  "a + b = 0 \<longleftrightarrow> a = - b"
1.367 +lemma add_eq_0_iff2: "a + b = 0 \<longleftrightarrow> a = - b"
1.369
1.371 -  "- a = b \<longleftrightarrow> a + b = 0"
1.372 +lemma neg_eq_iff_add_eq_0: "- a = b \<longleftrightarrow> a + b = 0"
1.374
1.376 -  "a + b = 0 \<longleftrightarrow> b = - a"
1.377 +lemma add_eq_0_iff: "a + b = 0 \<longleftrightarrow> b = - a"
1.379
1.380 -lemma minus_diff_eq [simp]:
1.381 -  "- (a - b) = b - a"
1.382 +lemma minus_diff_eq [simp]: "- (a - b) = b - a"
1.384
1.386 -  "a + (b - c) = (a + b) - c"
1.387 +lemma add_diff_eq [algebra_simps, field_simps]: "a + (b - c) = (a + b) - c"
1.389
1.391 -  "a - (b + c) = a - c - b"
1.392 +lemma diff_add_eq_diff_diff_swap: "a - (b + c) = a - c - b"
1.394
1.395 -lemma diff_eq_eq [algebra_simps, field_simps]:
1.396 -  "a - b = c \<longleftrightarrow> a = c + b"
1.397 +lemma diff_eq_eq [algebra_simps, field_simps]: "a - b = c \<longleftrightarrow> a = c + b"
1.398    by auto
1.399
1.400 -lemma eq_diff_eq [algebra_simps, field_simps]:
1.401 -  "a = c - b \<longleftrightarrow> a + b = c"
1.402 +lemma eq_diff_eq [algebra_simps, field_simps]: "a = c - b \<longleftrightarrow> a + b = c"
1.403    by auto
1.404
1.405 -lemma diff_diff_eq2 [algebra_simps, field_simps]:
1.406 -  "a - (b - c) = (a + c) - b"
1.407 +lemma diff_diff_eq2 [algebra_simps, field_simps]: "a - (b - c) = (a + c) - b"
1.409
1.410 -lemma diff_eq_diff_eq:
1.411 -  "a - b = c - d \<Longrightarrow> a = b \<longleftrightarrow> c = d"
1.412 +lemma diff_eq_diff_eq: "a - b = c - d \<Longrightarrow> a = b \<longleftrightarrow> c = d"
1.413    by (simp only: eq_iff_diff_eq_0 [of a b] eq_iff_diff_eq_0 [of c d])
1.414
1.415  end
1.416 @@ -550,7 +527,7 @@
1.417  begin
1.418
1.422
1.424  proof
1.425 @@ -563,16 +540,13 @@
1.427  qed
1.428
1.430 -  "- a + b = b - a"
1.431 +lemma uminus_add_conv_diff [simp]: "- a + b = b - a"
1.433
1.435 -  "- (a + b) = - a + - b"
1.436 +lemma minus_add_distrib [simp]: "- (a + b) = - a + - b"
1.438
1.440 -  "(a - b) + c = (a + c) - b"
1.441 +lemma diff_add_eq [algebra_simps, field_simps]: "(a - b) + c = (a + c) - b"
1.443
1.444  end
1.445 @@ -582,35 +556,31 @@
1.446
1.447  text \<open>
1.448    The theory of partially ordered groups is taken from the books:
1.449 -  \begin{itemize}
1.450 -  \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979
1.451 -  \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
1.452 -  \end{itemize}
1.453 +
1.454 +    \<^item> \<^emph>\<open>Lattice Theory\<close> by Garret Birkhoff, American Mathematical Society, 1979
1.455 +    \<^item> \<^emph>\<open>Partially Ordered Algebraic Systems\<close>, Pergamon Press, 1963
1.456 +
1.457    Most of the used notions can also be looked up in
1.458 -  \begin{itemize}
1.459 -  \item @{url "http://www.mathworld.com"} by Eric Weisstein et. al.
1.460 -  \item \emph{Algebra I} by van der Waerden, Springer.
1.461 -  \end{itemize}
1.462 +    \<^item> @{url "http://www.mathworld.com"} by Eric Weisstein et. al.
1.463 +    \<^item> \<^emph>\<open>Algebra I\<close> by van der Waerden, Springer
1.464  \<close>
1.465
1.467    assumes add_left_mono: "a \<le> b \<Longrightarrow> c + a \<le> c + b"
1.468  begin
1.469
1.471 -  "a \<le> b \<Longrightarrow> a + c \<le> b + c"
1.473 +lemma add_right_mono: "a \<le> b \<Longrightarrow> a + c \<le> b + c"
1.475
1.476  text \<open>non-strict, in both arguments\<close>
1.478 -  "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c \<le> b + d"
1.479 +lemma add_mono: "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c \<le> b + d"
1.480    apply (erule add_right_mono [THEN order_trans])
1.482    done
1.483
1.484  end
1.485
1.486 -text\<open>Strict monotonicity in both arguments\<close>
1.487 +text \<open>Strict monotonicity in both arguments\<close>
1.489    assumes add_strict_mono: "a < b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d"
1.490
1.491 @@ -618,13 +588,11 @@
1.493  begin
1.494
1.496 -  "a < b \<Longrightarrow> c + a < c + b"
1.498 +lemma add_strict_left_mono: "a < b \<Longrightarrow> c + a < c + b"
1.500
1.502 -  "a < b \<Longrightarrow> a + c < b + c"
1.504 +lemma add_strict_right_mono: "a < b \<Longrightarrow> a + c < b + c"
1.506
1.508    apply standard
1.509 @@ -632,17 +600,15 @@
1.511    done
1.512
1.514 -  "a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c < b + d"
1.515 -apply (erule add_strict_right_mono [THEN less_le_trans])
1.517 -done
1.518 +lemma add_less_le_mono: "a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c < b + d"
1.519 +  apply (erule add_strict_right_mono [THEN less_le_trans])
1.521 +  done
1.522
1.524 -  "a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d"
1.525 -apply (erule add_right_mono [THEN le_less_trans])
1.527 -done
1.528 +lemma add_le_less_mono: "a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d"
1.529 +  apply (erule add_right_mono [THEN le_less_trans])
1.531 +  done
1.532
1.533  end
1.534
1.535 @@ -651,63 +617,60 @@
1.536  begin
1.537
1.539 -  assumes less: "c + a < c + b" shows "a < b"
1.540 +  assumes less: "c + a < c + b"
1.541 +  shows "a < b"
1.542  proof -
1.543 -  from less have le: "c + a <= c + b" by (simp add: order_le_less)
1.544 -  have "a <= b"
1.545 +  from less have le: "c + a \<le> c + b"
1.546 +    by (simp add: order_le_less)
1.547 +  have "a \<le> b"
1.548      apply (insert le)
1.550 -    by (insert le, drule add_le_imp_le_left, assumption)
1.551 +    apply (insert le)
1.553 +    apply assumption
1.554 +    done
1.555    moreover have "a \<noteq> b"
1.556    proof (rule ccontr)
1.557 -    assume "~(a \<noteq> b)"
1.558 +    assume "\<not> ?thesis"
1.559      then have "a = b" by simp
1.560      then have "c + a = c + b" by simp
1.561 -    with less show "False"by simp
1.562 +    with less show "False" by simp
1.563    qed
1.564 -  ultimately show "a < b" by (simp add: order_le_less)
1.565 +  ultimately show "a < b"
1.566 +    by (simp add: order_le_less)
1.567  qed
1.568
1.570 -  "a + c < b + c \<Longrightarrow> a < b"
1.571 -apply (rule add_less_imp_less_left [of c])
1.573 -done
1.574 +lemma add_less_imp_less_right: "a + c < b + c \<Longrightarrow> a < b"
1.576
1.578 -  "c + a < c + b \<longleftrightarrow> a < b"
1.579 +lemma add_less_cancel_left [simp]: "c + a < c + b \<longleftrightarrow> a < b"
1.581
1.583 -  "a + c < b + c \<longleftrightarrow> a < b"
1.584 +lemma add_less_cancel_right [simp]: "a + c < b + c \<longleftrightarrow> a < b"
1.586
1.588 -  "c + a \<le> c + b \<longleftrightarrow> a \<le> b"
1.590 +lemma add_le_cancel_left [simp]: "c + a \<le> c + b \<longleftrightarrow> a \<le> b"
1.591 +  apply auto
1.594 +  done
1.595
1.597 -  "a + c \<le> b + c \<longleftrightarrow> a \<le> b"
1.598 +lemma add_le_cancel_right [simp]: "a + c \<le> b + c \<longleftrightarrow> a \<le> b"
1.600
1.602 -  "a + c \<le> b + c \<Longrightarrow> a \<le> b"
1.603 -by simp
1.604 +lemma add_le_imp_le_right: "a + c \<le> b + c \<Longrightarrow> a \<le> b"
1.605 +  by simp
1.606
1.608 -  "max x y + z = max (x + z) (y + z)"
1.609 +lemma max_add_distrib_left: "max x y + z = max (x + z) (y + z)"
1.610    unfolding max_def by auto
1.611
1.613 -  "min x y + z = min (x + z) (y + z)"
1.614 +lemma min_add_distrib_left: "min x y + z = min (x + z) (y + z)"
1.615    unfolding min_def by auto
1.616
1.618 -  "x + max y z = max (x + y) (x + z)"
1.619 +lemma max_add_distrib_right: "x + max y z = max (x + y) (x + z)"
1.620    unfolding max_def by auto
1.621
1.623 -  "x + min y z = min (x + y) (x + z)"
1.624 +lemma min_add_distrib_right: "x + min y z = min (x + y) (x + z)"
1.625    unfolding min_def by auto
1.626
1.627  end
1.628 @@ -717,36 +680,28 @@
1.630  begin
1.631
1.633 -  "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b"
1.634 +lemma add_nonneg_nonneg [simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b"
1.635    using add_mono[of 0 a 0 b] by simp
1.636
1.638 -  "a \<le> 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> a + b \<le> 0"
1.639 +lemma add_nonpos_nonpos: "a \<le> 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> a + b \<le> 0"
1.640    using add_mono[of a 0 b 0] by simp
1.641
1.643 -  "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0"
1.644 +lemma add_nonneg_eq_0_iff: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0"
1.645    using add_left_mono[of 0 y x] add_right_mono[of 0 x y] by auto
1.646
1.648 -  "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0"
1.649 +lemma add_nonpos_eq_0_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0"
1.650    using add_left_mono[of y 0 x] add_right_mono[of x 0 y] by auto
1.651
1.653 -  "0 \<le> a \<Longrightarrow> b \<le> c \<Longrightarrow> b \<le> a + c"
1.654 -  by (insert add_mono [of 0 a b c], simp)
1.655 +lemma add_increasing: "0 \<le> a \<Longrightarrow> b \<le> c \<Longrightarrow> b \<le> a + c"
1.656 +  using add_mono [of 0 a b c] by simp
1.657
1.659 -  "0 \<le> c \<Longrightarrow> b \<le> a \<Longrightarrow> b \<le> a + c"
1.660 +lemma add_increasing2: "0 \<le> c \<Longrightarrow> b \<le> a \<Longrightarrow> b \<le> a + c"
1.662
1.664 -  "a \<le> 0 \<Longrightarrow> c \<le> b \<Longrightarrow> a + c \<le> b"
1.665 -  using add_mono[of a 0 c b] by simp
1.666 +lemma add_decreasing: "a \<le> 0 \<Longrightarrow> c \<le> b \<Longrightarrow> a + c \<le> b"
1.667 +  using add_mono [of a 0 c b] by simp
1.668
1.670 -  "c \<le> 0 \<Longrightarrow> a \<le> b \<Longrightarrow> a + c \<le> b"
1.671 +lemma add_decreasing2: "c \<le> 0 \<Longrightarrow> a \<le> b \<Longrightarrow> a + c \<le> b"
1.672    using add_mono[of a b c 0] by simp
1.673
1.674  lemma add_pos_nonneg: "0 < a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 < a + b"
1.675 @@ -776,8 +731,7 @@
1.677  begin
1.678
1.680 -  shows "0 < a \<Longrightarrow> b < c \<Longrightarrow> b < a + c"
1.681 +lemma pos_add_strict: "0 < a \<Longrightarrow> b < c \<Longrightarrow> b < a + c"
1.682    using add_strict_mono [of 0 a b c] by simp
1.683
1.684  end
1.685 @@ -788,13 +742,11 @@
1.688
1.690 -  "0 < a \<Longrightarrow> b \<le> c \<Longrightarrow> b < a + c"
1.691 -  by (insert add_less_le_mono [of 0 a b c], simp)
1.692 +lemma add_strict_increasing: "0 < a \<Longrightarrow> b \<le> c \<Longrightarrow> b < a + c"
1.693 +  using add_less_le_mono [of 0 a b c] by simp
1.694
1.696 -  "0 \<le> a \<Longrightarrow> b < c \<Longrightarrow> b < a + c"
1.697 -  by (insert add_le_less_mono [of 0 a b c], simp)
1.698 +lemma add_strict_increasing2: "0 \<le> a \<Longrightarrow> b < c \<Longrightarrow> b < a + c"
1.699 +  using add_le_less_mono [of 0 a b c] by simp
1.700
1.701  end
1.702
1.703 @@ -807,105 +759,108 @@
1.704  proof
1.705    fix a b c :: 'a
1.706    assume "c + a \<le> c + b"
1.707 -  hence "(-c) + (c + a) \<le> (-c) + (c + b)" by (rule add_left_mono)
1.708 -  hence "((-c) + c) + a \<le> ((-c) + c) + b" by (simp only: add.assoc)
1.709 -  thus "a \<le> b" by simp
1.710 +  then have "(-c) + (c + a) \<le> (-c) + (c + b)"
1.712 +  then have "((-c) + c) + a \<le> ((-c) + c) + b"
1.713 +    by (simp only: add.assoc)
1.714 +  then show "a \<le> b" by simp
1.715  qed
1.716
1.718
1.720 -  "b + a < b \<longleftrightarrow> a < 0"
1.721 +lemma add_less_same_cancel1 [simp]: "b + a < b \<longleftrightarrow> a < 0"
1.722    using add_less_cancel_left [of _ _ 0] by simp
1.723
1.725 -  "a + b < b \<longleftrightarrow> a < 0"
1.726 +lemma add_less_same_cancel2 [simp]: "a + b < b \<longleftrightarrow> a < 0"
1.727    using add_less_cancel_right [of _ _ 0] by simp
1.728
1.730 -  "a < a + b \<longleftrightarrow> 0 < b"
1.731 +lemma less_add_same_cancel1 [simp]: "a < a + b \<longleftrightarrow> 0 < b"
1.732    using add_less_cancel_left [of _ 0] by simp
1.733
1.735 -  "a < b + a \<longleftrightarrow> 0 < b"
1.736 +lemma less_add_same_cancel2 [simp]: "a < b + a \<longleftrightarrow> 0 < b"
1.737    using add_less_cancel_right [of 0] by simp
1.738
1.740 -  "b + a \<le> b \<longleftrightarrow> a \<le> 0"
1.741 +lemma add_le_same_cancel1 [simp]: "b + a \<le> b \<longleftrightarrow> a \<le> 0"
1.742    using add_le_cancel_left [of _ _ 0] by simp
1.743
1.745 -  "a + b \<le> b \<longleftrightarrow> a \<le> 0"
1.746 +lemma add_le_same_cancel2 [simp]: "a + b \<le> b \<longleftrightarrow> a \<le> 0"
1.747    using add_le_cancel_right [of _ _ 0] by simp
1.748
1.750 -  "a \<le> a + b \<longleftrightarrow> 0 \<le> b"
1.751 +lemma le_add_same_cancel1 [simp]: "a \<le> a + b \<longleftrightarrow> 0 \<le> b"
1.752    using add_le_cancel_left [of _ 0] by simp
1.753
1.755 -  "a \<le> b + a \<longleftrightarrow> 0 \<le> b"
1.756 +lemma le_add_same_cancel2 [simp]: "a \<le> b + a \<longleftrightarrow> 0 \<le> b"
1.757    using add_le_cancel_right [of 0] by simp
1.758
1.759 -lemma max_diff_distrib_left:
1.760 -  shows "max x y - z = max (x - z) (y - z)"
1.761 +lemma max_diff_distrib_left: "max x y - z = max (x - z) (y - z)"
1.762    using max_add_distrib_left [of x y "- z"] by simp
1.763
1.764 -lemma min_diff_distrib_left:
1.765 -  shows "min x y - z = min (x - z) (y - z)"
1.766 +lemma min_diff_distrib_left: "min x y - z = min (x - z) (y - z)"
1.767    using min_add_distrib_left [of x y "- z"] by simp
1.768
1.769  lemma le_imp_neg_le:
1.770 -  assumes "a \<le> b" shows "-b \<le> -a"
1.771 +  assumes "a \<le> b"
1.772 +  shows "- b \<le> - a"
1.773  proof -
1.774 -  have "-a+a \<le> -a+b" using \<open>a \<le> b\<close> by (rule add_left_mono)
1.775 -  then have "0 \<le> -a+b" by simp
1.776 -  then have "0 + (-b) \<le> (-a + b) + (-b)" by (rule add_right_mono)
1.777 -  then show ?thesis by (simp add: algebra_simps)
1.778 +  from assms have "- a + a \<le> - a + b"
1.780 +  then have "0 \<le> - a + b"
1.781 +    by simp
1.782 +  then have "0 + (- b) \<le> (- a + b) + (- b)"
1.784 +  then show ?thesis
1.785 +    by (simp add: algebra_simps)
1.786  qed
1.787
1.788  lemma neg_le_iff_le [simp]: "- b \<le> - a \<longleftrightarrow> a \<le> b"
1.789  proof
1.790    assume "- b \<le> - a"
1.791 -  hence "- (- a) \<le> - (- b)" by (rule le_imp_neg_le)
1.792 -  thus "a\<le>b" by simp
1.793 +  then have "- (- a) \<le> - (- b)"
1.794 +    by (rule le_imp_neg_le)
1.795 +  then show "a \<le> b"
1.796 +    by simp
1.797  next
1.798 -  assume "a\<le>b"
1.799 -  thus "-b \<le> -a" by (rule le_imp_neg_le)
1.800 +  assume "a \<le> b"
1.801 +  then show "- b \<le> - a"
1.802 +    by (rule le_imp_neg_le)
1.803  qed
1.804
1.805  lemma neg_le_0_iff_le [simp]: "- a \<le> 0 \<longleftrightarrow> 0 \<le> a"
1.806 -by (subst neg_le_iff_le [symmetric], simp)
1.807 +  by (subst neg_le_iff_le [symmetric]) simp
1.808
1.809  lemma neg_0_le_iff_le [simp]: "0 \<le> - a \<longleftrightarrow> a \<le> 0"
1.810 -by (subst neg_le_iff_le [symmetric], simp)
1.811 +  by (subst neg_le_iff_le [symmetric]) simp
1.812
1.813  lemma neg_less_iff_less [simp]: "- b < - a \<longleftrightarrow> a < b"
1.814 -by (force simp add: less_le)
1.815 +  by (auto simp add: less_le)
1.816
1.817  lemma neg_less_0_iff_less [simp]: "- a < 0 \<longleftrightarrow> 0 < a"
1.818 -by (subst neg_less_iff_less [symmetric], simp)
1.819 +  by (subst neg_less_iff_less [symmetric]) simp
1.820
1.821  lemma neg_0_less_iff_less [simp]: "0 < - a \<longleftrightarrow> a < 0"
1.822 -by (subst neg_less_iff_less [symmetric], simp)
1.823 +  by (subst neg_less_iff_less [symmetric]) simp
1.824
1.825 -text\<open>The next several equations can make the simplifier loop!\<close>
1.826 +text \<open>The next several equations can make the simplifier loop!\<close>
1.827
1.828  lemma less_minus_iff: "a < - b \<longleftrightarrow> b < - a"
1.829  proof -
1.830 -  have "(- (-a) < - b) = (b < - a)" by (rule neg_less_iff_less)
1.831 -  thus ?thesis by simp
1.832 +  have "- (-a) < - b \<longleftrightarrow> b < - a"
1.833 +    by (rule neg_less_iff_less)
1.834 +  then show ?thesis by simp
1.835  qed
1.836
1.837  lemma minus_less_iff: "- a < b \<longleftrightarrow> - b < a"
1.838  proof -
1.839 -  have "(- a < - (-b)) = (- b < a)" by (rule neg_less_iff_less)
1.840 -  thus ?thesis by simp
1.841 +  have "- a < - (- b) \<longleftrightarrow> - b < a"
1.842 +    by (rule neg_less_iff_less)
1.843 +  then show ?thesis by simp
1.844  qed
1.845
1.846  lemma le_minus_iff: "a \<le> - b \<longleftrightarrow> b \<le> - a"
1.847  proof -
1.848 -  have mm: "!! a (b::'a). (-(-a)) < -b \<Longrightarrow> -(-b) < -a" by (simp only: minus_less_iff)
1.849 -  have "(- (- a) <= -b) = (b <= - a)"
1.850 +  have mm: "- (- a) < -b \<Longrightarrow> - (- b) < -a" for a b :: 'a
1.851 +    by (simp only: minus_less_iff)
1.852 +  have "- (- a) \<le> -b \<longleftrightarrow> b \<le> - a"
1.853      apply (auto simp only: le_less)
1.854      apply (drule mm)
1.855      apply (simp_all)
1.856 @@ -915,60 +870,52 @@
1.857  qed
1.858
1.859  lemma minus_le_iff: "- a \<le> b \<longleftrightarrow> - b \<le> a"
1.860 -by (auto simp add: le_less minus_less_iff)
1.861 +  by (auto simp add: le_less minus_less_iff)
1.862
1.863 -lemma diff_less_0_iff_less [simp]:
1.864 -  "a - b < 0 \<longleftrightarrow> a < b"
1.865 +lemma diff_less_0_iff_less [simp]: "a - b < 0 \<longleftrightarrow> a < b"
1.866  proof -
1.867 -  have "a - b < 0 \<longleftrightarrow> a + (- b) < b + (- b)" by simp
1.868 -  also have "... \<longleftrightarrow> a < b" by (simp only: add_less_cancel_right)
1.869 +  have "a - b < 0 \<longleftrightarrow> a + (- b) < b + (- b)"
1.870 +    by simp
1.871 +  also have "\<dots> \<longleftrightarrow> a < b"
1.872 +    by (simp only: add_less_cancel_right)
1.873    finally show ?thesis .
1.874  qed
1.875
1.876  lemmas less_iff_diff_less_0 = diff_less_0_iff_less [symmetric]
1.877
1.878 -lemma diff_less_eq [algebra_simps, field_simps]:
1.879 -  "a - b < c \<longleftrightarrow> a < c + b"
1.880 -apply (subst less_iff_diff_less_0 [of a])
1.881 -apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst])
1.883 -done
1.884 +lemma diff_less_eq [algebra_simps, field_simps]: "a - b < c \<longleftrightarrow> a < c + b"
1.885 +  apply (subst less_iff_diff_less_0 [of a])
1.886 +  apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst])
1.887 +  apply (simp add: algebra_simps)
1.888 +  done
1.889
1.890 -lemma less_diff_eq[algebra_simps, field_simps]:
1.891 -  "a < c - b \<longleftrightarrow> a + b < c"
1.892 -apply (subst less_iff_diff_less_0 [of "a + b"])
1.893 -apply (subst less_iff_diff_less_0 [of a])
1.895 -done
1.896 +lemma less_diff_eq[algebra_simps, field_simps]: "a < c - b \<longleftrightarrow> a + b < c"
1.897 +  apply (subst less_iff_diff_less_0 [of "a + b"])
1.898 +  apply (subst less_iff_diff_less_0 [of a])
1.899 +  apply (simp add: algebra_simps)
1.900 +  done
1.901
1.902 -lemma diff_gt_0_iff_gt [simp]:
1.903 -  "a - b > 0 \<longleftrightarrow> a > b"
1.904 +lemma diff_gt_0_iff_gt [simp]: "a - b > 0 \<longleftrightarrow> a > b"
1.906
1.907 -lemma diff_le_eq [algebra_simps, field_simps]:
1.908 -  "a - b \<le> c \<longleftrightarrow> a \<le> c + b"
1.909 +lemma diff_le_eq [algebra_simps, field_simps]: "a - b \<le> c \<longleftrightarrow> a \<le> c + b"
1.910    by (auto simp add: le_less diff_less_eq )
1.911
1.912 -lemma le_diff_eq [algebra_simps, field_simps]:
1.913 -  "a \<le> c - b \<longleftrightarrow> a + b \<le> c"
1.914 +lemma le_diff_eq [algebra_simps, field_simps]: "a \<le> c - b \<longleftrightarrow> a + b \<le> c"
1.915    by (auto simp add: le_less less_diff_eq)
1.916
1.917 -lemma diff_le_0_iff_le [simp]:
1.918 -  "a - b \<le> 0 \<longleftrightarrow> a \<le> b"
1.919 +lemma diff_le_0_iff_le [simp]: "a - b \<le> 0 \<longleftrightarrow> a \<le> b"
1.921
1.922  lemmas le_iff_diff_le_0 = diff_le_0_iff_le [symmetric]
1.923
1.924 -lemma diff_ge_0_iff_ge [simp]:
1.925 -  "a - b \<ge> 0 \<longleftrightarrow> a \<ge> b"
1.926 +lemma diff_ge_0_iff_ge [simp]: "a - b \<ge> 0 \<longleftrightarrow> a \<ge> b"
1.928
1.929 -lemma diff_eq_diff_less:
1.930 -  "a - b = c - d \<Longrightarrow> a < b \<longleftrightarrow> c < d"
1.931 +lemma diff_eq_diff_less: "a - b = c - d \<Longrightarrow> a < b \<longleftrightarrow> c < d"
1.932    by (auto simp only: less_iff_diff_less_0 [of a b] less_iff_diff_less_0 [of c d])
1.933
1.934 -lemma diff_eq_diff_less_eq:
1.935 -  "a - b = c - d \<Longrightarrow> a \<le> b \<longleftrightarrow> c \<le> d"
1.936 +lemma diff_eq_diff_less_eq: "a - b = c - d \<Longrightarrow> a \<le> b \<longleftrightarrow> c \<le> d"
1.937    by (auto simp only: le_iff_diff_le_0 [of a b] le_iff_diff_le_0 [of c d])
1.938
1.939  lemma diff_mono: "a \<le> b \<Longrightarrow> d \<le> c \<Longrightarrow> a - c \<le> b - d"
1.940 @@ -1020,18 +967,18 @@
1.942  proof
1.943    fix a b c :: 'a
1.944 -  assume le: "c + a <= c + b"
1.945 -  show "a <= b"
1.946 +  assume le1: "c + a \<le> c + b"
1.947 +  show "a \<le> b"
1.948    proof (rule ccontr)
1.949 -    assume w: "~ a \<le> b"
1.950 -    hence "b <= a" by (simp add: linorder_not_le)
1.951 -    hence le2: "c + b <= c + a" by (rule add_left_mono)
1.952 +    assume *: "\<not> ?thesis"
1.953 +    then have "b \<le> a" by (simp add: linorder_not_le)
1.954 +    then have le2: "c + b \<le> c + a" by (rule add_left_mono)
1.955      have "a = b"
1.956 -      apply (insert le)
1.957 -      apply (insert le2)
1.958 -      apply (drule antisym, simp_all)
1.959 +      apply (insert le1 le2)
1.960 +      apply (drule antisym)
1.961 +      apply simp_all
1.962        done
1.963 -    with w show False
1.964 +    with * show False
1.965        by (simp add: linorder_not_le [symmetric])
1.966    qed
1.967  qed
1.968 @@ -1043,72 +990,71 @@
1.969
1.971
1.972 -lemma equal_neg_zero [simp]:
1.973 -  "a = - a \<longleftrightarrow> a = 0"
1.974 +lemma equal_neg_zero [simp]: "a = - a \<longleftrightarrow> a = 0"
1.975  proof
1.976 -  assume "a = 0" then show "a = - a" by simp
1.977 +  assume "a = 0"
1.978 +  then show "a = - a" by simp
1.979  next
1.980 -  assume A: "a = - a" show "a = 0"
1.981 +  assume A: "a = - a"
1.982 +  show "a = 0"
1.983    proof (cases "0 \<le> a")
1.984 -    case True with A have "0 \<le> - a" by auto
1.985 +    case True
1.986 +    with A have "0 \<le> - a" by auto
1.987      with le_minus_iff have "a \<le> 0" by simp
1.988      with True show ?thesis by (auto intro: order_trans)
1.989    next
1.990 -    case False then have B: "a \<le> 0" by auto
1.991 +    case False
1.992 +    then have B: "a \<le> 0" by auto
1.993      with A have "- a \<le> 0" by auto
1.994      with B show ?thesis by (auto intro: order_trans)
1.995    qed
1.996  qed
1.997
1.998 -lemma neg_equal_zero [simp]:
1.999 -  "- a = a \<longleftrightarrow> a = 0"
1.1000 +lemma neg_equal_zero [simp]: "- a = a \<longleftrightarrow> a = 0"
1.1001    by (auto dest: sym)
1.1002
1.1003 -lemma neg_less_eq_nonneg [simp]:
1.1004 -  "- a \<le> a \<longleftrightarrow> 0 \<le> a"
1.1005 +lemma neg_less_eq_nonneg [simp]: "- a \<le> a \<longleftrightarrow> 0 \<le> a"
1.1006  proof
1.1007 -  assume A: "- a \<le> a" show "0 \<le> a"
1.1008 +  assume *: "- a \<le> a"
1.1009 +  show "0 \<le> a"
1.1010    proof (rule classical)
1.1011 -    assume "\<not> 0 \<le> a"
1.1012 +    assume "\<not> ?thesis"
1.1013      then have "a < 0" by auto
1.1014 -    with A have "- a < 0" by (rule le_less_trans)
1.1015 +    with * have "- a < 0" by (rule le_less_trans)
1.1016      then show ?thesis by auto
1.1017    qed
1.1018  next
1.1019 -  assume A: "0 \<le> a" show "- a \<le> a"
1.1020 -  proof (rule order_trans)
1.1021 -    show "- a \<le> 0" using A by (simp add: minus_le_iff)
1.1022 -  next
1.1023 -    show "0 \<le> a" using A .
1.1024 -  qed
1.1025 +  assume *: "0 \<le> a"
1.1026 +  then have "- a \<le> 0" by (simp add: minus_le_iff)
1.1027 +  from this * show "- a \<le> a" by (rule order_trans)
1.1028  qed
1.1029
1.1030 -lemma neg_less_pos [simp]:
1.1031 -  "- a < a \<longleftrightarrow> 0 < a"
1.1032 +lemma neg_less_pos [simp]: "- a < a \<longleftrightarrow> 0 < a"
1.1033    by (auto simp add: less_le)
1.1034
1.1035 -lemma less_eq_neg_nonpos [simp]:
1.1036 -  "a \<le> - a \<longleftrightarrow> a \<le> 0"
1.1037 +lemma less_eq_neg_nonpos [simp]: "a \<le> - a \<longleftrightarrow> a \<le> 0"
1.1038    using neg_less_eq_nonneg [of "- a"] by simp
1.1039
1.1040 -lemma less_neg_neg [simp]:
1.1041 -  "a < - a \<longleftrightarrow> a < 0"
1.1042 +lemma less_neg_neg [simp]: "a < - a \<longleftrightarrow> a < 0"
1.1043    using neg_less_pos [of "- a"] by simp
1.1044
1.1045 -lemma double_zero [simp]:
1.1046 -  "a + a = 0 \<longleftrightarrow> a = 0"
1.1047 +lemma double_zero [simp]: "a + a = 0 \<longleftrightarrow> a = 0"
1.1048  proof
1.1049 -  assume assm: "a + a = 0"
1.1050 +  assume "a + a = 0"
1.1051    then have a: "- a = a" by (rule minus_unique)
1.1052    then show "a = 0" by (simp only: neg_equal_zero)
1.1053 -qed simp
1.1054 +next
1.1055 +  assume "a = 0"
1.1056 +  then show "a + a = 0" by simp
1.1057 +qed
1.1058
1.1059 -lemma double_zero_sym [simp]:
1.1060 -  "0 = a + a \<longleftrightarrow> a = 0"
1.1061 -  by (rule, drule sym) simp_all
1.1062 +lemma double_zero_sym [simp]: "0 = a + a \<longleftrightarrow> a = 0"
1.1063 +  apply (rule iffI)
1.1064 +  apply (drule sym)
1.1065 +  apply simp_all
1.1066 +  done
1.1067
1.1069 -  "0 < a + a \<longleftrightarrow> 0 < a"
1.1070 +lemma zero_less_double_add_iff_zero_less_single_add [simp]: "0 < a + a \<longleftrightarrow> 0 < a"
1.1071  proof
1.1072    assume "0 < a + a"
1.1073    then have "0 - a < a" by (simp only: diff_less_eq)
1.1074 @@ -1121,32 +1067,27 @@
1.1075    then show "0 < a + a" by simp
1.1076  qed
1.1077
1.1079 -  "0 \<le> a + a \<longleftrightarrow> 0 \<le> a"
1.1080 +lemma zero_le_double_add_iff_zero_le_single_add [simp]: "0 \<le> a + a \<longleftrightarrow> 0 \<le> a"
1.1081    by (auto simp add: le_less)
1.1082
1.1084 -  "a + a < 0 \<longleftrightarrow> a < 0"
1.1085 +lemma double_add_less_zero_iff_single_add_less_zero [simp]: "a + a < 0 \<longleftrightarrow> a < 0"
1.1086  proof -
1.1087    have "\<not> a + a < 0 \<longleftrightarrow> \<not> a < 0"
1.1089    then show ?thesis by simp
1.1090  qed
1.1091
1.1093 -  "a + a \<le> 0 \<longleftrightarrow> a \<le> 0"
1.1094 +lemma double_add_le_zero_iff_single_add_le_zero [simp]: "a + a \<le> 0 \<longleftrightarrow> a \<le> 0"
1.1095  proof -
1.1096    have "\<not> a + a \<le> 0 \<longleftrightarrow> \<not> a \<le> 0"
1.1098    then show ?thesis by simp
1.1099  qed
1.1100
1.1101 -lemma minus_max_eq_min:
1.1102 -  "- max x y = min (-x) (-y)"
1.1103 +lemma minus_max_eq_min: "- max x y = min (- x) (- y)"
1.1104    by (auto simp add: max_def min_def)
1.1105
1.1106 -lemma minus_min_eq_max:
1.1107 -  "- min x y = max (-x) (-y)"
1.1108 +lemma minus_min_eq_max: "- min x y = max (- x) (- y)"
1.1109    by (auto simp add: max_def min_def)
1.1110
1.1111  end
1.1112 @@ -1181,16 +1122,17 @@
1.1113    unfolding neg_le_0_iff_le by simp
1.1114
1.1115  lemma abs_of_nonneg [simp]:
1.1116 -  assumes nonneg: "0 \<le> a" shows "\<bar>a\<bar> = a"
1.1117 +  assumes nonneg: "0 \<le> a"
1.1118 +  shows "\<bar>a\<bar> = a"
1.1119  proof (rule antisym)
1.1120 +  show "a \<le> \<bar>a\<bar>" by (rule abs_ge_self)
1.1121    from nonneg le_imp_neg_le have "- a \<le> 0" by simp
1.1122    from this nonneg have "- a \<le> a" by (rule order_trans)
1.1123    then show "\<bar>a\<bar> \<le> a" by (auto intro: abs_leI)
1.1124 -qed (rule abs_ge_self)
1.1125 +qed
1.1126
1.1127  lemma abs_idempotent [simp]: "\<bar>\<bar>a\<bar>\<bar> = \<bar>a\<bar>"
1.1128 -by (rule antisym)
1.1129 -   (auto intro!: abs_ge_self abs_leI order_trans [of "- \<bar>a\<bar>" 0 "\<bar>a\<bar>"])
1.1130 +  by (rule antisym) (auto intro!: abs_ge_self abs_leI order_trans [of "- \<bar>a\<bar>" 0 "\<bar>a\<bar>"])
1.1131
1.1132  lemma abs_eq_0 [simp]: "\<bar>a\<bar> = 0 \<longleftrightarrow> a = 0"
1.1133  proof -
1.1134 @@ -1206,27 +1148,27 @@
1.1135  qed
1.1136
1.1137  lemma abs_zero [simp]: "\<bar>0\<bar> = 0"
1.1138 -by simp
1.1139 +  by simp
1.1140
1.1141  lemma abs_0_eq [simp]: "0 = \<bar>a\<bar> \<longleftrightarrow> a = 0"
1.1142  proof -
1.1143    have "0 = \<bar>a\<bar> \<longleftrightarrow> \<bar>a\<bar> = 0" by (simp only: eq_ac)
1.1144 -  thus ?thesis by simp
1.1145 +  then show ?thesis by simp
1.1146  qed
1.1147
1.1148  lemma abs_le_zero_iff [simp]: "\<bar>a\<bar> \<le> 0 \<longleftrightarrow> a = 0"
1.1149  proof
1.1150    assume "\<bar>a\<bar> \<le> 0"
1.1151    then have "\<bar>a\<bar> = 0" by (rule antisym) simp
1.1152 -  thus "a = 0" by simp
1.1153 +  then show "a = 0" by simp
1.1154  next
1.1155    assume "a = 0"
1.1156 -  thus "\<bar>a\<bar> \<le> 0" by simp
1.1157 +  then show "\<bar>a\<bar> \<le> 0" by simp
1.1158  qed
1.1159
1.1160  lemma abs_le_self_iff [simp]: "\<bar>a\<bar> \<le> a \<longleftrightarrow> 0 \<le> a"
1.1161  proof -
1.1162 -  have "\<forall>a. (0::'a) \<le> \<bar>a\<bar>"
1.1163 +  have "0 \<le> \<bar>a\<bar>"
1.1164      using abs_ge_zero by blast
1.1165    then have "\<bar>a\<bar> \<le> a \<Longrightarrow> 0 \<le> a"
1.1166      using order.trans by blast
1.1167 @@ -1235,12 +1177,12 @@
1.1168  qed
1.1169
1.1170  lemma zero_less_abs_iff [simp]: "0 < \<bar>a\<bar> \<longleftrightarrow> a \<noteq> 0"
1.1172 +  by (simp add: less_le)
1.1173
1.1174  lemma abs_not_less_zero [simp]: "\<not> \<bar>a\<bar> < 0"
1.1175  proof -
1.1176 -  have a: "\<And>x y. x \<le> y \<Longrightarrow> \<not> y < x" by auto
1.1177 -  show ?thesis by (simp add: a)
1.1178 +  have "x \<le> y \<Longrightarrow> \<not> y < x" for x y by auto
1.1179 +  then show ?thesis by simp
1.1180  qed
1.1181
1.1182  lemma abs_ge_minus_self: "- a \<le> \<bar>a\<bar>"
1.1183 @@ -1249,39 +1191,40 @@
1.1184    then show ?thesis by simp
1.1185  qed
1.1186
1.1187 -lemma abs_minus_commute:
1.1188 -  "\<bar>a - b\<bar> = \<bar>b - a\<bar>"
1.1189 +lemma abs_minus_commute: "\<bar>a - b\<bar> = \<bar>b - a\<bar>"
1.1190  proof -
1.1191 -  have "\<bar>a - b\<bar> = \<bar>- (a - b)\<bar>" by (simp only: abs_minus_cancel)
1.1192 -  also have "... = \<bar>b - a\<bar>" by simp
1.1193 +  have "\<bar>a - b\<bar> = \<bar>- (a - b)\<bar>"
1.1194 +    by (simp only: abs_minus_cancel)
1.1195 +  also have "\<dots> = \<bar>b - a\<bar>" by simp
1.1196    finally show ?thesis .
1.1197  qed
1.1198
1.1199  lemma abs_of_pos: "0 < a \<Longrightarrow> \<bar>a\<bar> = a"
1.1200 -by (rule abs_of_nonneg, rule less_imp_le)
1.1201 +  by (rule abs_of_nonneg) (rule less_imp_le)
1.1202
1.1203  lemma abs_of_nonpos [simp]:
1.1204 -  assumes "a \<le> 0" shows "\<bar>a\<bar> = - a"
1.1205 +  assumes "a \<le> 0"
1.1206 +  shows "\<bar>a\<bar> = - a"
1.1207  proof -
1.1208    let ?b = "- a"
1.1209    have "- ?b \<le> 0 \<Longrightarrow> \<bar>- ?b\<bar> = - (- ?b)"
1.1210 -  unfolding abs_minus_cancel [of "?b"]
1.1211 -  unfolding neg_le_0_iff_le [of "?b"]
1.1212 -  unfolding minus_minus by (erule abs_of_nonneg)
1.1213 +    unfolding abs_minus_cancel [of ?b]
1.1214 +    unfolding neg_le_0_iff_le [of ?b]
1.1215 +    unfolding minus_minus by (erule abs_of_nonneg)
1.1216    then show ?thesis using assms by auto
1.1217  qed
1.1218
1.1219  lemma abs_of_neg: "a < 0 \<Longrightarrow> \<bar>a\<bar> = - a"
1.1220 -by (rule abs_of_nonpos, rule less_imp_le)
1.1221 +  by (rule abs_of_nonpos) (rule less_imp_le)
1.1222
1.1223  lemma abs_le_D1: "\<bar>a\<bar> \<le> b \<Longrightarrow> a \<le> b"
1.1224 -by (insert abs_ge_self, blast intro: order_trans)
1.1225 +  using abs_ge_self by (blast intro: order_trans)
1.1226
1.1227  lemma abs_le_D2: "\<bar>a\<bar> \<le> b \<Longrightarrow> - a \<le> b"
1.1228 -by (insert abs_le_D1 [of "- a"], simp)
1.1229 +  using abs_le_D1 [of "- a"] by simp
1.1230
1.1231  lemma abs_le_iff: "\<bar>a\<bar> \<le> b \<longleftrightarrow> a \<le> b \<and> - a \<le> b"
1.1232 -by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2)
1.1233 +  by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2)
1.1234
1.1235  lemma abs_triangle_ineq2: "\<bar>a\<bar> - \<bar>b\<bar> \<le> \<bar>a - b\<bar>"
1.1236  proof -
1.1237 @@ -1301,24 +1244,27 @@
1.1238
1.1239  lemma abs_triangle_ineq4: "\<bar>a - b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>"
1.1240  proof -
1.1241 -  have "\<bar>a - b\<bar> = \<bar>a + - b\<bar>" by (simp add: algebra_simps)
1.1242 -  also have "... \<le> \<bar>a\<bar> + \<bar>- b\<bar>" by (rule abs_triangle_ineq)
1.1243 +  have "\<bar>a - b\<bar> = \<bar>a + - b\<bar>"
1.1244 +    by (simp add: algebra_simps)
1.1245 +  also have "\<dots> \<le> \<bar>a\<bar> + \<bar>- b\<bar>"
1.1246 +    by (rule abs_triangle_ineq)
1.1247    finally show ?thesis by simp
1.1248  qed
1.1249
1.1250  lemma abs_diff_triangle_ineq: "\<bar>a + b - (c + d)\<bar> \<le> \<bar>a - c\<bar> + \<bar>b - d\<bar>"
1.1251  proof -
1.1252 -  have "\<bar>a + b - (c+d)\<bar> = \<bar>(a-c) + (b-d)\<bar>" by (simp add: algebra_simps)
1.1253 -  also have "... \<le> \<bar>a-c\<bar> + \<bar>b-d\<bar>" by (rule abs_triangle_ineq)
1.1254 +  have "\<bar>a + b - (c + d)\<bar> = \<bar>(a - c) + (b - d)\<bar>"
1.1255 +    by (simp add: algebra_simps)
1.1256 +  also have "\<dots> \<le> \<bar>a - c\<bar> + \<bar>b - d\<bar>"
1.1257 +    by (rule abs_triangle_ineq)
1.1258    finally show ?thesis .
1.1259  qed
1.1260
1.1262 -  "\<bar>\<bar>a\<bar> + \<bar>b\<bar>\<bar> = \<bar>a\<bar> + \<bar>b\<bar>" (is "?L = ?R")
1.1263 +lemma abs_add_abs [simp]: "\<bar>\<bar>a\<bar> + \<bar>b\<bar>\<bar> = \<bar>a\<bar> + \<bar>b\<bar>"
1.1264 +  (is "?L = ?R")
1.1265  proof (rule antisym)
1.1266 -  show "?L \<ge> ?R" by(rule abs_ge_self)
1.1267 -next
1.1268 -  have "?L \<le> \<bar>\<bar>a\<bar>\<bar> + \<bar>\<bar>b\<bar>\<bar>" by(rule abs_triangle_ineq)
1.1269 +  show "?L \<ge> ?R" by (rule abs_ge_self)
1.1270 +  have "?L \<le> \<bar>\<bar>a\<bar>\<bar> + \<bar>\<bar>b\<bar>\<bar>" by (rule abs_triangle_ineq)
1.1271    also have "\<dots> = ?R" by simp
1.1272    finally show "?L \<le> ?R" .
1.1273  qed
1.1274 @@ -1327,8 +1273,9 @@
1.1275
1.1276  lemma dense_eq0_I:
1.1278 -  shows "(\<And>e. 0 < e \<Longrightarrow> \<bar>x\<bar> \<le> e) ==> x = 0"
1.1279 -  apply (cases "\<bar>x\<bar> = 0", simp)
1.1280 +  shows "(\<And>e. 0 < e \<Longrightarrow> \<bar>x\<bar> \<le> e) \<Longrightarrow> x = 0"
1.1281 +  apply (cases "\<bar>x\<bar> = 0")
1.1282 +  apply simp
1.1283    apply (simp only: zero_less_abs_iff [symmetric])
1.1284    apply (drule dense)
1.1285    apply (auto simp add: not_less [symmetric])
1.1286 @@ -1336,10 +1283,11 @@
1.1287
1.1289
1.1291 -lemmas mult_1 = mult_1_left \<comment> \<open>FIXME duplicate\<close>
1.1292 -lemmas ab_left_minus = left_minus \<comment> \<open>FIXME duplicate\<close>
1.1293 -lemmas diff_diff_eq = diff_diff_add \<comment> \<open>FIXME duplicate\<close>
1.1295 +lemmas mult_1 = mult_1_left (* FIXME duplicate *)
1.1296 +lemmas ab_left_minus = left_minus (* FIXME duplicate *)
1.1297 +lemmas diff_diff_eq = diff_diff_add (* FIXME duplicate *)
1.1298 +
1.1299
1.1300  subsection \<open>Canonically ordered monoids\<close>
1.1301
1.1302 @@ -1358,14 +1306,14 @@
1.1303  lemma not_less_zero[simp]: "\<not> n < 0"
1.1304    by (auto simp: less_le)
1.1305
1.1306 -lemma zero_less_iff_neq_zero: "(0 < n) \<longleftrightarrow> (n \<noteq> 0)"
1.1307 +lemma zero_less_iff_neq_zero: "0 < n \<longleftrightarrow> n \<noteq> 0"
1.1308    by (auto simp: less_le)
1.1309
1.1310  text \<open>This theorem is useful with \<open>blast\<close>\<close>
1.1311  lemma gr_zeroI: "(n = 0 \<Longrightarrow> False) \<Longrightarrow> 0 < n"
1.1312    by (rule zero_less_iff_neq_zero[THEN iffD2]) iprover
1.1313
1.1314 -lemma not_gr_zero[simp]: "(\<not> (0 < n)) \<longleftrightarrow> (n = 0)"
1.1315 +lemma not_gr_zero[simp]: "\<not> 0 < n \<longleftrightarrow> n = 0"
1.1317
1.1319 @@ -1388,54 +1336,48 @@
1.1320
1.1321  context
1.1322    fixes a b
1.1323 -  assumes "a \<le> b"
1.1324 +  assumes le: "a \<le> b"
1.1325  begin
1.1326
1.1328 -  "a + (b - a) = b"
1.1330 +lemma add_diff_inverse: "a + (b - a) = b"
1.1332
1.1334 -  "c + (b - a) = c + b - a"
1.1336 +lemma add_diff_assoc: "c + (b - a) = c + b - a"
1.1338
1.1340 -  "b - a + c = b + c - a"
1.1342 +lemma add_diff_assoc2: "b - a + c = b + c - a"
1.1344
1.1346 -  "c + b - a = c + (b - a)"
1.1348 +lemma diff_add_assoc: "c + b - a = c + (b - a)"
1.1350
1.1352 -  "b + c - a = b - a + c"
1.1354 +lemma diff_add_assoc2: "b + c - a = b - a + c"
1.1356
1.1357 -lemma diff_diff_right:
1.1358 -  "c - (b - a) = c + a - b"
1.1359 +lemma diff_diff_right: "c - (b - a) = c + a - b"
1.1361
1.1363 -  "b - a + a = b"
1.1364 +lemma diff_add: "b - a + a = b"
1.1366
1.1368 -  "c \<le> b + c - a"
1.1369 +lemma le_add_diff: "c \<le> b + c - a"
1.1371
1.1373 -  "a \<le> b \<Longrightarrow> b - a = c \<longleftrightarrow> b = c + a"
1.1374 +lemma le_imp_diff_is_add: "a \<le> b \<Longrightarrow> b - a = c \<longleftrightarrow> b = c + a"
1.1376
1.1377 -lemma le_diff_conv2:
1.1378 -  "c \<le> b - a \<longleftrightarrow> c + a \<le> b" (is "?P \<longleftrightarrow> ?Q")
1.1379 +lemma le_diff_conv2: "c \<le> b - a \<longleftrightarrow> c + a \<le> b"
1.1380 +  (is "?P \<longleftrightarrow> ?Q")
1.1381  proof
1.1382    assume ?P
1.1383 -  then have "c + a \<le> b - a + a" by (rule add_right_mono)
1.1385 +  then have "c + a \<le> b - a + a"
1.1387 +  then show ?Q
1.1389  next
1.1390    assume ?Q
1.1391 -  then have "a + c \<le> a + (b - a)" by (simp add: add_diff_inverse add.commute)
1.1392 +  then have "a + c \<le> a + (b - a)"
1.1394    then show ?P by simp
1.1395  qed
1.1396
1.1397 @@ -1443,6 +1385,7 @@
1.1398
1.1399  end
1.1400
1.1401 +
1.1402  subsection \<open>Tools setup\<close>
1.1403
1.1405 @@ -1451,7 +1394,7 @@
1.1406      and "i = j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l"
1.1407      and "i \<le> j \<and> k = l \<Longrightarrow> i + k \<le> j + l"
1.1408      and "i = j \<and> k = l \<Longrightarrow> i + k = j + l"
1.1410 +  by (rule add_mono, clarify+)+
1.1411
1.1413    fixes i j k :: "'a::ordered_cancel_ab_semigroup_add"
1.1414 @@ -1460,8 +1403,8 @@
1.1415      and "i < j \<and> k \<le> l \<Longrightarrow> i + k < j + l"
1.1416      and "i \<le> j \<and> k < l \<Longrightarrow> i + k < j + l"
1.1417      and "i < j \<and> k < l \<Longrightarrow> i + k < j + l"
1.1422
1.1423  code_identifier
1.1424    code_module Groups \<rightharpoonup> (SML) Arith and (OCaml) Arith and (Haskell) Arith

     2.1 --- a/src/HOL/Rings.thy	Mon Jun 20 17:51:47 2016 +0200
2.2 +++ b/src/HOL/Rings.thy	Mon Jun 20 21:40:48 2016 +0200
2.3 @@ -18,10 +18,9 @@
2.4    assumes distrib_left[algebra_simps]: "a * (b + c) = a * b + a * c"
2.5  begin
2.6
2.7 -text\<open>For the \<open>combine_numerals\<close> simproc\<close>
2.8 -lemma combine_common_factor:
2.9 -  "a * e + (b * e + c) = (a + b) * e + c"
2.10 -by (simp add: distrib_right ac_simps)
2.11 +text \<open>For the \<open>combine_numerals\<close> simproc\<close>
2.12 +lemma combine_common_factor: "a * e + (b * e + c) = (a + b) * e + c"
2.13 +  by (simp add: distrib_right ac_simps)
2.14
2.15  end
2.16
2.17 @@ -30,8 +29,7 @@
2.18    assumes mult_zero_right [simp]: "a * 0 = 0"
2.19  begin
2.20
2.21 -lemma mult_not_zero:
2.22 -  "a * b \<noteq> 0 \<Longrightarrow> a \<noteq> 0 \<and> b \<noteq> 0"
2.23 +lemma mult_not_zero: "a * b \<noteq> 0 \<Longrightarrow> a \<noteq> 0 \<and> b \<noteq> 0"
2.24    by auto
2.25
2.26  end
2.27 @@ -45,11 +43,9 @@
2.28  proof
2.29    fix a :: 'a
2.30    have "0 * a + 0 * a = 0 * a + 0" by (simp add: distrib_right [symmetric])
2.31 -  thus "0 * a = 0" by (simp only: add_left_cancel)
2.32 -next
2.33 -  fix a :: 'a
2.34 +  then show "0 * a = 0" by (simp only: add_left_cancel)
2.35    have "a * 0 + a * 0 = a * 0 + 0" by (simp add: distrib_left [symmetric])
2.36 -  thus "a * 0 = 0" by (simp only: add_left_cancel)
2.37 +  then show "a * 0 = 0" by (simp only: add_left_cancel)
2.38  qed
2.39
2.40  end
2.41 @@ -63,8 +59,8 @@
2.42    fix a b c :: 'a
2.43    show "(a + b) * c = a * c + b * c" by (simp add: distrib)
2.44    have "a * (b + c) = (b + c) * a" by (simp add: ac_simps)
2.45 -  also have "... = b * a + c * a" by (simp only: distrib)
2.46 -  also have "... = a * b + a * c" by (simp add: ac_simps)
2.47 +  also have "\<dots> = b * a + c * a" by (simp only: distrib)
2.48 +  also have "\<dots> = a * b + a * c" by (simp add: ac_simps)
2.49    finally show "a * (b + c) = a * b + a * c" by blast
2.50  qed
2.51
2.52 @@ -91,27 +87,23 @@
2.53  begin
2.54
2.55  lemma one_neq_zero [simp]: "1 \<noteq> 0"
2.56 -by (rule not_sym) (rule zero_neq_one)
2.57 +  by (rule not_sym) (rule zero_neq_one)
2.58
2.59  definition of_bool :: "bool \<Rightarrow> 'a"
2.60 -where
2.61 -  "of_bool p = (if p then 1 else 0)"
2.62 +  where "of_bool p = (if p then 1 else 0)"
2.63
2.64  lemma of_bool_eq [simp, code]:
2.65    "of_bool False = 0"
2.66    "of_bool True = 1"
2.68
2.69 -lemma of_bool_eq_iff:
2.70 -  "of_bool p = of_bool q \<longleftrightarrow> p = q"
2.71 +lemma of_bool_eq_iff: "of_bool p = of_bool q \<longleftrightarrow> p = q"
2.73
2.74 -lemma split_of_bool [split]:
2.75 -  "P (of_bool p) \<longleftrightarrow> (p \<longrightarrow> P 1) \<and> (\<not> p \<longrightarrow> P 0)"
2.76 +lemma split_of_bool [split]: "P (of_bool p) \<longleftrightarrow> (p \<longrightarrow> P 1) \<and> (\<not> p \<longrightarrow> P 0)"
2.77    by (cases p) simp_all
2.78
2.79 -lemma split_of_bool_asm:
2.80 -  "P (of_bool p) \<longleftrightarrow> \<not> (p \<and> \<not> P 1 \<or> \<not> p \<and> \<not> P 0)"
2.81 +lemma split_of_bool_asm: "P (of_bool p) \<longleftrightarrow> \<not> (p \<and> \<not> P 1 \<or> \<not> p \<and> \<not> P 0)"
2.82    by (cases p) simp_all
2.83
2.84  end
2.85 @@ -123,8 +115,8 @@
2.86  class dvd = times
2.87  begin
2.88
2.89 -definition dvd :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "dvd" 50) where
2.90 -  "b dvd a \<longleftrightarrow> (\<exists>k. a = b * k)"
2.91 +definition dvd :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "dvd" 50)
2.92 +  where "b dvd a \<longleftrightarrow> (\<exists>k. a = b * k)"
2.93
2.94  lemma dvdI [intro?]: "a = b * k \<Longrightarrow> b dvd a"
2.95    unfolding dvd_def ..
2.96 @@ -139,8 +131,7 @@
2.97
2.98  subclass dvd .
2.99
2.100 -lemma dvd_refl [simp]:
2.101 -  "a dvd a"
2.102 +lemma dvd_refl [simp]: "a dvd a"
2.103  proof
2.104    show "a = a * 1" by simp
2.105  qed
2.106 @@ -155,32 +146,25 @@
2.107    then show ?thesis ..
2.108  qed
2.109
2.110 -lemma subset_divisors_dvd:
2.111 -  "{c. c dvd a} \<subseteq> {c. c dvd b} \<longleftrightarrow> a dvd b"
2.112 +lemma subset_divisors_dvd: "{c. c dvd a} \<subseteq> {c. c dvd b} \<longleftrightarrow> a dvd b"
2.113    by (auto simp add: subset_iff intro: dvd_trans)
2.114
2.115 -lemma strict_subset_divisors_dvd:
2.116 -  "{c. c dvd a} \<subset> {c. c dvd b} \<longleftrightarrow> a dvd b \<and> \<not> b dvd a"
2.117 +lemma strict_subset_divisors_dvd: "{c. c dvd a} \<subset> {c. c dvd b} \<longleftrightarrow> a dvd b \<and> \<not> b dvd a"
2.118    by (auto simp add: subset_iff intro: dvd_trans)
2.119
2.120 -lemma one_dvd [simp]:
2.121 -  "1 dvd a"
2.122 +lemma one_dvd [simp]: "1 dvd a"
2.123    by (auto intro!: dvdI)
2.124
2.125 -lemma dvd_mult [simp]:
2.126 -  "a dvd c \<Longrightarrow> a dvd (b * c)"
2.127 +lemma dvd_mult [simp]: "a dvd c \<Longrightarrow> a dvd (b * c)"
2.128    by (auto intro!: mult.left_commute dvdI elim!: dvdE)
2.129
2.130 -lemma dvd_mult2 [simp]:
2.131 -  "a dvd b \<Longrightarrow> a dvd (b * c)"
2.132 +lemma dvd_mult2 [simp]: "a dvd b \<Longrightarrow> a dvd (b * c)"
2.133    using dvd_mult [of a b c] by (simp add: ac_simps)
2.134
2.135 -lemma dvd_triv_right [simp]:
2.136 -  "a dvd b * a"
2.137 +lemma dvd_triv_right [simp]: "a dvd b * a"
2.138    by (rule dvd_mult) (rule dvd_refl)
2.139
2.140 -lemma dvd_triv_left [simp]:
2.141 -  "a dvd a * b"
2.142 +lemma dvd_triv_left [simp]: "a dvd a * b"
2.143    by (rule dvd_mult2) (rule dvd_refl)
2.144
2.145  lemma mult_dvd_mono:
2.146 @@ -194,12 +178,10 @@
2.147    then show ?thesis ..
2.148  qed
2.149
2.150 -lemma dvd_mult_left:
2.151 -  "a * b dvd c \<Longrightarrow> a dvd c"
2.152 +lemma dvd_mult_left: "a * b dvd c \<Longrightarrow> a dvd c"
2.153    by (simp add: dvd_def mult.assoc) blast
2.154
2.155 -lemma dvd_mult_right:
2.156 -  "a * b dvd c \<Longrightarrow> b dvd c"
2.157 +lemma dvd_mult_right: "a * b dvd c \<Longrightarrow> b dvd c"
2.158    using dvd_mult_left [of b a c] by (simp add: ac_simps)
2.159
2.160  end
2.161 @@ -209,18 +191,15 @@
2.162
2.163  subclass semiring_1 ..
2.164
2.165 -lemma dvd_0_left_iff [simp]:
2.166 -  "0 dvd a \<longleftrightarrow> a = 0"
2.167 +lemma dvd_0_left_iff [simp]: "0 dvd a \<longleftrightarrow> a = 0"
2.168    by (auto intro: dvd_refl elim!: dvdE)
2.169
2.170 -lemma dvd_0_right [iff]:
2.171 -  "a dvd 0"
2.172 +lemma dvd_0_right [iff]: "a dvd 0"
2.173  proof
2.174    show "0 = a * 0" by simp
2.175  qed
2.176
2.177 -lemma dvd_0_left:
2.178 -  "0 dvd a \<Longrightarrow> a = 0"
2.179 +lemma dvd_0_left: "0 dvd a \<Longrightarrow> a = 0"
2.180    by simp
2.181
2.183 @@ -245,8 +224,8 @@
2.184
2.185  end
2.186
2.187 -class comm_semiring_1_cancel = comm_semiring + cancel_comm_monoid_add +
2.188 -                               zero_neq_one + comm_monoid_mult +
2.189 +class comm_semiring_1_cancel =
2.190 +  comm_semiring + cancel_comm_monoid_add + zero_neq_one + comm_monoid_mult +
2.191    assumes right_diff_distrib' [algebra_simps]: "a * (b - c) = a * b - a * c"
2.192  begin
2.193
2.194 @@ -254,16 +233,15 @@
2.195  subclass comm_semiring_0_cancel ..
2.196  subclass comm_semiring_1 ..
2.197
2.198 -lemma left_diff_distrib' [algebra_simps]:
2.199 -  "(b - c) * a = b * a - c * a"
2.200 +lemma left_diff_distrib' [algebra_simps]: "(b - c) * a = b * a - c * a"
2.202
2.204 -  "a dvd c * a + b \<longleftrightarrow> a dvd b"
2.205 +lemma dvd_add_times_triv_left_iff [simp]: "a dvd c * a + b \<longleftrightarrow> a dvd b"
2.206  proof -
2.207    have "a dvd a * c + b \<longleftrightarrow> a dvd b" (is "?P \<longleftrightarrow> ?Q")
2.208    proof
2.209 -    assume ?Q then show ?P by simp
2.210 +    assume ?Q
2.211 +    then show ?P by simp
2.212    next
2.213      assume ?P
2.214      then obtain d where "a * c + b = a * d" ..
2.215 @@ -275,23 +253,21 @@
2.216    then show "a dvd c * a + b \<longleftrightarrow> a dvd b" by (simp add: ac_simps)
2.217  qed
2.218
2.220 -  "a dvd b + c * a \<longleftrightarrow> a dvd b"
2.221 +lemma dvd_add_times_triv_right_iff [simp]: "a dvd b + c * a \<longleftrightarrow> a dvd b"
2.223
2.225 -  "a dvd a + b \<longleftrightarrow> a dvd b"
2.226 +lemma dvd_add_triv_left_iff [simp]: "a dvd a + b \<longleftrightarrow> a dvd b"
2.227    using dvd_add_times_triv_left_iff [of a 1 b] by simp
2.228
2.230 -  "a dvd b + a \<longleftrightarrow> a dvd b"
2.231 +lemma dvd_add_triv_right_iff [simp]: "a dvd b + a \<longleftrightarrow> a dvd b"
2.232    using dvd_add_times_triv_right_iff [of a b 1] by simp
2.233
2.235    assumes "a dvd b"
2.236    shows "a dvd b + c \<longleftrightarrow> a dvd c" (is "?P \<longleftrightarrow> ?Q")
2.237  proof
2.238 -  assume ?P then obtain d where "b + c = a * d" ..
2.239 +  assume ?P
2.240 +  then obtain d where "b + c = a * d" ..
2.241    moreover from \<open>a dvd b\<close> obtain e where "b = a * e" ..
2.242    ultimately have "a * e + c = a * d" by simp
2.243    then have "a * e + c - a * e = a * d - a * e" by simp
2.244 @@ -299,13 +275,12 @@
2.245    then have "c = a * (d - e)" by (simp add: algebra_simps)
2.246    then show ?Q ..
2.247  next
2.248 -  assume ?Q with assms show ?P by simp
2.249 +  assume ?Q
2.250 +  with assms show ?P by simp
2.251  qed
2.252
2.254 -  assumes "a dvd c"
2.255 -  shows "a dvd b + c \<longleftrightarrow> a dvd b"
2.256 -  using assms dvd_add_right_iff [of a c b] by (simp add: ac_simps)
2.257 +lemma dvd_add_left_iff: "a dvd c \<Longrightarrow> a dvd b + c \<longleftrightarrow> a dvd b"
2.258 +  using dvd_add_right_iff [of a c b] by (simp add: ac_simps)
2.259
2.260  end
2.261
2.262 @@ -317,44 +292,38 @@
2.263  text \<open>Distribution rules\<close>
2.264
2.265  lemma minus_mult_left: "- (a * b) = - a * b"
2.266 -by (rule minus_unique) (simp add: distrib_right [symmetric])
2.267 +  by (rule minus_unique) (simp add: distrib_right [symmetric])
2.268
2.269  lemma minus_mult_right: "- (a * b) = a * - b"
2.270 -by (rule minus_unique) (simp add: distrib_left [symmetric])
2.271 +  by (rule minus_unique) (simp add: distrib_left [symmetric])
2.272
2.273 -text\<open>Extract signs from products\<close>
2.274 +text \<open>Extract signs from products\<close>
2.275  lemmas mult_minus_left [simp] = minus_mult_left [symmetric]
2.276  lemmas mult_minus_right [simp] = minus_mult_right [symmetric]
2.277
2.278  lemma minus_mult_minus [simp]: "- a * - b = a * b"
2.279 -by simp
2.280 +  by simp
2.281
2.282  lemma minus_mult_commute: "- a * b = a * - b"
2.283 -by simp
2.284 +  by simp
2.285
2.286 -lemma right_diff_distrib [algebra_simps]:
2.287 -  "a * (b - c) = a * b - a * c"
2.288 +lemma right_diff_distrib [algebra_simps]: "a * (b - c) = a * b - a * c"
2.289    using distrib_left [of a b "-c "] by simp
2.290
2.291 -lemma left_diff_distrib [algebra_simps]:
2.292 -  "(a - b) * c = a * c - b * c"
2.293 +lemma left_diff_distrib [algebra_simps]: "(a - b) * c = a * c - b * c"
2.294    using distrib_right [of a "- b" c] by simp
2.295
2.296 -lemmas ring_distribs =
2.297 -  distrib_left distrib_right left_diff_distrib right_diff_distrib
2.298 +lemmas ring_distribs = distrib_left distrib_right left_diff_distrib right_diff_distrib
2.299
2.301 -  "a * e + c = b * e + d \<longleftrightarrow> (a - b) * e + c = d"
2.303 +lemma eq_add_iff1: "a * e + c = b * e + d \<longleftrightarrow> (a - b) * e + c = d"
2.304 +  by (simp add: algebra_simps)
2.305
2.307 -  "a * e + c = b * e + d \<longleftrightarrow> c = (b - a) * e + d"
2.309 +lemma eq_add_iff2: "a * e + c = b * e + d \<longleftrightarrow> c = (b - a) * e + d"
2.310 +  by (simp add: algebra_simps)
2.311
2.312  end
2.313
2.314 -lemmas ring_distribs =
2.315 -  distrib_left distrib_right left_diff_distrib right_diff_distrib
2.316 +lemmas ring_distribs = distrib_left distrib_right left_diff_distrib right_diff_distrib
2.317
2.318  class comm_ring = comm_semiring + ab_group_add
2.319  begin
2.320 @@ -362,8 +331,7 @@
2.321  subclass ring ..
2.322  subclass comm_semiring_0_cancel ..
2.323
2.324 -lemma square_diff_square_factored:
2.325 -  "x * x - y * y = (x + y) * (x - y)"
2.326 +lemma square_diff_square_factored: "x * x - y * y = (x + y) * (x - y)"
2.328
2.329  end
2.330 @@ -373,8 +341,7 @@
2.331
2.332  subclass semiring_1_cancel ..
2.333
2.334 -lemma square_diff_one_factored:
2.335 -  "x * x - 1 = (x + 1) * (x - 1)"
2.336 +lemma square_diff_one_factored: "x * x - 1 = (x + 1) * (x - 1)"
2.338
2.339  end
2.340 @@ -410,8 +377,7 @@
2.341    then show "- x dvd y" ..
2.342  qed
2.343
2.344 -lemma dvd_diff [simp]:
2.345 -  "x dvd y \<Longrightarrow> x dvd z \<Longrightarrow> x dvd (y - z)"
2.346 +lemma dvd_diff [simp]: "x dvd y \<Longrightarrow> x dvd z \<Longrightarrow> x dvd (y - z)"
2.347    using dvd_add [of x y "- z"] by simp
2.348
2.349  end
2.350 @@ -424,19 +390,20 @@
2.351    assumes "a * b = 0"
2.352    shows "a = 0 \<or> b = 0"
2.353  proof (rule classical)
2.354 -  assume "\<not> (a = 0 \<or> b = 0)"
2.355 +  assume "\<not> ?thesis"
2.356    then have "a \<noteq> 0" and "b \<noteq> 0" by auto
2.357    with no_zero_divisors have "a * b \<noteq> 0" by blast
2.358    with assms show ?thesis by simp
2.359  qed
2.360
2.361 -lemma mult_eq_0_iff [simp]:
2.362 -  shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
2.363 +lemma mult_eq_0_iff [simp]: "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
2.364  proof (cases "a = 0 \<or> b = 0")
2.365 -  case False then have "a \<noteq> 0" and "b \<noteq> 0" by auto
2.366 +  case False
2.367 +  then have "a \<noteq> 0" and "b \<noteq> 0" by auto
2.368      then show ?thesis using no_zero_divisors by simp
2.369  next
2.370 -  case True then show ?thesis by auto
2.371 +  case True
2.372 +  then show ?thesis by auto
2.373  qed
2.374
2.375  end
2.376 @@ -448,12 +415,10 @@
2.377      and mult_cancel_left [simp]: "c * a = c * b \<longleftrightarrow> c = 0 \<or> a = b"
2.378  begin
2.379
2.380 -lemma mult_left_cancel:
2.381 -  "c \<noteq> 0 \<Longrightarrow> c * a = c * b \<longleftrightarrow> a = b"
2.382 +lemma mult_left_cancel: "c \<noteq> 0 \<Longrightarrow> c * a = c * b \<longleftrightarrow> a = b"
2.383    by simp
2.384
2.385 -lemma mult_right_cancel:
2.386 -  "c \<noteq> 0 \<Longrightarrow> a * c = b * c \<longleftrightarrow> a = b"
2.387 +lemma mult_right_cancel: "c \<noteq> 0 \<Longrightarrow> a * c = b * c \<longleftrightarrow> a = b"
2.388    by simp
2.389
2.390  end
2.391 @@ -483,32 +448,27 @@
2.392
2.393  subclass semiring_1_no_zero_divisors ..
2.394
2.395 -lemma square_eq_1_iff:
2.396 -  "x * x = 1 \<longleftrightarrow> x = 1 \<or> x = - 1"
2.397 +lemma square_eq_1_iff: "x * x = 1 \<longleftrightarrow> x = 1 \<or> x = - 1"
2.398  proof -
2.399    have "(x - 1) * (x + 1) = x * x - 1"
2.401 -  hence "x * x = 1 \<longleftrightarrow> (x - 1) * (x + 1) = 0"
2.402 +  then have "x * x = 1 \<longleftrightarrow> (x - 1) * (x + 1) = 0"
2.403      by simp
2.404 -  thus ?thesis
2.405 +  then show ?thesis
2.407  qed
2.408
2.409 -lemma mult_cancel_right1 [simp]:
2.410 -  "c = b * c \<longleftrightarrow> c = 0 \<or> b = 1"
2.411 -by (insert mult_cancel_right [of 1 c b], force)
2.412 +lemma mult_cancel_right1 [simp]: "c = b * c \<longleftrightarrow> c = 0 \<or> b = 1"
2.413 +  using mult_cancel_right [of 1 c b] by auto
2.414
2.415 -lemma mult_cancel_right2 [simp]:
2.416 -  "a * c = c \<longleftrightarrow> c = 0 \<or> a = 1"
2.417 -by (insert mult_cancel_right [of a c 1], simp)
2.418 +lemma mult_cancel_right2 [simp]: "a * c = c \<longleftrightarrow> c = 0 \<or> a = 1"
2.419 +  using mult_cancel_right [of a c 1] by simp
2.420
2.421 -lemma mult_cancel_left1 [simp]:
2.422 -  "c = c * b \<longleftrightarrow> c = 0 \<or> b = 1"
2.423 -by (insert mult_cancel_left [of c 1 b], force)
2.424 +lemma mult_cancel_left1 [simp]: "c = c * b \<longleftrightarrow> c = 0 \<or> b = 1"
2.425 +  using mult_cancel_left [of c 1 b] by force
2.426
2.427 -lemma mult_cancel_left2 [simp]:
2.428 -  "c * a = c \<longleftrightarrow> c = 0 \<or> a = 1"
2.429 -by (insert mult_cancel_left [of c a 1], simp)
2.430 +lemma mult_cancel_left2 [simp]: "c * a = c \<longleftrightarrow> c = 0 \<or> a = 1"
2.431 +  using mult_cancel_left [of c a 1] by simp
2.432
2.433  end
2.434
2.435 @@ -526,8 +486,7 @@
2.436
2.437  subclass ring_1_no_zero_divisors ..
2.438
2.439 -lemma dvd_mult_cancel_right [simp]:
2.440 -  "a * c dvd b * c \<longleftrightarrow> c = 0 \<or> a dvd b"
2.441 +lemma dvd_mult_cancel_right [simp]: "a * c dvd b * c \<longleftrightarrow> c = 0 \<or> a dvd b"
2.442  proof -
2.443    have "a * c dvd b * c \<longleftrightarrow> (\<exists>k. b * c = (a * k) * c)"
2.444      unfolding dvd_def by (simp add: ac_simps)
2.445 @@ -536,8 +495,7 @@
2.446    finally show ?thesis .
2.447  qed
2.448
2.449 -lemma dvd_mult_cancel_left [simp]:
2.450 -  "c * a dvd c * b \<longleftrightarrow> c = 0 \<or> a dvd b"
2.451 +lemma dvd_mult_cancel_left [simp]: "c * a dvd c * b \<longleftrightarrow> c = 0 \<or> a dvd b"
2.452  proof -
2.453    have "c * a dvd c * b \<longleftrightarrow> (\<exists>k. b * c = (a * k) * c)"
2.454      unfolding dvd_def by (simp add: ac_simps)
2.455 @@ -562,15 +520,12 @@
2.456
2.457  text \<open>
2.458    The theory of partially ordered rings is taken from the books:
2.459 -  \begin{itemize}
2.460 -  \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979
2.461 -  \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
2.462 -  \end{itemize}
2.463 +    \<^item> \<^emph>\<open>Lattice Theory\<close> by Garret Birkhoff, American Mathematical Society, 1979
2.464 +    \<^item> \<^emph>\<open>Partially Ordered Algebraic Systems\<close>, Pergamon Press, 1963
2.465 +
2.466    Most of the used notions can also be looked up in
2.467 -  \begin{itemize}
2.468 -  \item @{url "http://www.mathworld.com"} by Eric Weisstein et. al.
2.469 -  \item \emph{Algebra I} by van der Waerden, Springer.
2.470 -  \end{itemize}
2.471 +    \<^item> @{url "http://www.mathworld.com"} by Eric Weisstein et. al.
2.472 +    \<^item> \<^emph>\<open>Algebra I\<close> by van der Waerden, Springer
2.473  \<close>
2.474
2.475  class divide =
2.476 @@ -605,49 +560,45 @@
2.477    assumes divide_zero [simp]: "a div 0 = 0"
2.478  begin
2.479
2.480 -lemma nonzero_mult_divide_cancel_left [simp]:
2.481 -  "a \<noteq> 0 \<Longrightarrow> (a * b) div a = b"
2.482 +lemma nonzero_mult_divide_cancel_left [simp]: "a \<noteq> 0 \<Longrightarrow> (a * b) div a = b"
2.483    using nonzero_mult_divide_cancel_right [of a b] by (simp add: ac_simps)
2.484
2.485  subclass semiring_no_zero_divisors_cancel
2.486  proof
2.487 -  fix a b c
2.488 -  { fix a b c
2.489 -    show "a * c = b * c \<longleftrightarrow> c = 0 \<or> a = b"
2.490 -    proof (cases "c = 0")
2.491 -      case True then show ?thesis by simp
2.492 -    next
2.493 -      case False
2.494 -      { assume "a * c = b * c"
2.495 -        then have "a * c div c = b * c div c"
2.496 -          by simp
2.497 -        with False have "a = b"
2.498 -          by simp
2.499 -      } then show ?thesis by auto
2.500 -    qed
2.501 -  }
2.502 -  from this [of a c b]
2.503 -  show "c * a = c * b \<longleftrightarrow> c = 0 \<or> a = b"
2.504 -    by (simp add: ac_simps)
2.505 +  show *: "a * c = b * c \<longleftrightarrow> c = 0 \<or> a = b" for a b c
2.506 +  proof (cases "c = 0")
2.507 +    case True
2.508 +    then show ?thesis by simp
2.509 +  next
2.510 +    case False
2.511 +    {
2.512 +      assume "a * c = b * c"
2.513 +      then have "a * c div c = b * c div c"
2.514 +        by simp
2.515 +      with False have "a = b"
2.516 +        by simp
2.517 +    }
2.518 +    then show ?thesis by auto
2.519 +  qed
2.520 +  show "c * a = c * b \<longleftrightarrow> c = 0 \<or> a = b" for a b c
2.521 +    using * [of a c b] by (simp add: ac_simps)
2.522  qed
2.523
2.524 -lemma div_self [simp]:
2.525 -  assumes "a \<noteq> 0"
2.526 -  shows "a div a = 1"
2.527 -  using assms nonzero_mult_divide_cancel_left [of a 1] by simp
2.528 +lemma div_self [simp]: "a \<noteq> 0 \<Longrightarrow> a div a = 1"
2.529 +  using nonzero_mult_divide_cancel_left [of a 1] by simp
2.530
2.531 -lemma divide_zero_left [simp]:
2.532 -  "0 div a = 0"
2.533 +lemma divide_zero_left [simp]: "0 div a = 0"
2.534  proof (cases "a = 0")
2.535 -  case True then show ?thesis by simp
2.536 +  case True
2.537 +  then show ?thesis by simp
2.538  next
2.539 -  case False then have "a * 0 div a = 0"
2.540 +  case False
2.541 +  then have "a * 0 div a = 0"
2.542      by (rule nonzero_mult_divide_cancel_left)
2.543    then show ?thesis by simp
2.544  qed
2.545
2.546 -lemma divide_1 [simp]:
2.547 -  "a div 1 = a"
2.548 +lemma divide_1 [simp]: "a div 1 = a"
2.549    using nonzero_mult_divide_cancel_left [of 1 a] by simp
2.550
2.551  end
2.552 @@ -668,11 +619,13 @@
2.553    assumes "a \<noteq> 0"
2.554    shows "a * b dvd a * c \<longleftrightarrow> b dvd c" (is "?P \<longleftrightarrow> ?Q")
2.555  proof
2.556 -  assume ?P then obtain d where "a * c = a * b * d" ..
2.557 +  assume ?P
2.558 +  then obtain d where "a * c = a * b * d" ..
2.559    with assms have "c = b * d" by (simp add: ac_simps)
2.560    then show ?Q ..
2.561  next
2.562 -  assume ?Q then obtain d where "c = b * d" ..
2.563 +  assume ?Q
2.564 +  then obtain d where "c = b * d" ..
2.565    then have "a * c = a * b * d" by (simp add: ac_simps)
2.566    then show ?P ..
2.567  qed
2.568 @@ -680,7 +633,7 @@
2.569  lemma dvd_times_right_cancel_iff [simp]:
2.570    assumes "a \<noteq> 0"
2.571    shows "b * a dvd c * a \<longleftrightarrow> b dvd c" (is "?P \<longleftrightarrow> ?Q")
2.572 -using dvd_times_left_cancel_iff [of a b c] assms by (simp add: ac_simps)
2.573 +  using dvd_times_left_cancel_iff [of a b c] assms by (simp add: ac_simps)
2.574
2.575  lemma div_dvd_iff_mult:
2.576    assumes "b \<noteq> 0" and "b dvd a"
2.577 @@ -702,7 +655,8 @@
2.578    assumes "a dvd b" and "a dvd c"
2.579    shows "b div a dvd c div a \<longleftrightarrow> b dvd c"
2.580  proof (cases "a = 0")
2.581 -  case True with assms show ?thesis by simp
2.582 +  case True
2.583 +  with assms show ?thesis by simp
2.584  next
2.585    case False
2.586    moreover from assms obtain k l where "b = a * k" and "c = a * l"
2.587 @@ -714,7 +668,8 @@
2.588    assumes "c dvd a" and "c dvd b"
2.589    shows "(a + b) div c = a div c + b div c"
2.590  proof (cases "c = 0")
2.591 -  case True then show ?thesis by simp
2.592 +  case True
2.593 +  then show ?thesis by simp
2.594  next
2.595    case False
2.596    moreover from assms obtain k l where "a = c * k" and "b = c * l"
2.597 @@ -729,7 +684,8 @@
2.598    assumes "b dvd a" and "d dvd c"
2.599    shows "(a div b) * (c div d) = (a * c) div (b * d)"
2.600  proof (cases "b = 0 \<or> c = 0")
2.601 -  case True with assms show ?thesis by auto
2.602 +  case True
2.603 +  with assms show ?thesis by auto
2.604  next
2.605    case False
2.606    moreover from assms obtain k l where "a = b * k" and "c = d * l"
2.607 @@ -748,42 +704,39 @@
2.608  next
2.609    assume "b div a = c"
2.610    then have "b div a * a = c * a" by simp
2.611 -  moreover from \<open>a \<noteq> 0\<close> \<open>a dvd b\<close> have "b div a * a = b"
2.612 +  moreover from assms have "b div a * a = b"
2.613      by (auto elim!: dvdE simp add: ac_simps)
2.614    ultimately show "b = c * a" by simp
2.615  qed
2.616
2.617 -lemma dvd_div_mult_self [simp]:
2.618 -  "a dvd b \<Longrightarrow> b div a * a = b"
2.619 +lemma dvd_div_mult_self [simp]: "a dvd b \<Longrightarrow> b div a * a = b"
2.620    by (cases "a = 0") (auto elim: dvdE simp add: ac_simps)
2.621
2.622 -lemma dvd_mult_div_cancel [simp]:
2.623 -  "a dvd b \<Longrightarrow> a * (b div a) = b"
2.624 +lemma dvd_mult_div_cancel [simp]: "a dvd b \<Longrightarrow> a * (b div a) = b"
2.625    using dvd_div_mult_self [of a b] by (simp add: ac_simps)
2.626
2.627  lemma div_mult_swap:
2.628    assumes "c dvd b"
2.629    shows "a * (b div c) = (a * b) div c"
2.630  proof (cases "c = 0")
2.631 -  case True then show ?thesis by simp
2.632 +  case True
2.633 +  then show ?thesis by simp
2.634  next
2.635 -  case False from assms obtain d where "b = c * d" ..
2.636 +  case False
2.637 +  from assms obtain d where "b = c * d" ..
2.638    moreover from False have "a * divide (d * c) c = ((a * d) * c) div c"
2.639      by simp
2.640    ultimately show ?thesis by (simp add: ac_simps)
2.641  qed
2.642
2.643 -lemma dvd_div_mult:
2.644 -  assumes "c dvd b"
2.645 -  shows "b div c * a = (b * a) div c"
2.646 -  using assms div_mult_swap [of c b a] by (simp add: ac_simps)
2.647 +lemma dvd_div_mult: "c dvd b \<Longrightarrow> b div c * a = (b * a) div c"
2.648 +  using div_mult_swap [of c b a] by (simp add: ac_simps)
2.649
2.650  lemma dvd_div_mult2_eq:
2.651    assumes "b * c dvd a"
2.652    shows "a div (b * c) = a div b div c"
2.653 -using assms proof
2.654 -  fix k
2.655 -  assume "a = b * c * k"
2.656 +proof -
2.657 +  from assms obtain k where "a = b * c * k" ..
2.658    then show ?thesis
2.659      by (cases "b = 0 \<or> c = 0") (auto, simp add: ac_simps)
2.660  qed
2.661 @@ -808,15 +761,12 @@
2.662  text \<open>Units: invertible elements in a ring\<close>
2.663
2.664  abbreviation is_unit :: "'a \<Rightarrow> bool"
2.665 -where
2.666 -  "is_unit a \<equiv> a dvd 1"
2.667 +  where "is_unit a \<equiv> a dvd 1"
2.668
2.669 -lemma not_is_unit_0 [simp]:
2.670 -  "\<not> is_unit 0"
2.671 +lemma not_is_unit_0 [simp]: "\<not> is_unit 0"
2.672    by simp
2.673
2.674 -lemma unit_imp_dvd [dest]:
2.675 -  "is_unit b \<Longrightarrow> b dvd a"
2.676 +lemma unit_imp_dvd [dest]: "is_unit b \<Longrightarrow> b dvd a"
2.677    by (rule dvd_trans [of _ 1]) simp_all
2.678
2.679  lemma unit_dvdE:
2.680 @@ -829,8 +779,7 @@
2.681    ultimately show thesis using that by blast
2.682  qed
2.683
2.684 -lemma dvd_unit_imp_unit:
2.685 -  "a dvd b \<Longrightarrow> is_unit b \<Longrightarrow> is_unit a"
2.686 +lemma dvd_unit_imp_unit: "a dvd b \<Longrightarrow> is_unit b \<Longrightarrow> is_unit a"
2.687    by (rule dvd_trans)
2.688
2.689  lemma unit_div_1_unit [simp, intro]:
2.690 @@ -849,27 +798,24 @@
2.691  proof (rule that)
2.692    define b where "b = 1 div a"
2.693    then show "1 div a = b" by simp
2.694 -  from b_def \<open>is_unit a\<close> show "is_unit b" by simp
2.695 -  from \<open>is_unit a\<close> and \<open>is_unit b\<close> show "a \<noteq> 0" and "b \<noteq> 0" by auto
2.696 -  from b_def \<open>is_unit a\<close> show "a * b = 1" by simp
2.697 +  from assms b_def show "is_unit b" by simp
2.698 +  with assms show "a \<noteq> 0" and "b \<noteq> 0" by auto
2.699 +  from assms b_def show "a * b = 1" by simp
2.700    then have "1 = a * b" ..
2.701    with b_def \<open>b \<noteq> 0\<close> show "1 div b = a" by simp
2.702 -  from \<open>is_unit a\<close> have "a dvd c" ..
2.703 +  from assms have "a dvd c" ..
2.704    then obtain d where "c = a * d" ..
2.705    with \<open>a \<noteq> 0\<close> \<open>a * b = 1\<close> show "c div a = c * b"
2.706      by (simp add: mult.assoc mult.left_commute [of a])
2.707  qed
2.708
2.709 -lemma unit_prod [intro]:
2.710 -  "is_unit a \<Longrightarrow> is_unit b \<Longrightarrow> is_unit (a * b)"
2.711 +lemma unit_prod [intro]: "is_unit a \<Longrightarrow> is_unit b \<Longrightarrow> is_unit (a * b)"
2.712    by (subst mult_1_left [of 1, symmetric]) (rule mult_dvd_mono)
2.713
2.714 -lemma is_unit_mult_iff:
2.715 -  "is_unit (a * b) \<longleftrightarrow> is_unit a \<and> is_unit b" (is "?P \<longleftrightarrow> ?Q")
2.716 +lemma is_unit_mult_iff: "is_unit (a * b) \<longleftrightarrow> is_unit a \<and> is_unit b"
2.717    by (auto dest: dvd_mult_left dvd_mult_right)
2.718
2.719 -lemma unit_div [intro]:
2.720 -  "is_unit a \<Longrightarrow> is_unit b \<Longrightarrow> is_unit (a div b)"
2.721 +lemma unit_div [intro]: "is_unit a \<Longrightarrow> is_unit b \<Longrightarrow> is_unit (a div b)"
2.722    by (erule is_unitE [of b a]) (simp add: ac_simps unit_prod)
2.723
2.724  lemma mult_unit_dvd_iff:
2.725 @@ -894,7 +840,8 @@
2.726    assume "a dvd c * b"
2.727    with assms have "c * b dvd c * (b * (1 div b))"
2.728      by (subst mult_assoc [symmetric]) simp
2.729 -  also from \<open>is_unit b\<close> have "b * (1 div b) = 1" by (rule is_unitE) simp
2.730 +  also from assms have "b * (1 div b) = 1"
2.731 +    by (rule is_unitE) simp
2.732    finally have "c * b dvd c" by simp
2.733    with \<open>a dvd c * b\<close> show "a dvd c" by (rule dvd_trans)
2.734  next
2.735 @@ -902,52 +849,40 @@
2.736    then show "a dvd c * b" by simp
2.737  qed
2.738
2.739 -lemma div_unit_dvd_iff:
2.740 -  "is_unit b \<Longrightarrow> a div b dvd c \<longleftrightarrow> a dvd c"
2.741 +lemma div_unit_dvd_iff: "is_unit b \<Longrightarrow> a div b dvd c \<longleftrightarrow> a dvd c"
2.742    by (erule is_unitE [of _ a]) (auto simp add: mult_unit_dvd_iff)
2.743
2.744 -lemma dvd_div_unit_iff:
2.745 -  "is_unit b \<Longrightarrow> a dvd c div b \<longleftrightarrow> a dvd c"
2.746 +lemma dvd_div_unit_iff: "is_unit b \<Longrightarrow> a dvd c div b \<longleftrightarrow> a dvd c"
2.747    by (erule is_unitE [of _ c]) (simp add: dvd_mult_unit_iff)
2.748
2.749  lemmas unit_dvd_iff = mult_unit_dvd_iff div_unit_dvd_iff
2.750 -  dvd_mult_unit_iff dvd_div_unit_iff \<comment> \<open>FIXME consider fact collection\<close>
2.751 +  dvd_mult_unit_iff dvd_div_unit_iff  (* FIXME consider named_theorems *)
2.752
2.753 -lemma unit_mult_div_div [simp]:
2.754 -  "is_unit a \<Longrightarrow> b * (1 div a) = b div a"
2.755 +lemma unit_mult_div_div [simp]: "is_unit a \<Longrightarrow> b * (1 div a) = b div a"
2.756    by (erule is_unitE [of _ b]) simp
2.757
2.758 -lemma unit_div_mult_self [simp]:
2.759 -  "is_unit a \<Longrightarrow> b div a * a = b"
2.760 +lemma unit_div_mult_self [simp]: "is_unit a \<Longrightarrow> b div a * a = b"
2.761    by (rule dvd_div_mult_self) auto
2.762
2.763 -lemma unit_div_1_div_1 [simp]:
2.764 -  "is_unit a \<Longrightarrow> 1 div (1 div a) = a"
2.765 +lemma unit_div_1_div_1 [simp]: "is_unit a \<Longrightarrow> 1 div (1 div a) = a"
2.766    by (erule is_unitE) simp
2.767
2.768 -lemma unit_div_mult_swap:
2.769 -  "is_unit c \<Longrightarrow> a * (b div c) = (a * b) div c"
2.770 +lemma unit_div_mult_swap: "is_unit c \<Longrightarrow> a * (b div c) = (a * b) div c"
2.771    by (erule unit_dvdE [of _ b]) (simp add: mult.left_commute [of _ c])
2.772
2.773 -lemma unit_div_commute:
2.774 -  "is_unit b \<Longrightarrow> (a div b) * c = (a * c) div b"
2.775 +lemma unit_div_commute: "is_unit b \<Longrightarrow> (a div b) * c = (a * c) div b"
2.776    using unit_div_mult_swap [of b c a] by (simp add: ac_simps)
2.777
2.778 -lemma unit_eq_div1:
2.779 -  "is_unit b \<Longrightarrow> a div b = c \<longleftrightarrow> a = c * b"
2.780 +lemma unit_eq_div1: "is_unit b \<Longrightarrow> a div b = c \<longleftrightarrow> a = c * b"
2.781    by (auto elim: is_unitE)
2.782
2.783 -lemma unit_eq_div2:
2.784 -  "is_unit b \<Longrightarrow> a = c div b \<longleftrightarrow> a * b = c"
2.785 +lemma unit_eq_div2: "is_unit b \<Longrightarrow> a = c div b \<longleftrightarrow> a * b = c"
2.786    using unit_eq_div1 [of b c a] by auto
2.787
2.788 -lemma unit_mult_left_cancel:
2.789 -  assumes "is_unit a"
2.790 -  shows "a * b = a * c \<longleftrightarrow> b = c" (is "?P \<longleftrightarrow> ?Q")
2.791 -  using assms mult_cancel_left [of a b c] by auto
2.792 +lemma unit_mult_left_cancel: "is_unit a \<Longrightarrow> a * b = a * c \<longleftrightarrow> b = c"
2.793 +  using mult_cancel_left [of a b c] by auto
2.794
2.795 -lemma unit_mult_right_cancel:
2.796 -  "is_unit a \<Longrightarrow> b * a = c * a \<longleftrightarrow> b = c"
2.797 +lemma unit_mult_right_cancel: "is_unit a \<Longrightarrow> b * a = c * a \<longleftrightarrow> b = c"
2.798    using unit_mult_left_cancel [of a b c] by (auto simp add: ac_simps)
2.799
2.800  lemma unit_div_cancel:
2.801 @@ -964,7 +899,8 @@
2.802    assumes "is_unit b" and "is_unit c"
2.803    shows "a div (b * c) = a div b div c"
2.804  proof -
2.805 -  from assms have "is_unit (b * c)" by (simp add: unit_prod)
2.806 +  from assms have "is_unit (b * c)"
2.807 +    by (simp add: unit_prod)
2.808    then have "b * c dvd a"
2.809      by (rule unit_imp_dvd)
2.810    then show ?thesis
2.811 @@ -1015,58 +951,57 @@
2.812    values rather than associated elements.
2.813  \<close>
2.814
2.815 -lemma unit_factor_dvd [simp]:
2.816 -  "a \<noteq> 0 \<Longrightarrow> unit_factor a dvd b"
2.817 +lemma unit_factor_dvd [simp]: "a \<noteq> 0 \<Longrightarrow> unit_factor a dvd b"
2.818    by (rule unit_imp_dvd) simp
2.819
2.820 -lemma unit_factor_self [simp]:
2.821 -  "unit_factor a dvd a"
2.822 +lemma unit_factor_self [simp]: "unit_factor a dvd a"
2.823    by (cases "a = 0") simp_all
2.824
2.825 -lemma normalize_mult_unit_factor [simp]:
2.826 -  "normalize a * unit_factor a = a"
2.827 +lemma normalize_mult_unit_factor [simp]: "normalize a * unit_factor a = a"
2.828    using unit_factor_mult_normalize [of a] by (simp add: ac_simps)
2.829
2.830 -lemma normalize_eq_0_iff [simp]:
2.831 -  "normalize a = 0 \<longleftrightarrow> a = 0" (is "?P \<longleftrightarrow> ?Q")
2.832 +lemma normalize_eq_0_iff [simp]: "normalize a = 0 \<longleftrightarrow> a = 0"
2.833 +  (is "?P \<longleftrightarrow> ?Q")
2.834  proof
2.835    assume ?P
2.836    moreover have "unit_factor a * normalize a = a" by simp
2.837    ultimately show ?Q by simp
2.838  next
2.839 -  assume ?Q then show ?P by simp
2.840 +  assume ?Q
2.841 +  then show ?P by simp
2.842  qed
2.843
2.844 -lemma unit_factor_eq_0_iff [simp]:
2.845 -  "unit_factor a = 0 \<longleftrightarrow> a = 0" (is "?P \<longleftrightarrow> ?Q")
2.846 +lemma unit_factor_eq_0_iff [simp]: "unit_factor a = 0 \<longleftrightarrow> a = 0"
2.847 +  (is "?P \<longleftrightarrow> ?Q")
2.848  proof
2.849    assume ?P
2.850    moreover have "unit_factor a * normalize a = a" by simp
2.851    ultimately show ?Q by simp
2.852  next
2.853 -  assume ?Q then show ?P by simp
2.854 +  assume ?Q
2.855 +  then show ?P by simp
2.856  qed
2.857
2.858  lemma is_unit_unit_factor:
2.859 -  assumes "is_unit a" shows "unit_factor a = a"
2.860 +  assumes "is_unit a"
2.861 +  shows "unit_factor a = a"
2.862  proof -
2.863    from assms have "normalize a = 1" by (rule is_unit_normalize)
2.864    moreover from unit_factor_mult_normalize have "unit_factor a * normalize a = a" .
2.865    ultimately show ?thesis by simp
2.866  qed
2.867
2.868 -lemma unit_factor_1 [simp]:
2.869 -  "unit_factor 1 = 1"
2.870 +lemma unit_factor_1 [simp]: "unit_factor 1 = 1"
2.871    by (rule is_unit_unit_factor) simp
2.872
2.873 -lemma normalize_1 [simp]:
2.874 -  "normalize 1 = 1"
2.875 +lemma normalize_1 [simp]: "normalize 1 = 1"
2.876    by (rule is_unit_normalize) simp
2.877
2.878 -lemma normalize_1_iff:
2.879 -  "normalize a = 1 \<longleftrightarrow> is_unit a" (is "?P \<longleftrightarrow> ?Q")
2.880 +lemma normalize_1_iff: "normalize a = 1 \<longleftrightarrow> is_unit a"
2.881 +  (is "?P \<longleftrightarrow> ?Q")
2.882  proof
2.883 -  assume ?Q then show ?P by (rule is_unit_normalize)
2.884 +  assume ?Q
2.885 +  then show ?P by (rule is_unit_normalize)
2.886  next
2.887    assume ?P
2.888    then have "a \<noteq> 0" by auto
2.889 @@ -1079,32 +1014,34 @@
2.890    ultimately show ?Q by simp
2.891  qed
2.892
2.893 -lemma div_normalize [simp]:
2.894 -  "a div normalize a = unit_factor a"
2.895 +lemma div_normalize [simp]: "a div normalize a = unit_factor a"
2.896  proof (cases "a = 0")
2.897 -  case True then show ?thesis by simp
2.898 +  case True
2.899 +  then show ?thesis by simp
2.900  next
2.901 -  case False then have "normalize a \<noteq> 0" by simp
2.902 +  case False
2.903 +  then have "normalize a \<noteq> 0" by simp
2.904    with nonzero_mult_divide_cancel_right
2.905    have "unit_factor a * normalize a div normalize a = unit_factor a" by blast
2.906    then show ?thesis by simp
2.907  qed
2.908
2.909 -lemma div_unit_factor [simp]:
2.910 -  "a div unit_factor a = normalize a"
2.911 +lemma div_unit_factor [simp]: "a div unit_factor a = normalize a"
2.912  proof (cases "a = 0")
2.913 -  case True then show ?thesis by simp
2.914 +  case True
2.915 +  then show ?thesis by simp
2.916  next
2.917 -  case False then have "unit_factor a \<noteq> 0" by simp
2.918 +  case False
2.919 +  then have "unit_factor a \<noteq> 0" by simp
2.920    with nonzero_mult_divide_cancel_left
2.921    have "unit_factor a * normalize a div unit_factor a = normalize a" by blast
2.922    then show ?thesis by simp
2.923  qed
2.924
2.925 -lemma normalize_div [simp]:
2.926 -  "normalize a div a = 1 div unit_factor a"
2.927 +lemma normalize_div [simp]: "normalize a div a = 1 div unit_factor a"
2.928  proof (cases "a = 0")
2.929 -  case True then show ?thesis by simp
2.930 +  case True
2.931 +  then show ?thesis by simp
2.932  next
2.933    case False
2.934    have "normalize a div a = normalize a div (unit_factor a * normalize a)"
2.935 @@ -1114,62 +1051,64 @@
2.936    finally show ?thesis .
2.937  qed
2.938
2.939 -lemma mult_one_div_unit_factor [simp]:
2.940 -  "a * (1 div unit_factor b) = a div unit_factor b"
2.941 +lemma mult_one_div_unit_factor [simp]: "a * (1 div unit_factor b) = a div unit_factor b"
2.942    by (cases "b = 0") simp_all
2.943
2.944 -lemma normalize_mult:
2.945 -  "normalize (a * b) = normalize a * normalize b"
2.946 +lemma normalize_mult: "normalize (a * b) = normalize a * normalize b"
2.947  proof (cases "a = 0 \<or> b = 0")
2.948 -  case True then show ?thesis by auto
2.949 +  case True
2.950 +  then show ?thesis by auto
2.951  next
2.952    case False
2.953    from unit_factor_mult_normalize have "unit_factor (a * b) * normalize (a * b) = a * b" .
2.954 -  then have "normalize (a * b) = a * b div unit_factor (a * b)" by simp
2.955 -  also have "\<dots> = a * b div unit_factor (b * a)" by (simp add: ac_simps)
2.956 +  then have "normalize (a * b) = a * b div unit_factor (a * b)"
2.957 +    by simp
2.958 +  also have "\<dots> = a * b div unit_factor (b * a)"
2.959 +    by (simp add: ac_simps)
2.960    also have "\<dots> = a * b div unit_factor b div unit_factor a"
2.961      using False by (simp add: unit_factor_mult is_unit_div_mult2_eq [symmetric])
2.962    also have "\<dots> = a * (b div unit_factor b) div unit_factor a"
2.963      using False by (subst unit_div_mult_swap) simp_all
2.964    also have "\<dots> = normalize a * normalize b"
2.965 -    using False by (simp add: mult.commute [of a] mult.commute [of "normalize a"] unit_div_mult_swap [symmetric])
2.966 +    using False
2.967 +    by (simp add: mult.commute [of a] mult.commute [of "normalize a"] unit_div_mult_swap [symmetric])
2.968    finally show ?thesis .
2.969  qed
2.970
2.971 -lemma unit_factor_idem [simp]:
2.972 -  "unit_factor (unit_factor a) = unit_factor a"
2.973 +lemma unit_factor_idem [simp]: "unit_factor (unit_factor a) = unit_factor a"
2.974    by (cases "a = 0") (auto intro: is_unit_unit_factor)
2.975
2.976 -lemma normalize_unit_factor [simp]:
2.977 -  "a \<noteq> 0 \<Longrightarrow> normalize (unit_factor a) = 1"
2.978 +lemma normalize_unit_factor [simp]: "a \<noteq> 0 \<Longrightarrow> normalize (unit_factor a) = 1"
2.979    by (rule is_unit_normalize) simp
2.980
2.981 -lemma normalize_idem [simp]:
2.982 -  "normalize (normalize a) = normalize a"
2.983 +lemma normalize_idem [simp]: "normalize (normalize a) = normalize a"
2.984  proof (cases "a = 0")
2.985 -  case True then show ?thesis by simp
2.986 +  case True
2.987 +  then show ?thesis by simp
2.988  next
2.989    case False
2.990 -  have "normalize a = normalize (unit_factor a * normalize a)" by simp
2.991 +  have "normalize a = normalize (unit_factor a * normalize a)"
2.992 +    by simp
2.993    also have "\<dots> = normalize (unit_factor a) * normalize (normalize a)"
2.994      by (simp only: normalize_mult)
2.995 -  finally show ?thesis using False by simp_all
2.996 +  finally show ?thesis
2.997 +    using False by simp_all
2.998  qed
2.999
2.1000  lemma unit_factor_normalize [simp]:
2.1001    assumes "a \<noteq> 0"
2.1002    shows "unit_factor (normalize a) = 1"
2.1003  proof -
2.1004 -  from assms have "normalize a \<noteq> 0" by simp
2.1005 +  from assms have *: "normalize a \<noteq> 0"
2.1006 +    by simp
2.1007    have "unit_factor (normalize a) * normalize (normalize a) = normalize a"
2.1008      by (simp only: unit_factor_mult_normalize)
2.1009    then have "unit_factor (normalize a) * normalize a = normalize a"
2.1010      by simp
2.1011 -  with \<open>normalize a \<noteq> 0\<close>
2.1012 -  have "unit_factor (normalize a) * normalize a div normalize a = normalize a div normalize a"
2.1013 +  with * have "unit_factor (normalize a) * normalize a div normalize a = normalize a div normalize a"
2.1014      by simp
2.1015 -  with \<open>normalize a \<noteq> 0\<close>
2.1016 -  show ?thesis by simp
2.1017 +  with * show ?thesis
2.1018 +    by simp
2.1019  qed
2.1020
2.1021  lemma dvd_unit_factor_div:
2.1022 @@ -1196,8 +1135,7 @@
2.1023      by (cases "b = 0") (simp_all add: normalize_mult)
2.1024  qed
2.1025
2.1026 -lemma normalize_dvd_iff [simp]:
2.1027 -  "normalize a dvd b \<longleftrightarrow> a dvd b"
2.1028 +lemma normalize_dvd_iff [simp]: "normalize a dvd b \<longleftrightarrow> a dvd b"
2.1029  proof -
2.1030    have "normalize a dvd b \<longleftrightarrow> unit_factor a * normalize a dvd b"
2.1031      using mult_unit_dvd_iff [of "unit_factor a" "normalize a" b]
2.1032 @@ -1205,8 +1143,7 @@
2.1033    then show ?thesis by simp
2.1034  qed
2.1035
2.1036 -lemma dvd_normalize_iff [simp]:
2.1037 -  "a dvd normalize b \<longleftrightarrow> a dvd b"
2.1038 +lemma dvd_normalize_iff [simp]: "a dvd normalize b \<longleftrightarrow> a dvd b"
2.1039  proof -
2.1040    have "a dvd normalize  b \<longleftrightarrow> a dvd normalize b * unit_factor b"
2.1041      using dvd_mult_unit_iff [of "unit_factor b" a "normalize b"]
2.1042 @@ -1226,36 +1163,38 @@
2.1043    assumes "a dvd b" and "b dvd a"
2.1044    shows "normalize a = normalize b"
2.1045  proof (cases "a = 0 \<or> b = 0")
2.1046 -  case True with assms show ?thesis by auto
2.1047 +  case True
2.1048 +  with assms show ?thesis by auto
2.1049  next
2.1050    case False
2.1051    from \<open>a dvd b\<close> obtain c where b: "b = a * c" ..
2.1052    moreover from \<open>b dvd a\<close> obtain d where a: "a = b * d" ..
2.1053 -  ultimately have "b * 1 = b * (c * d)" by (simp add: ac_simps)
2.1054 +  ultimately have "b * 1 = b * (c * d)"
2.1055 +    by (simp add: ac_simps)
2.1056    with False have "1 = c * d"
2.1057      unfolding mult_cancel_left by simp
2.1058 -  then have "is_unit c" and "is_unit d" by auto
2.1059 -  with a b show ?thesis by (simp add: normalize_mult is_unit_normalize)
2.1060 +  then have "is_unit c" and "is_unit d"
2.1061 +    by auto
2.1062 +  with a b show ?thesis
2.1063 +    by (simp add: normalize_mult is_unit_normalize)
2.1064  qed
2.1065
2.1066 -lemma associatedD1:
2.1067 -  "normalize a = normalize b \<Longrightarrow> a dvd b"
2.1068 +lemma associatedD1: "normalize a = normalize b \<Longrightarrow> a dvd b"
2.1069    using dvd_normalize_iff [of _ b, symmetric] normalize_dvd_iff [of a _, symmetric]
2.1070    by simp
2.1071
2.1072 -lemma associatedD2:
2.1073 -  "normalize a = normalize b \<Longrightarrow> b dvd a"
2.1074 +lemma associatedD2: "normalize a = normalize b \<Longrightarrow> b dvd a"
2.1075    using dvd_normalize_iff [of _ a, symmetric] normalize_dvd_iff [of b _, symmetric]
2.1076    by simp
2.1077
2.1078 -lemma associated_unit:
2.1079 -  "normalize a = normalize b \<Longrightarrow> is_unit a \<Longrightarrow> is_unit b"
2.1080 +lemma associated_unit: "normalize a = normalize b \<Longrightarrow> is_unit a \<Longrightarrow> is_unit b"
2.1081    using dvd_unit_imp_unit by (auto dest!: associatedD1 associatedD2)
2.1082
2.1083 -lemma associated_iff_dvd:
2.1084 -  "normalize a = normalize b \<longleftrightarrow> a dvd b \<and> b dvd a" (is "?P \<longleftrightarrow> ?Q")
2.1085 +lemma associated_iff_dvd: "normalize a = normalize b \<longleftrightarrow> a dvd b \<and> b dvd a"
2.1086 +  (is "?P \<longleftrightarrow> ?Q")
2.1087  proof
2.1088 -  assume ?Q then show ?P by (auto intro!: associatedI)
2.1089 +  assume ?Q
2.1090 +  then show ?P by (auto intro!: associatedI)
2.1091  next
2.1092    assume ?P
2.1093    then have "unit_factor a * normalize a = unit_factor a * normalize b"
2.1094 @@ -1264,7 +1203,8 @@
2.1096    show ?Q
2.1097    proof (cases "a = 0 \<or> b = 0")
2.1098 -    case True with \<open>?P\<close> show ?thesis by auto
2.1099 +    case True
2.1100 +    with \<open>?P\<close> show ?thesis by auto
2.1101    next
2.1102      case False
2.1103      then have "b dvd normalize b * unit_factor a" and "normalize b * unit_factor a dvd b"
2.1104 @@ -1291,38 +1231,38 @@
2.1105    assumes mult_right_mono: "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * c"
2.1106  begin
2.1107
2.1108 -lemma mult_mono:
2.1109 -  "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * d"
2.1110 -apply (erule mult_right_mono [THEN order_trans], assumption)
2.1111 -apply (erule mult_left_mono, assumption)
2.1112 -done
2.1113 +lemma mult_mono: "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * d"
2.1114 +  apply (erule (1) mult_right_mono [THEN order_trans])
2.1115 +  apply (erule (1) mult_left_mono)
2.1116 +  done
2.1117
2.1118 -lemma mult_mono':
2.1119 -  "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> a \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * d"
2.1120 -apply (rule mult_mono)
2.1121 -apply (fast intro: order_trans)+
2.1122 -done
2.1123 +lemma mult_mono': "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> a \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * d"
2.1124 +  apply (rule mult_mono)
2.1125 +  apply (fast intro: order_trans)+
2.1126 +  done
2.1127
2.1128  end
2.1129
2.1130  class ordered_semiring_0 = semiring_0 + ordered_semiring
2.1131  begin
2.1132
2.1133 -lemma mult_nonneg_nonneg[simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * b"
2.1134 -using mult_left_mono [of 0 b a] by simp
2.1135 +lemma mult_nonneg_nonneg [simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * b"
2.1136 +  using mult_left_mono [of 0 b a] by simp
2.1137
2.1138  lemma mult_nonneg_nonpos: "0 \<le> a \<Longrightarrow> b \<le> 0 \<Longrightarrow> a * b \<le> 0"
2.1139 -using mult_left_mono [of b 0 a] by simp
2.1140 +  using mult_left_mono [of b 0 a] by simp
2.1141
2.1142  lemma mult_nonpos_nonneg: "a \<le> 0 \<Longrightarrow> 0 \<le> b \<Longrightarrow> a * b \<le> 0"
2.1143 -using mult_right_mono [of a 0 b] by simp
2.1144 +  using mult_right_mono [of a 0 b] by simp
2.1145
2.1146  text \<open>Legacy - use \<open>mult_nonpos_nonneg\<close>\<close>
2.1147  lemma mult_nonneg_nonpos2: "0 \<le> a \<Longrightarrow> b \<le> 0 \<Longrightarrow> b * a \<le> 0"
2.1148 -by (drule mult_right_mono [of b 0], auto)
2.1149 +  apply (drule mult_right_mono [of b 0])
2.1150 +  apply auto
2.1151 +  done
2.1152
2.1153  lemma split_mult_neg_le: "(0 \<le> a \<and> b \<le> 0) \<or> (a \<le> 0 \<and> 0 \<le> b) \<Longrightarrow> a * b \<le> 0"
2.1154 -by (auto simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)
2.1155 +  by (auto simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)
2.1156
2.1157  end
2.1158
2.1159 @@ -1341,44 +1281,34 @@
2.1160
2.1162
2.1163 -lemma mult_left_less_imp_less:
2.1164 -  "c * a < c * b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b"
2.1165 -by (force simp add: mult_left_mono not_le [symmetric])
2.1166 +lemma mult_left_less_imp_less: "c * a < c * b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b"
2.1167 +  by (force simp add: mult_left_mono not_le [symmetric])
2.1168
2.1169 -lemma mult_right_less_imp_less:
2.1170 -  "a * c < b * c \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b"
2.1171 -by (force simp add: mult_right_mono not_le [symmetric])
2.1172 +lemma mult_right_less_imp_less: "a * c < b * c \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b"
2.1173 +  by (force simp add: mult_right_mono not_le [symmetric])
2.1174
2.1176 -  "a \<le> a + b \<longleftrightarrow> 0 \<le> b"
2.1177 +lemma less_eq_add_cancel_left_greater_eq_zero [simp]: "a \<le> a + b \<longleftrightarrow> 0 \<le> b"
2.1178    using add_le_cancel_left [of a 0 b] by simp
2.1179
2.1181 -  "a + b \<le> a \<longleftrightarrow> b \<le> 0"
2.1182 +lemma less_eq_add_cancel_left_less_eq_zero [simp]: "a + b \<le> a \<longleftrightarrow> b \<le> 0"
2.1183    using add_le_cancel_left [of a b 0] by simp
2.1184
2.1186 -  "a \<le> b + a \<longleftrightarrow> 0 \<le> b"
2.1187 +lemma less_eq_add_cancel_right_greater_eq_zero [simp]: "a \<le> b + a \<longleftrightarrow> 0 \<le> b"
2.1188    using add_le_cancel_right [of 0 a b] by simp
2.1189
2.1191 -  "b + a \<le> a \<longleftrightarrow> b \<le> 0"
2.1192 +lemma less_eq_add_cancel_right_less_eq_zero [simp]: "b + a \<le> a \<longleftrightarrow> b \<le> 0"
2.1193    using add_le_cancel_right [of b a 0] by simp
2.1194
2.1196 -  "a < a + b \<longleftrightarrow> 0 < b"
2.1197 +lemma less_add_cancel_left_greater_zero [simp]: "a < a + b \<longleftrightarrow> 0 < b"
2.1198    using add_less_cancel_left [of a 0 b] by simp
2.1199
2.1201 -  "a + b < a \<longleftrightarrow> b < 0"
2.1202 +lemma less_add_cancel_left_less_zero [simp]: "a + b < a \<longleftrightarrow> b < 0"
2.1203    using add_less_cancel_left [of a b 0] by simp
2.1204
2.1206 -  "a < b + a \<longleftrightarrow> 0 < b"
2.1207 +lemma less_add_cancel_right_greater_zero [simp]: "a < b + a \<longleftrightarrow> 0 < b"
2.1208    using add_less_cancel_right [of 0 a b] by simp
2.1209
2.1211 -  "b + a < a \<longleftrightarrow> b < 0"
2.1212 +lemma less_add_cancel_right_less_zero [simp]: "b + a < a \<longleftrightarrow> b < 0"
2.1213    using add_less_cancel_right [of b a 0] by simp
2.1214
2.1215  end
2.1216 @@ -1392,7 +1322,8 @@
2.1217  proof-
2.1218    from assms have "u * x + v * y \<le> u * a + v * a"
2.1220 -  thus ?thesis using assms unfolding distrib_right[symmetric] by simp
2.1221 +  with assms show ?thesis
2.1222 +    unfolding distrib_right[symmetric] by simp
2.1223  qed
2.1224
2.1225  end
2.1226 @@ -1416,80 +1347,79 @@
2.1227      using mult_strict_right_mono by (cases "c = 0") auto
2.1228  qed
2.1229
2.1230 -lemma mult_left_le_imp_le:
2.1231 -  "c * a \<le> c * b \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b"
2.1232 -by (force simp add: mult_strict_left_mono _not_less [symmetric])
2.1233 +lemma mult_left_le_imp_le: "c * a \<le> c * b \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b"
2.1234 +  by (auto simp add: mult_strict_left_mono _not_less [symmetric])
2.1235
2.1236 -lemma mult_right_le_imp_le:
2.1237 -  "a * c \<le> b * c \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b"
2.1238 -by (force simp add: mult_strict_right_mono not_less [symmetric])
2.1239 +lemma mult_right_le_imp_le: "a * c \<le> b * c \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b"
2.1240 +  by (auto simp add: mult_strict_right_mono not_less [symmetric])
2.1241
2.1242  lemma mult_pos_pos[simp]: "0 < a \<Longrightarrow> 0 < b \<Longrightarrow> 0 < a * b"
2.1243 -using mult_strict_left_mono [of 0 b a] by simp
2.1244 +  using mult_strict_left_mono [of 0 b a] by simp
2.1245
2.1246  lemma mult_pos_neg: "0 < a \<Longrightarrow> b < 0 \<Longrightarrow> a * b < 0"
2.1247 -using mult_strict_left_mono [of b 0 a] by simp
2.1248 +  using mult_strict_left_mono [of b 0 a] by simp
2.1249
2.1250  lemma mult_neg_pos: "a < 0 \<Longrightarrow> 0 < b \<Longrightarrow> a * b < 0"
2.1251 -using mult_strict_right_mono [of a 0 b] by simp
2.1252 +  using mult_strict_right_mono [of a 0 b] by simp
2.1253
2.1254  text \<open>Legacy - use \<open>mult_neg_pos\<close>\<close>
2.1255  lemma mult_pos_neg2: "0 < a \<Longrightarrow> b < 0 \<Longrightarrow> b * a < 0"
2.1256 -by (drule mult_strict_right_mono [of b 0], auto)
2.1257 -
2.1258 -lemma zero_less_mult_pos:
2.1259 -  "0 < a * b \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b"
2.1260 -apply (cases "b\<le>0")
2.1261 - apply (auto simp add: le_less not_less)
2.1262 -apply (drule_tac mult_pos_neg [of a b])
2.1263 - apply (auto dest: less_not_sym)
2.1264 -done
2.1265 +  apply (drule mult_strict_right_mono [of b 0])
2.1266 +  apply auto
2.1267 +  done
2.1268
2.1269 -lemma zero_less_mult_pos2:
2.1270 -  "0 < b * a \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b"
2.1271 -apply (cases "b\<le>0")
2.1272 - apply (auto simp add: le_less not_less)
2.1273 -apply (drule_tac mult_pos_neg2 [of a b])
2.1274 - apply (auto dest: less_not_sym)
2.1275 -done
2.1276 +lemma zero_less_mult_pos: "0 < a * b \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b"
2.1277 +  apply (cases "b \<le> 0")
2.1278 +   apply (auto simp add: le_less not_less)
2.1279 +  apply (drule_tac mult_pos_neg [of a b])
2.1280 +   apply (auto dest: less_not_sym)
2.1281 +  done
2.1282
2.1283 -text\<open>Strict monotonicity in both arguments\<close>
2.1284 +lemma zero_less_mult_pos2: "0 < b * a \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b"
2.1285 +  apply (cases "b \<le> 0")
2.1286 +   apply (auto simp add: le_less not_less)
2.1287 +  apply (drule_tac mult_pos_neg2 [of a b])
2.1288 +   apply (auto dest: less_not_sym)
2.1289 +  done
2.1290 +
2.1291 +text \<open>Strict monotonicity in both arguments\<close>
2.1292  lemma mult_strict_mono:
2.1293    assumes "a < b" and "c < d" and "0 < b" and "0 \<le> c"
2.1294    shows "a * c < b * d"
2.1295 -  using assms apply (cases "c=0")
2.1296 -  apply (simp)
2.1297 +  using assms
2.1298 +  apply (cases "c = 0")
2.1299 +  apply simp
2.1300    apply (erule mult_strict_right_mono [THEN less_trans])
2.1301 -  apply (force simp add: le_less)
2.1302 -  apply (erule mult_strict_left_mono, assumption)
2.1303 +  apply (auto simp add: le_less)
2.1304 +  apply (erule (1) mult_strict_left_mono)
2.1305    done
2.1306
2.1307 -text\<open>This weaker variant has more natural premises\<close>
2.1308 +text \<open>This weaker variant has more natural premises\<close>
2.1309  lemma mult_strict_mono':
2.1310    assumes "a < b" and "c < d" and "0 \<le> a" and "0 \<le> c"
2.1311    shows "a * c < b * d"
2.1312 -by (rule mult_strict_mono) (insert assms, auto)
2.1313 +  by (rule mult_strict_mono) (insert assms, auto)
2.1314
2.1315  lemma mult_less_le_imp_less:
2.1316    assumes "a < b" and "c \<le> d" and "0 \<le> a" and "0 < c"
2.1317    shows "a * c < b * d"
2.1318 -  using assms apply (subgoal_tac "a * c < b * c")
2.1319 +  using assms
2.1320 +  apply (subgoal_tac "a * c < b * c")
2.1321    apply (erule less_le_trans)
2.1322    apply (erule mult_left_mono)
2.1323    apply simp
2.1324 -  apply (erule mult_strict_right_mono)
2.1325 -  apply assumption
2.1326 +  apply (erule (1) mult_strict_right_mono)
2.1327    done
2.1328
2.1329  lemma mult_le_less_imp_less:
2.1330    assumes "a \<le> b" and "c < d" and "0 < a" and "0 \<le> c"
2.1331    shows "a * c < b * d"
2.1332 -  using assms apply (subgoal_tac "a * c \<le> b * c")
2.1333 +  using assms
2.1334 +  apply (subgoal_tac "a * c \<le> b * c")
2.1335    apply (erule le_less_trans)
2.1336    apply (erule mult_strict_left_mono)
2.1337    apply simp
2.1338 -  apply (erule mult_right_mono)
2.1339 -  apply simp
2.1340 +  apply (erule (1) mult_right_mono)
2.1341    done
2.1342
2.1343  end
2.1344 @@ -1504,9 +1434,9 @@
2.1345    shows "u * x + v * y < a"
2.1346  proof -
2.1347    from assms have "u * x + v * y < u * a + v * a"
2.1348 -    by (cases "u = 0")
2.1349 -       (auto intro!: add_less_le_mono mult_strict_left_mono mult_left_mono)
2.1350 -  thus ?thesis using assms unfolding distrib_right[symmetric] by simp
2.1351 +    by (cases "u = 0") (auto intro!: add_less_le_mono mult_strict_left_mono mult_left_mono)
2.1352 +  with assms show ?thesis
2.1353 +    unfolding distrib_right[symmetric] by simp
2.1354  qed
2.1355
2.1356  end
2.1357 @@ -1519,8 +1449,8 @@
2.1358  proof
2.1359    fix a b c :: 'a
2.1360    assume "a \<le> b" "0 \<le> c"
2.1361 -  thus "c * a \<le> c * b" by (rule comm_mult_left_mono)
2.1362 -  thus "a * c \<le> b * c" by (simp only: mult.commute)
2.1363 +  then show "c * a \<le> c * b" by (rule comm_mult_left_mono)
2.1364 +  then show "a * c \<le> b * c" by (simp only: mult.commute)
2.1365  qed
2.1366
2.1367  end
2.1368 @@ -1542,15 +1472,15 @@
2.1369  proof
2.1370    fix a b c :: 'a
2.1371    assume "a < b" "0 < c"
2.1372 -  thus "c * a < c * b" by (rule comm_mult_strict_left_mono)
2.1373 -  thus "a * c < b * c" by (simp only: mult.commute)
2.1374 +  then show "c * a < c * b" by (rule comm_mult_strict_left_mono)
2.1375 +  then show "a * c < b * c" by (simp only: mult.commute)
2.1376  qed
2.1377
2.1378  subclass ordered_cancel_comm_semiring
2.1379  proof
2.1380    fix a b c :: 'a
2.1381    assume "a \<le> b" "0 \<le> c"
2.1382 -  thus "c * a \<le> c * b"
2.1383 +  then show "c * a \<le> c * b"
2.1384      unfolding le_less
2.1385      using mult_strict_left_mono by (cases "c = 0") auto
2.1386  qed
2.1387 @@ -1562,40 +1492,33 @@
2.1388
2.1390
2.1392 -  "a * e + c < b * e + d \<longleftrightarrow> (a - b) * e + c < d"
2.1394 +lemma less_add_iff1: "a * e + c < b * e + d \<longleftrightarrow> (a - b) * e + c < d"
2.1395 +  by (simp add: algebra_simps)
2.1396
2.1398 -  "a * e + c < b * e + d \<longleftrightarrow> c < (b - a) * e + d"
2.1400 +lemma less_add_iff2: "a * e + c < b * e + d \<longleftrightarrow> c < (b - a) * e + d"
2.1401 +  by (simp add: algebra_simps)
2.1402
2.1404 -  "a * e + c \<le> b * e + d \<longleftrightarrow> (a - b) * e + c \<le> d"
2.1406 +lemma le_add_iff1: "a * e + c \<le> b * e + d \<longleftrightarrow> (a - b) * e + c \<le> d"
2.1407 +  by (simp add: algebra_simps)
2.1408
2.1410 -  "a * e + c \<le> b * e + d \<longleftrightarrow> c \<le> (b - a) * e + d"
2.1412 +lemma le_add_iff2: "a * e + c \<le> b * e + d \<longleftrightarrow> c \<le> (b - a) * e + d"
2.1413 +  by (simp add: algebra_simps)
2.1414
2.1415 -lemma mult_left_mono_neg:
2.1416 -  "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> c * a \<le> c * b"
2.1417 +lemma mult_left_mono_neg: "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> c * a \<le> c * b"
2.1418    apply (drule mult_left_mono [of _ _ "- c"])
2.1419    apply simp_all
2.1420    done
2.1421
2.1422 -lemma mult_right_mono_neg:
2.1423 -  "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> a * c \<le> b * c"
2.1424 +lemma mult_right_mono_neg: "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> a * c \<le> b * c"
2.1425    apply (drule mult_right_mono [of _ _ "- c"])
2.1426    apply simp_all
2.1427    done
2.1428
2.1429  lemma mult_nonpos_nonpos: "a \<le> 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> 0 \<le> a * b"
2.1430 -using mult_right_mono_neg [of a 0 b] by simp
2.1431 +  using mult_right_mono_neg [of a 0 b] by simp
2.1432
2.1433 -lemma split_mult_pos_le:
2.1434 -  "(0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0) \<Longrightarrow> 0 \<le> a * b"
2.1435 -by (auto simp add: mult_nonpos_nonpos)
2.1436 +lemma split_mult_pos_le: "(0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0) \<Longrightarrow> 0 \<le> a * b"
2.1437 +  by (auto simp add: mult_nonpos_nonpos)
2.1438
2.1439  end
2.1440
2.1441 @@ -1608,12 +1531,12 @@
2.1442  proof
2.1443    fix a b
2.1444    show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>"
2.1446 +    by (auto simp add: abs_if not_le not_less algebra_simps
2.1448  qed (auto simp add: abs_if)
2.1449
2.1450  lemma zero_le_square [simp]: "0 \<le> a * a"
2.1451 -  using linear [of 0 a]
2.1452 -  by (auto simp add: mult_nonpos_nonpos)
2.1453 +  using linear [of 0 a] by (auto simp add: mult_nonpos_nonpos)
2.1454
2.1455  lemma not_square_less_zero [simp]: "\<not> (a * a < 0)"
2.1457 @@ -1621,12 +1544,10 @@
2.1458  proposition abs_eq_iff: "\<bar>x\<bar> = \<bar>y\<bar> \<longleftrightarrow> x = y \<or> x = -y"
2.1459    by (auto simp add: abs_if split: if_split_asm)
2.1460
2.1461 -lemma sum_squares_ge_zero:
2.1462 -  "0 \<le> x * x + y * y"
2.1463 +lemma sum_squares_ge_zero: "0 \<le> x * x + y * y"
2.1465
2.1466 -lemma not_sum_squares_lt_zero:
2.1467 -  "\<not> x * x + y * y < 0"
2.1468 +lemma not_sum_squares_lt_zero: "\<not> x * x + y * y < 0"
2.1469    by (simp add: not_less sum_squares_ge_zero)
2.1470
2.1471  end
2.1472 @@ -1638,40 +1559,49 @@
2.1473  subclass linordered_ring ..
2.1474
2.1475  lemma mult_strict_left_mono_neg: "b < a \<Longrightarrow> c < 0 \<Longrightarrow> c * a < c * b"
2.1476 -using mult_strict_left_mono [of b a "- c"] by simp
2.1477 +  using mult_strict_left_mono [of b a "- c"] by simp
2.1478
2.1479  lemma mult_strict_right_mono_neg: "b < a \<Longrightarrow> c < 0 \<Longrightarrow> a * c < b * c"
2.1480 -using mult_strict_right_mono [of b a "- c"] by simp
2.1481 +  using mult_strict_right_mono [of b a "- c"] by simp
2.1482
2.1483  lemma mult_neg_neg: "a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> 0 < a * b"
2.1484 -using mult_strict_right_mono_neg [of a 0 b] by simp
2.1485 +  using mult_strict_right_mono_neg [of a 0 b] by simp
2.1486
2.1487  subclass ring_no_zero_divisors
2.1488  proof
2.1489    fix a b
2.1490 -  assume "a \<noteq> 0" then have A: "a < 0 \<or> 0 < a" by (simp add: neq_iff)
2.1491 -  assume "b \<noteq> 0" then have B: "b < 0 \<or> 0 < b" by (simp add: neq_iff)
2.1492 +  assume "a \<noteq> 0"
2.1493 +  then have A: "a < 0 \<or> 0 < a" by (simp add: neq_iff)
2.1494 +  assume "b \<noteq> 0"
2.1495 +  then have B: "b < 0 \<or> 0 < b" by (simp add: neq_iff)
2.1496    have "a * b < 0 \<or> 0 < a * b"
2.1497    proof (cases "a < 0")
2.1498 -    case True note A' = this
2.1499 -    show ?thesis proof (cases "b < 0")
2.1500 -      case True with A'
2.1501 -      show ?thesis by (auto dest: mult_neg_neg)
2.1502 +    case A': True
2.1503 +    show ?thesis
2.1504 +    proof (cases "b < 0")
2.1505 +      case True
2.1506 +      with A' show ?thesis by (auto dest: mult_neg_neg)
2.1507      next
2.1508 -      case False with B have "0 < b" by auto
2.1509 +      case False
2.1510 +      with B have "0 < b" by auto
2.1511        with A' show ?thesis by (auto dest: mult_strict_right_mono)
2.1512      qed
2.1513    next
2.1514 -    case False with A have A': "0 < a" by auto
2.1515 -    show ?thesis proof (cases "b < 0")
2.1516 -      case True with A'
2.1517 -      show ?thesis by (auto dest: mult_strict_right_mono_neg)
2.1518 +    case False
2.1519 +    with A have A': "0 < a" by auto
2.1520 +    show ?thesis
2.1521 +    proof (cases "b < 0")
2.1522 +      case True
2.1523 +      with A' show ?thesis
2.1524 +        by (auto dest: mult_strict_right_mono_neg)
2.1525      next
2.1526 -      case False with B have "0 < b" by auto
2.1527 +      case False
2.1528 +      with B have "0 < b" by auto
2.1529        with A' show ?thesis by auto
2.1530      qed
2.1531    qed
2.1532 -  then show "a * b \<noteq> 0" by (simp add: neq_iff)
2.1533 +  then show "a * b \<noteq> 0"
2.1534 +    by (simp add: neq_iff)
2.1535  qed
2.1536
2.1537  lemma zero_less_mult_iff: "0 < a * b \<longleftrightarrow> 0 < a \<and> 0 < b \<or> a < 0 \<and> b < 0"
2.1538 @@ -1681,84 +1611,66 @@
2.1539  lemma zero_le_mult_iff: "0 \<le> a * b \<longleftrightarrow> 0 \<le> a \<and> 0 \<le> b \<or> a \<le> 0 \<and> b \<le> 0"
2.1540    by (auto simp add: eq_commute [of 0] le_less not_less zero_less_mult_iff)
2.1541
2.1542 -lemma mult_less_0_iff:
2.1543 -  "a * b < 0 \<longleftrightarrow> 0 < a \<and> b < 0 \<or> a < 0 \<and> 0 < b"
2.1544 -  apply (insert zero_less_mult_iff [of "-a" b])
2.1545 -  apply force
2.1546 -  done
2.1547 +lemma mult_less_0_iff: "a * b < 0 \<longleftrightarrow> 0 < a \<and> b < 0 \<or> a < 0 \<and> 0 < b"
2.1548 +  using zero_less_mult_iff [of "- a" b] by auto
2.1549
2.1550 -lemma mult_le_0_iff:
2.1551 -  "a * b \<le> 0 \<longleftrightarrow> 0 \<le> a \<and> b \<le> 0 \<or> a \<le> 0 \<and> 0 \<le> b"
2.1552 -  apply (insert zero_le_mult_iff [of "-a" b])
2.1553 -  apply force
2.1554 -  done
2.1555 +lemma mult_le_0_iff: "a * b \<le> 0 \<longleftrightarrow> 0 \<le> a \<and> b \<le> 0 \<or> a \<le> 0 \<and> 0 \<le> b"
2.1556 +  using zero_le_mult_iff [of "- a" b] by auto
2.1557
2.1558 -text\<open>Cancellation laws for @{term "c*a < c*b"} and @{term "a*c < b*c"},
2.1559 -   also with the relations \<open>\<le>\<close> and equality.\<close>
2.1560 +text \<open>
2.1561 +  Cancellation laws for @{term "c * a < c * b"} and @{term "a * c < b * c"},
2.1562 +  also with the relations \<open>\<le>\<close> and equality.
2.1563 +\<close>
2.1564
2.1565 -text\<open>These disjunction'' versions produce two cases when the comparison is
2.1566 - an assumption, but effectively four when the comparison is a goal.\<close>
2.1567 +text \<open>
2.1568 +  These disjunction'' versions produce two cases when the comparison is
2.1569 +  an assumption, but effectively four when the comparison is a goal.
2.1570 +\<close>
2.1571
2.1572 -lemma mult_less_cancel_right_disj:
2.1573 -  "a * c < b * c \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and>  b < a"
2.1574 +lemma mult_less_cancel_right_disj: "a * c < b * c \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and>  b < a"
2.1575    apply (cases "c = 0")
2.1576 -  apply (auto simp add: neq_iff mult_strict_right_mono
2.1577 -                      mult_strict_right_mono_neg)
2.1578 -  apply (auto simp add: not_less
2.1579 -                      not_le [symmetric, of "a*c"]
2.1580 -                      not_le [symmetric, of a])
2.1581 +  apply (auto simp add: neq_iff mult_strict_right_mono mult_strict_right_mono_neg)
2.1582 +  apply (auto simp add: not_less not_le [symmetric, of "a*c"] not_le [symmetric, of a])
2.1583    apply (erule_tac [!] notE)
2.1584 -  apply (auto simp add: less_imp_le mult_right_mono
2.1585 -                      mult_right_mono_neg)
2.1586 +  apply (auto simp add: less_imp_le mult_right_mono mult_right_mono_neg)
2.1587    done
2.1588
2.1589 -lemma mult_less_cancel_left_disj:
2.1590 -  "c * a < c * b \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and>  b < a"
2.1591 +lemma mult_less_cancel_left_disj: "c * a < c * b \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and>  b < a"
2.1592    apply (cases "c = 0")
2.1593 -  apply (auto simp add: neq_iff mult_strict_left_mono
2.1594 -                      mult_strict_left_mono_neg)
2.1595 -  apply (auto simp add: not_less
2.1596 -                      not_le [symmetric, of "c*a"]
2.1597 -                      not_le [symmetric, of a])
2.1598 +  apply (auto simp add: neq_iff mult_strict_left_mono mult_strict_left_mono_neg)
2.1599 +  apply (auto simp add: not_less not_le [symmetric, of "c * a"] not_le [symmetric, of a])
2.1600    apply (erule_tac [!] notE)
2.1601 -  apply (auto simp add: less_imp_le mult_left_mono
2.1602 -                      mult_left_mono_neg)
2.1603 +  apply (auto simp add: less_imp_le mult_left_mono mult_left_mono_neg)
2.1604    done
2.1605
2.1606 -text\<open>The conjunction of implication'' lemmas produce two cases when the
2.1607 -comparison is a goal, but give four when the comparison is an assumption.\<close>
2.1608 +text \<open>
2.1609 +  The conjunction of implication'' lemmas produce two cases when the
2.1610 +  comparison is a goal, but give four when the comparison is an assumption.
2.1611 +\<close>
2.1612
2.1613 -lemma mult_less_cancel_right:
2.1614 -  "a * c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)"
2.1615 +lemma mult_less_cancel_right: "a * c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)"
2.1616    using mult_less_cancel_right_disj [of a c b] by auto
2.1617
2.1618 -lemma mult_less_cancel_left:
2.1619 -  "c * a < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)"
2.1620 +lemma mult_less_cancel_left: "c * a < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)"
2.1621    using mult_less_cancel_left_disj [of c a b] by auto
2.1622
2.1623 -lemma mult_le_cancel_right:
2.1624 -   "a * c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
2.1625 -by (simp add: not_less [symmetric] mult_less_cancel_right_disj)
2.1626 +lemma mult_le_cancel_right: "a * c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
2.1627 +  by (simp add: not_less [symmetric] mult_less_cancel_right_disj)
2.1628
2.1629 -lemma mult_le_cancel_left:
2.1630 -  "c * a \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
2.1631 -by (simp add: not_less [symmetric] mult_less_cancel_left_disj)
2.1632 +lemma mult_le_cancel_left: "c * a \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
2.1633 +  by (simp add: not_less [symmetric] mult_less_cancel_left_disj)
2.1634
2.1635 -lemma mult_le_cancel_left_pos:
2.1636 -  "0 < c \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> a \<le> b"
2.1637 -by (auto simp: mult_le_cancel_left)
2.1638 +lemma mult_le_cancel_left_pos: "0 < c \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> a \<le> b"
2.1639 +  by (auto simp: mult_le_cancel_left)
2.1640
2.1641 -lemma mult_le_cancel_left_neg:
2.1642 -  "c < 0 \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> b \<le> a"
2.1643 -by (auto simp: mult_le_cancel_left)
2.1644 +lemma mult_le_cancel_left_neg: "c < 0 \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> b \<le> a"
2.1645 +  by (auto simp: mult_le_cancel_left)
2.1646
2.1647 -lemma mult_less_cancel_left_pos:
2.1648 -  "0 < c \<Longrightarrow> c * a < c * b \<longleftrightarrow> a < b"
2.1649 -by (auto simp: mult_less_cancel_left)
2.1650 +lemma mult_less_cancel_left_pos: "0 < c \<Longrightarrow> c * a < c * b \<longleftrightarrow> a < b"
2.1651 +  by (auto simp: mult_less_cancel_left)
2.1652
2.1653 -lemma mult_less_cancel_left_neg:
2.1654 -  "c < 0 \<Longrightarrow> c * a < c * b \<longleftrightarrow> b < a"
2.1655 -by (auto simp: mult_less_cancel_left)
2.1656 +lemma mult_less_cancel_left_neg: "c < 0 \<Longrightarrow> c * a < c * b \<longleftrightarrow> b < a"
2.1657 +  by (auto simp: mult_less_cancel_left)
2.1658
2.1659  end
2.1660
2.1661 @@ -1783,19 +1695,19 @@
2.1662  begin
2.1663
2.1664  subclass zero_neq_one
2.1665 -  proof qed (insert zero_less_one, blast)
2.1666 +  by standard (insert zero_less_one, blast)
2.1667
2.1668  subclass comm_semiring_1
2.1669 -  proof qed (rule mult_1_left)
2.1670 +  by standard (rule mult_1_left)
2.1671
2.1672  lemma zero_le_one [simp]: "0 \<le> 1"
2.1673 -by (rule zero_less_one [THEN less_imp_le])
2.1674 +  by (rule zero_less_one [THEN less_imp_le])
2.1675
2.1676  lemma not_one_le_zero [simp]: "\<not> 1 \<le> 0"
2.1678 +  by (simp add: not_le)
2.1679
2.1680  lemma not_one_less_zero [simp]: "\<not> 1 < 0"
2.1682 +  by (simp add: not_less)
2.1683
2.1684  lemma mult_left_le: "c \<le> 1 \<Longrightarrow> 0 \<le> a \<Longrightarrow> a * c \<le> a"
2.1685    using mult_left_mono[of c 1 a] by simp
2.1686 @@ -1812,8 +1724,7 @@
2.1687    assumes le_add_diff_inverse2 [simp]: "b \<le> a \<Longrightarrow> a - b + b = a"
2.1688  begin
2.1689
2.1690 -subclass linordered_nonzero_semiring
2.1691 -  proof qed
2.1692 +subclass linordered_nonzero_semiring ..
2.1693
2.1694  text \<open>Addition is the inverse of subtraction.\<close>
2.1695
2.1696 @@ -1823,31 +1734,31 @@
2.1697  lemma add_diff_inverse: "\<not> a < b \<Longrightarrow> b + (a - b) = a"
2.1698    by simp
2.1699
2.1701 -  shows "i + k \<le> n \<Longrightarrow> i \<le> n - k"
2.1702 +lemma add_le_imp_le_diff: "i + k \<le> n \<Longrightarrow> i \<le> n - k"
2.1703    apply (subst add_le_cancel_right [where c=k, symmetric])
2.1705    apply (simp only: add.assoc [symmetric])
2.1706 -  using add_implies_diff by fastforce
2.1707 +  using add_implies_diff apply fastforce
2.1708 +  done
2.1709
2.1711 -  assumes a1: "i + k \<le> n"
2.1712 -      and a2: "n \<le> j + k"
2.1713 -  shows "\<lbrakk>i + k \<le> n; n \<le> j + k\<rbrakk> \<Longrightarrow> n - k \<le> j"
2.1714 +  assumes 1: "i + k \<le> n"
2.1715 +    and 2: "n \<le> j + k"
2.1716 +  shows "i + k \<le> n \<Longrightarrow> n \<le> j + k \<Longrightarrow> n - k \<le> j"
2.1717  proof -
2.1718    have "n - (i + k) + (i + k) = n"
2.1719 -    using a1 by simp
2.1720 +    using 1 by simp
2.1721    moreover have "n - k = n - k - i + i"
2.1724    ultimately show ?thesis
2.1725 -    using a2
2.1726 +    using 2
2.1730 +    apply (rule add_le_imp_le_diff [of _ k "j + k", simplified add_diff_cancel_right'])
2.1732 +    done
2.1733  qed
2.1734
2.1735 -lemma less_1_mult:
2.1736 -  "1 < m \<Longrightarrow> 1 < n \<Longrightarrow> 1 < m * n"
2.1737 +lemma less_1_mult: "1 < m \<Longrightarrow> 1 < n \<Longrightarrow> 1 < m * n"
2.1738    using mult_strict_mono [of 1 m 1 n] by (simp add: less_trans [OF zero_less_one])
2.1739
2.1740  end
2.1741 @@ -1864,90 +1775,73 @@
2.1742  subclass linordered_semidom
2.1743  proof
2.1744    have "0 \<le> 1 * 1" by (rule zero_le_square)
2.1745 -  thus "0 < 1" by (simp add: le_less)
2.1746 -  show "\<And>b a. b \<le> a \<Longrightarrow> a - b + b = a"
2.1747 +  then show "0 < 1" by (simp add: le_less)
2.1748 +  show "b \<le> a \<Longrightarrow> a - b + b = a" for a b
2.1749      by simp
2.1750  qed
2.1751
2.1752  lemma linorder_neqE_linordered_idom:
2.1753 -  assumes "x \<noteq> y" obtains "x < y" | "y < x"
2.1754 +  assumes "x \<noteq> y"
2.1755 +  obtains "x < y" | "y < x"
2.1756    using assms by (rule neqE)
2.1757
2.1758  text \<open>These cancellation simprules also produce two cases when the comparison is a goal.\<close>
2.1759
2.1760 -lemma mult_le_cancel_right1:
2.1761 -  "c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)"
2.1762 -by (insert mult_le_cancel_right [of 1 c b], simp)
2.1763 +lemma mult_le_cancel_right1: "c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)"
2.1764 +  using mult_le_cancel_right [of 1 c b] by simp
2.1765
2.1766 -lemma mult_le_cancel_right2:
2.1767 -  "a * c \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)"
2.1768 -by (insert mult_le_cancel_right [of a c 1], simp)
2.1769 +lemma mult_le_cancel_right2: "a * c \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)"
2.1770 +  using mult_le_cancel_right [of a c 1] by simp
2.1771
2.1772 -lemma mult_le_cancel_left1:
2.1773 -  "c \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)"
2.1774 -by (insert mult_le_cancel_left [of c 1 b], simp)
2.1775 +lemma mult_le_cancel_left1: "c \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)"
2.1776 +  using mult_le_cancel_left [of c 1 b] by simp
2.1777
2.1778 -lemma mult_le_cancel_left2:
2.1779 -  "c * a \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)"
2.1780 -by (insert mult_le_cancel_left [of c a 1], simp)
2.1781 +lemma mult_le_cancel_left2: "c * a \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)"
2.1782 +  using mult_le_cancel_left [of c a 1] by simp
2.1783
2.1784 -lemma mult_less_cancel_right1:
2.1785 -  "c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)"
2.1786 -by (insert mult_less_cancel_right [of 1 c b], simp)
2.1787 +lemma mult_less_cancel_right1: "c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)"
2.1788 +  using mult_less_cancel_right [of 1 c b] by simp
2.1789
2.1790 -lemma mult_less_cancel_right2:
2.1791 -  "a * c < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)"
2.1792 -by (insert mult_less_cancel_right [of a c 1], simp)
2.1793 +lemma mult_less_cancel_right2: "a * c < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)"
2.1794 +  using mult_less_cancel_right [of a c 1] by simp
2.1795
2.1796 -lemma mult_less_cancel_left1:
2.1797 -  "c < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)"
2.1798 -by (insert mult_less_cancel_left [of c 1 b], simp)
2.1799 +lemma mult_less_cancel_left1: "c < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)"
2.1800 +  using mult_less_cancel_left [of c 1 b] by simp
2.1801
2.1802 -lemma mult_less_cancel_left2:
2.1803 -  "c * a < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)"
2.1804 -by (insert mult_less_cancel_left [of c a 1], simp)
2.1805 +lemma mult_less_cancel_left2: "c * a < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)"
2.1806 +  using mult_less_cancel_left [of c a 1] by simp
2.1807
2.1808 -lemma sgn_sgn [simp]:
2.1809 -  "sgn (sgn a) = sgn a"
2.1810 -unfolding sgn_if by simp
2.1811 +lemma sgn_sgn [simp]: "sgn (sgn a) = sgn a"
2.1812 +  unfolding sgn_if by simp
2.1813
2.1814 -lemma sgn_0_0:
2.1815 -  "sgn a = 0 \<longleftrightarrow> a = 0"
2.1816 -unfolding sgn_if by simp
2.1817 +lemma sgn_0_0: "sgn a = 0 \<longleftrightarrow> a = 0"
2.1818 +  unfolding sgn_if by simp
2.1819
2.1820 -lemma sgn_1_pos:
2.1821 -  "sgn a = 1 \<longleftrightarrow> a > 0"
2.1822 -unfolding sgn_if by simp
2.1823 +lemma sgn_1_pos: "sgn a = 1 \<longleftrightarrow> a > 0"
2.1824 +  unfolding sgn_if by simp
2.1825
2.1826 -lemma sgn_1_neg:
2.1827 -  "sgn a = - 1 \<longleftrightarrow> a < 0"
2.1828 -unfolding sgn_if by auto
2.1829 +lemma sgn_1_neg: "sgn a = - 1 \<longleftrightarrow> a < 0"
2.1830 +  unfolding sgn_if by auto
2.1831
2.1832 -lemma sgn_pos [simp]:
2.1833 -  "0 < a \<Longrightarrow> sgn a = 1"
2.1834 -unfolding sgn_1_pos .
2.1835 +lemma sgn_pos [simp]: "0 < a \<Longrightarrow> sgn a = 1"
2.1836 +  by (simp only: sgn_1_pos)
2.1837
2.1838 -lemma sgn_neg [simp]:
2.1839 -  "a < 0 \<Longrightarrow> sgn a = - 1"
2.1840 -unfolding sgn_1_neg .
2.1841 +lemma sgn_neg [simp]: "a < 0 \<Longrightarrow> sgn a = - 1"
2.1842 +  by (simp only: sgn_1_neg)
2.1843
2.1844 -lemma sgn_times:
2.1845 -  "sgn (a * b) = sgn a * sgn b"
2.1846 -by (auto simp add: sgn_if zero_less_mult_iff)
2.1847 +lemma sgn_times: "sgn (a * b) = sgn a * sgn b"
2.1848 +  by (auto simp add: sgn_if zero_less_mult_iff)
2.1849
2.1850  lemma abs_sgn: "\<bar>k\<bar> = k * sgn k"
2.1851 -unfolding sgn_if abs_if by auto
2.1852 +  unfolding sgn_if abs_if by auto
2.1853
2.1854 -lemma sgn_greater [simp]:
2.1855 -  "0 < sgn a \<longleftrightarrow> 0 < a"
2.1856 +lemma sgn_greater [simp]: "0 < sgn a \<longleftrightarrow> 0 < a"
2.1857    unfolding sgn_if by auto
2.1858
2.1859 -lemma sgn_less [simp]:
2.1860 -  "sgn a < 0 \<longleftrightarrow> a < 0"
2.1861 +lemma sgn_less [simp]: "sgn a < 0 \<longleftrightarrow> a < 0"
2.1862    unfolding sgn_if by auto
2.1863
2.1864 -lemma abs_sgn_eq:
2.1865 -  "\<bar>sgn a\<bar> = (if a = 0 then 0 else 1)"
2.1866 +lemma abs_sgn_eq: "\<bar>sgn a\<bar> = (if a = 0 then 0 else 1)"
2.1868
2.1869  lemma abs_dvd_iff [simp]: "\<bar>m\<bar> dvd k \<longleftrightarrow> m dvd k"
2.1870 @@ -1956,36 +1850,31 @@
2.1871  lemma dvd_abs_iff [simp]: "m dvd \<bar>k\<bar> \<longleftrightarrow> m dvd k"
2.1873
2.1874 -lemma dvd_if_abs_eq:
2.1875 -  "\<bar>l\<bar> = \<bar>k\<bar> \<Longrightarrow> l dvd k"
2.1876 -by(subst abs_dvd_iff[symmetric]) simp
2.1877 +lemma dvd_if_abs_eq: "\<bar>l\<bar> = \<bar>k\<bar> \<Longrightarrow> l dvd k"
2.1878 +  by (subst abs_dvd_iff [symmetric]) simp
2.1879
2.1880 -text \<open>The following lemmas can be proven in more general structures, but
2.1881 -are dangerous as simp rules in absence of @{thm neg_equal_zero},
2.1882 -@{thm neg_less_pos}, @{thm neg_less_eq_nonneg}.\<close>
2.1883 +text \<open>
2.1884 +  The following lemmas can be proven in more general structures, but
2.1885 +  are dangerous as simp rules in absence of @{thm neg_equal_zero},
2.1886 +  @{thm neg_less_pos}, @{thm neg_less_eq_nonneg}.
2.1887 +\<close>
2.1888
2.1889 -lemma equation_minus_iff_1 [simp, no_atp]:
2.1890 -  "1 = - a \<longleftrightarrow> a = - 1"
2.1891 +lemma equation_minus_iff_1 [simp, no_atp]: "1 = - a \<longleftrightarrow> a = - 1"
2.1892    by (fact equation_minus_iff)
2.1893
2.1894 -lemma minus_equation_iff_1 [simp, no_atp]:
2.1895 -  "- a = 1 \<longleftrightarrow> a = - 1"
2.1896 +lemma minus_equation_iff_1 [simp, no_atp]: "- a = 1 \<longleftrightarrow> a = - 1"
2.1897    by (subst minus_equation_iff, auto)
2.1898
2.1899 -lemma le_minus_iff_1 [simp, no_atp]:
2.1900 -  "1 \<le> - b \<longleftrightarrow> b \<le> - 1"
2.1901 +lemma le_minus_iff_1 [simp, no_atp]: "1 \<le> - b \<longleftrightarrow> b \<le> - 1"
2.1902    by (fact le_minus_iff)
2.1903
2.1904 -lemma minus_le_iff_1 [simp, no_atp]:
2.1905 -  "- a \<le> 1 \<longleftrightarrow> - 1 \<le> a"
2.1906 +lemma minus_le_iff_1 [simp, no_atp]: "- a \<le> 1 \<longleftrightarrow> - 1 \<le> a"
2.1907    by (fact minus_le_iff)
2.1908
2.1909 -lemma less_minus_iff_1 [simp, no_atp]:
2.1910 -  "1 < - b \<longleftrightarrow> b < - 1"
2.1911 +lemma less_minus_iff_1 [simp, no_atp]: "1 < - b \<longleftrightarrow> b < - 1"
2.1912    by (fact less_minus_iff)
2.1913
2.1914 -lemma minus_less_iff_1 [simp, no_atp]:
2.1915 -  "- a < 1 \<longleftrightarrow> - 1 < a"
2.1916 +lemma minus_less_iff_1 [simp, no_atp]: "- a < 1 \<longleftrightarrow> - 1 < a"
2.1917    by (fact minus_less_iff)
2.1918
2.1919  end
2.1920 @@ -1993,15 +1882,16 @@
2.1921  text \<open>Simprules for comparisons where common factors can be cancelled.\<close>
2.1922
2.1923  lemmas mult_compare_simps =
2.1924 -    mult_le_cancel_right mult_le_cancel_left
2.1925 -    mult_le_cancel_right1 mult_le_cancel_right2
2.1926 -    mult_le_cancel_left1 mult_le_cancel_left2
2.1927 -    mult_less_cancel_right mult_less_cancel_left
2.1928 -    mult_less_cancel_right1 mult_less_cancel_right2
2.1929 -    mult_less_cancel_left1 mult_less_cancel_left2
2.1930 -    mult_cancel_right mult_cancel_left
2.1931 -    mult_cancel_right1 mult_cancel_right2
2.1932 -    mult_cancel_left1 mult_cancel_left2
2.1933 +  mult_le_cancel_right mult_le_cancel_left
2.1934 +  mult_le_cancel_right1 mult_le_cancel_right2
2.1935 +  mult_le_cancel_left1 mult_le_cancel_left2
2.1936 +  mult_less_cancel_right mult_less_cancel_left
2.1937 +  mult_less_cancel_right1 mult_less_cancel_right2
2.1938 +  mult_less_cancel_left1 mult_less_cancel_left2
2.1939 +  mult_cancel_right mult_cancel_left
2.1940 +  mult_cancel_right1 mult_cancel_right2
2.1941 +  mult_cancel_left1 mult_cancel_left2
2.1942 +
2.1943
2.1944  text \<open>Reasoning about inequalities with division\<close>
2.1945
2.1946 @@ -2012,7 +1902,7 @@
2.1947  proof -
2.1948    have "a + 0 < a + 1"
2.1949      by (blast intro: zero_less_one add_strict_left_mono)
2.1950 -  thus ?thesis by simp
2.1951 +  then show ?thesis by simp
2.1952  qed
2.1953
2.1954  end
2.1955 @@ -2020,12 +1910,10 @@
2.1956  context linordered_idom
2.1957  begin
2.1958
2.1959 -lemma mult_right_le_one_le:
2.1960 -  "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> x * y \<le> x"
2.1961 +lemma mult_right_le_one_le: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> x * y \<le> x"
2.1962    by (rule mult_left_le)
2.1963
2.1964 -lemma mult_left_le_one_le:
2.1965 -  "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> y * x \<le> x"
2.1966 +lemma mult_left_le_one_le: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> y * x \<le> x"
2.1967    by (auto simp add: mult_le_cancel_right2)
2.1968
2.1969  end
2.1970 @@ -2035,12 +1923,10 @@
2.1971  context linordered_idom
2.1972  begin
2.1973
2.1974 -lemma mult_sgn_abs:
2.1975 -  "sgn x * \<bar>x\<bar> = x"
2.1976 +lemma mult_sgn_abs: "sgn x * \<bar>x\<bar> = x"
2.1977    unfolding abs_if sgn_if by auto
2.1978
2.1979 -lemma abs_one [simp]:
2.1980 -  "\<bar>1\<bar> = 1"
2.1981 +lemma abs_one [simp]: "\<bar>1\<bar> = 1"
2.1983
2.1984  end
2.1985 @@ -2052,57 +1938,54 @@
2.1986  context linordered_idom
2.1987  begin
2.1988
2.1989 -subclass ordered_ring_abs proof
2.1990 -qed (auto simp add: abs_if not_less mult_less_0_iff)
2.1991 +subclass ordered_ring_abs
2.1992 +  by standard (auto simp add: abs_if not_less mult_less_0_iff)
2.1993
2.1994 -lemma abs_mult:
2.1995 -  "\<bar>a * b\<bar> = \<bar>a\<bar> * \<bar>b\<bar>"
2.1996 +lemma abs_mult: "\<bar>a * b\<bar> = \<bar>a\<bar> * \<bar>b\<bar>"
2.1997    by (rule abs_eq_mult) auto
2.1998
2.1999 -lemma abs_mult_self [simp]:
2.2000 -  "\<bar>a\<bar> * \<bar>a\<bar> = a * a"
2.2001 +lemma abs_mult_self [simp]: "\<bar>a\<bar> * \<bar>a\<bar> = a * a"
2.2003
2.2004  lemma abs_mult_less:
2.2005 -  "\<bar>a\<bar> < c \<Longrightarrow> \<bar>b\<bar> < d \<Longrightarrow> \<bar>a\<bar> * \<bar>b\<bar> < c * d"
2.2006 +  assumes ac: "\<bar>a\<bar> < c"
2.2007 +    and bd: "\<bar>b\<bar> < d"
2.2008 +  shows "\<bar>a\<bar> * \<bar>b\<bar> < c * d"
2.2009  proof -
2.2010 -  assume ac: "\<bar>a\<bar> < c"
2.2011 -  hence cpos: "0<c" by (blast intro: le_less_trans abs_ge_zero)
2.2012 -  assume "\<bar>b\<bar> < d"
2.2013 -  thus ?thesis by (simp add: ac cpos mult_strict_mono)
2.2014 +  from ac have "0 < c"
2.2015 +    by (blast intro: le_less_trans abs_ge_zero)
2.2016 +  with bd show ?thesis by (simp add: ac mult_strict_mono)
2.2017  qed
2.2018
2.2019 -lemma abs_less_iff:
2.2020 -  "\<bar>a\<bar> < b \<longleftrightarrow> a < b \<and> - a < b"
2.2021 +lemma abs_less_iff: "\<bar>a\<bar> < b \<longleftrightarrow> a < b \<and> - a < b"
2.2023
2.2024 -lemma abs_mult_pos:
2.2025 -  "0 \<le> x \<Longrightarrow> \<bar>y\<bar> * x = \<bar>y * x\<bar>"
2.2026 +lemma abs_mult_pos: "0 \<le> x \<Longrightarrow> \<bar>y\<bar> * x = \<bar>y * x\<bar>"
2.2028
2.2029 -lemma abs_diff_less_iff:
2.2030 -  "\<bar>x - a\<bar> < r \<longleftrightarrow> a - r < x \<and> x < a + r"
2.2031 +lemma abs_diff_less_iff: "\<bar>x - a\<bar> < r \<longleftrightarrow> a - r < x \<and> x < a + r"
2.2032    by (auto simp add: diff_less_eq ac_simps abs_less_iff)
2.2033
2.2034 -lemma abs_diff_le_iff:
2.2035 -   "\<bar>x - a\<bar> \<le> r \<longleftrightarrow> a - r \<le> x \<and> x \<le> a + r"
2.2036 +lemma abs_diff_le_iff: "\<bar>x - a\<bar> \<le> r \<longleftrightarrow> a - r \<le> x \<and> x \<le> a + r"
2.2037    by (auto simp add: diff_le_eq ac_simps abs_le_iff)
2.2038
2.2039  lemma abs_add_one_gt_zero: "0 < 1 + \<bar>x\<bar>"
2.2040 -  by (force simp: abs_if not_less intro: zero_less_one add_strict_increasing less_trans)
2.2041 +  by (auto simp: abs_if not_less intro: zero_less_one add_strict_increasing less_trans)
2.2042
2.2043  end
2.2044
2.2045  subsection \<open>Dioids\<close>
2.2046
2.2047 -text \<open>Dioids are the alternative extensions of semirings, a semiring can either be a ring or a dioid
2.2048 -but never both.\<close>
2.2049 +text \<open>
2.2050 +  Dioids are the alternative extensions of semirings, a semiring can
2.2051 +  either be a ring or a dioid but never both.
2.2052 +\<close>
2.2053
2.2054  class dioid = semiring_1 + canonically_ordered_monoid_add
2.2055  begin
2.2056
2.2057  subclass ordered_semiring
2.2058 -  proof qed (auto simp: le_iff_add distrib_left distrib_right)
2.2059 +  by standard (auto simp: le_iff_add distrib_left distrib_right)
2.2060
2.2061  end
2.2062