src/HOL/Rings.thy
 changeset 63325 1086d56cde86 parent 63040 eb4ddd18d635 child 63359 99b51ba8da1c
     1.1 --- a/src/HOL/Rings.thy	Mon Jun 20 17:51:47 2016 +0200
1.2 +++ b/src/HOL/Rings.thy	Mon Jun 20 21:40:48 2016 +0200
1.3 @@ -18,10 +18,9 @@
1.4    assumes distrib_left[algebra_simps]: "a * (b + c) = a * b + a * c"
1.5  begin
1.6
1.7 -text\<open>For the \<open>combine_numerals\<close> simproc\<close>
1.8 -lemma combine_common_factor:
1.9 -  "a * e + (b * e + c) = (a + b) * e + c"
1.10 -by (simp add: distrib_right ac_simps)
1.11 +text \<open>For the \<open>combine_numerals\<close> simproc\<close>
1.12 +lemma combine_common_factor: "a * e + (b * e + c) = (a + b) * e + c"
1.13 +  by (simp add: distrib_right ac_simps)
1.14
1.15  end
1.16
1.17 @@ -30,8 +29,7 @@
1.18    assumes mult_zero_right [simp]: "a * 0 = 0"
1.19  begin
1.20
1.21 -lemma mult_not_zero:
1.22 -  "a * b \<noteq> 0 \<Longrightarrow> a \<noteq> 0 \<and> b \<noteq> 0"
1.23 +lemma mult_not_zero: "a * b \<noteq> 0 \<Longrightarrow> a \<noteq> 0 \<and> b \<noteq> 0"
1.24    by auto
1.25
1.26  end
1.27 @@ -45,11 +43,9 @@
1.28  proof
1.29    fix a :: 'a
1.30    have "0 * a + 0 * a = 0 * a + 0" by (simp add: distrib_right [symmetric])
1.31 -  thus "0 * a = 0" by (simp only: add_left_cancel)
1.32 -next
1.33 -  fix a :: 'a
1.34 +  then show "0 * a = 0" by (simp only: add_left_cancel)
1.35    have "a * 0 + a * 0 = a * 0 + 0" by (simp add: distrib_left [symmetric])
1.36 -  thus "a * 0 = 0" by (simp only: add_left_cancel)
1.37 +  then show "a * 0 = 0" by (simp only: add_left_cancel)
1.38  qed
1.39
1.40  end
1.41 @@ -63,8 +59,8 @@
1.42    fix a b c :: 'a
1.43    show "(a + b) * c = a * c + b * c" by (simp add: distrib)
1.44    have "a * (b + c) = (b + c) * a" by (simp add: ac_simps)
1.45 -  also have "... = b * a + c * a" by (simp only: distrib)
1.46 -  also have "... = a * b + a * c" by (simp add: ac_simps)
1.47 +  also have "\<dots> = b * a + c * a" by (simp only: distrib)
1.48 +  also have "\<dots> = a * b + a * c" by (simp add: ac_simps)
1.49    finally show "a * (b + c) = a * b + a * c" by blast
1.50  qed
1.51
1.52 @@ -91,27 +87,23 @@
1.53  begin
1.54
1.55  lemma one_neq_zero [simp]: "1 \<noteq> 0"
1.56 -by (rule not_sym) (rule zero_neq_one)
1.57 +  by (rule not_sym) (rule zero_neq_one)
1.58
1.59  definition of_bool :: "bool \<Rightarrow> 'a"
1.60 -where
1.61 -  "of_bool p = (if p then 1 else 0)"
1.62 +  where "of_bool p = (if p then 1 else 0)"
1.63
1.64  lemma of_bool_eq [simp, code]:
1.65    "of_bool False = 0"
1.66    "of_bool True = 1"
1.68
1.69 -lemma of_bool_eq_iff:
1.70 -  "of_bool p = of_bool q \<longleftrightarrow> p = q"
1.71 +lemma of_bool_eq_iff: "of_bool p = of_bool q \<longleftrightarrow> p = q"
1.73
1.74 -lemma split_of_bool [split]:
1.75 -  "P (of_bool p) \<longleftrightarrow> (p \<longrightarrow> P 1) \<and> (\<not> p \<longrightarrow> P 0)"
1.76 +lemma split_of_bool [split]: "P (of_bool p) \<longleftrightarrow> (p \<longrightarrow> P 1) \<and> (\<not> p \<longrightarrow> P 0)"
1.77    by (cases p) simp_all
1.78
1.79 -lemma split_of_bool_asm:
1.80 -  "P (of_bool p) \<longleftrightarrow> \<not> (p \<and> \<not> P 1 \<or> \<not> p \<and> \<not> P 0)"
1.81 +lemma split_of_bool_asm: "P (of_bool p) \<longleftrightarrow> \<not> (p \<and> \<not> P 1 \<or> \<not> p \<and> \<not> P 0)"
1.82    by (cases p) simp_all
1.83
1.84  end
1.85 @@ -123,8 +115,8 @@
1.86  class dvd = times
1.87  begin
1.88
1.89 -definition dvd :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "dvd" 50) where
1.90 -  "b dvd a \<longleftrightarrow> (\<exists>k. a = b * k)"
1.91 +definition dvd :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "dvd" 50)
1.92 +  where "b dvd a \<longleftrightarrow> (\<exists>k. a = b * k)"
1.93
1.94  lemma dvdI [intro?]: "a = b * k \<Longrightarrow> b dvd a"
1.95    unfolding dvd_def ..
1.96 @@ -139,8 +131,7 @@
1.97
1.98  subclass dvd .
1.99
1.100 -lemma dvd_refl [simp]:
1.101 -  "a dvd a"
1.102 +lemma dvd_refl [simp]: "a dvd a"
1.103  proof
1.104    show "a = a * 1" by simp
1.105  qed
1.106 @@ -155,32 +146,25 @@
1.107    then show ?thesis ..
1.108  qed
1.109
1.110 -lemma subset_divisors_dvd:
1.111 -  "{c. c dvd a} \<subseteq> {c. c dvd b} \<longleftrightarrow> a dvd b"
1.112 +lemma subset_divisors_dvd: "{c. c dvd a} \<subseteq> {c. c dvd b} \<longleftrightarrow> a dvd b"
1.113    by (auto simp add: subset_iff intro: dvd_trans)
1.114
1.115 -lemma strict_subset_divisors_dvd:
1.116 -  "{c. c dvd a} \<subset> {c. c dvd b} \<longleftrightarrow> a dvd b \<and> \<not> b dvd a"
1.117 +lemma strict_subset_divisors_dvd: "{c. c dvd a} \<subset> {c. c dvd b} \<longleftrightarrow> a dvd b \<and> \<not> b dvd a"
1.118    by (auto simp add: subset_iff intro: dvd_trans)
1.119
1.120 -lemma one_dvd [simp]:
1.121 -  "1 dvd a"
1.122 +lemma one_dvd [simp]: "1 dvd a"
1.123    by (auto intro!: dvdI)
1.124
1.125 -lemma dvd_mult [simp]:
1.126 -  "a dvd c \<Longrightarrow> a dvd (b * c)"
1.127 +lemma dvd_mult [simp]: "a dvd c \<Longrightarrow> a dvd (b * c)"
1.128    by (auto intro!: mult.left_commute dvdI elim!: dvdE)
1.129
1.130 -lemma dvd_mult2 [simp]:
1.131 -  "a dvd b \<Longrightarrow> a dvd (b * c)"
1.132 +lemma dvd_mult2 [simp]: "a dvd b \<Longrightarrow> a dvd (b * c)"
1.133    using dvd_mult [of a b c] by (simp add: ac_simps)
1.134
1.135 -lemma dvd_triv_right [simp]:
1.136 -  "a dvd b * a"
1.137 +lemma dvd_triv_right [simp]: "a dvd b * a"
1.138    by (rule dvd_mult) (rule dvd_refl)
1.139
1.140 -lemma dvd_triv_left [simp]:
1.141 -  "a dvd a * b"
1.142 +lemma dvd_triv_left [simp]: "a dvd a * b"
1.143    by (rule dvd_mult2) (rule dvd_refl)
1.144
1.145  lemma mult_dvd_mono:
1.146 @@ -194,12 +178,10 @@
1.147    then show ?thesis ..
1.148  qed
1.149
1.150 -lemma dvd_mult_left:
1.151 -  "a * b dvd c \<Longrightarrow> a dvd c"
1.152 +lemma dvd_mult_left: "a * b dvd c \<Longrightarrow> a dvd c"
1.153    by (simp add: dvd_def mult.assoc) blast
1.154
1.155 -lemma dvd_mult_right:
1.156 -  "a * b dvd c \<Longrightarrow> b dvd c"
1.157 +lemma dvd_mult_right: "a * b dvd c \<Longrightarrow> b dvd c"
1.158    using dvd_mult_left [of b a c] by (simp add: ac_simps)
1.159
1.160  end
1.161 @@ -209,18 +191,15 @@
1.162
1.163  subclass semiring_1 ..
1.164
1.165 -lemma dvd_0_left_iff [simp]:
1.166 -  "0 dvd a \<longleftrightarrow> a = 0"
1.167 +lemma dvd_0_left_iff [simp]: "0 dvd a \<longleftrightarrow> a = 0"
1.168    by (auto intro: dvd_refl elim!: dvdE)
1.169
1.170 -lemma dvd_0_right [iff]:
1.171 -  "a dvd 0"
1.172 +lemma dvd_0_right [iff]: "a dvd 0"
1.173  proof
1.174    show "0 = a * 0" by simp
1.175  qed
1.176
1.177 -lemma dvd_0_left:
1.178 -  "0 dvd a \<Longrightarrow> a = 0"
1.179 +lemma dvd_0_left: "0 dvd a \<Longrightarrow> a = 0"
1.180    by simp
1.181
1.183 @@ -245,8 +224,8 @@
1.184
1.185  end
1.186
1.187 -class comm_semiring_1_cancel = comm_semiring + cancel_comm_monoid_add +
1.188 -                               zero_neq_one + comm_monoid_mult +
1.189 +class comm_semiring_1_cancel =
1.190 +  comm_semiring + cancel_comm_monoid_add + zero_neq_one + comm_monoid_mult +
1.191    assumes right_diff_distrib' [algebra_simps]: "a * (b - c) = a * b - a * c"
1.192  begin
1.193
1.194 @@ -254,16 +233,15 @@
1.195  subclass comm_semiring_0_cancel ..
1.196  subclass comm_semiring_1 ..
1.197
1.198 -lemma left_diff_distrib' [algebra_simps]:
1.199 -  "(b - c) * a = b * a - c * a"
1.200 +lemma left_diff_distrib' [algebra_simps]: "(b - c) * a = b * a - c * a"
1.202
1.204 -  "a dvd c * a + b \<longleftrightarrow> a dvd b"
1.205 +lemma dvd_add_times_triv_left_iff [simp]: "a dvd c * a + b \<longleftrightarrow> a dvd b"
1.206  proof -
1.207    have "a dvd a * c + b \<longleftrightarrow> a dvd b" (is "?P \<longleftrightarrow> ?Q")
1.208    proof
1.209 -    assume ?Q then show ?P by simp
1.210 +    assume ?Q
1.211 +    then show ?P by simp
1.212    next
1.213      assume ?P
1.214      then obtain d where "a * c + b = a * d" ..
1.215 @@ -275,23 +253,21 @@
1.216    then show "a dvd c * a + b \<longleftrightarrow> a dvd b" by (simp add: ac_simps)
1.217  qed
1.218
1.220 -  "a dvd b + c * a \<longleftrightarrow> a dvd b"
1.221 +lemma dvd_add_times_triv_right_iff [simp]: "a dvd b + c * a \<longleftrightarrow> a dvd b"
1.223
1.225 -  "a dvd a + b \<longleftrightarrow> a dvd b"
1.226 +lemma dvd_add_triv_left_iff [simp]: "a dvd a + b \<longleftrightarrow> a dvd b"
1.227    using dvd_add_times_triv_left_iff [of a 1 b] by simp
1.228
1.230 -  "a dvd b + a \<longleftrightarrow> a dvd b"
1.231 +lemma dvd_add_triv_right_iff [simp]: "a dvd b + a \<longleftrightarrow> a dvd b"
1.232    using dvd_add_times_triv_right_iff [of a b 1] by simp
1.233
1.235    assumes "a dvd b"
1.236    shows "a dvd b + c \<longleftrightarrow> a dvd c" (is "?P \<longleftrightarrow> ?Q")
1.237  proof
1.238 -  assume ?P then obtain d where "b + c = a * d" ..
1.239 +  assume ?P
1.240 +  then obtain d where "b + c = a * d" ..
1.241    moreover from \<open>a dvd b\<close> obtain e where "b = a * e" ..
1.242    ultimately have "a * e + c = a * d" by simp
1.243    then have "a * e + c - a * e = a * d - a * e" by simp
1.244 @@ -299,13 +275,12 @@
1.245    then have "c = a * (d - e)" by (simp add: algebra_simps)
1.246    then show ?Q ..
1.247  next
1.248 -  assume ?Q with assms show ?P by simp
1.249 +  assume ?Q
1.250 +  with assms show ?P by simp
1.251  qed
1.252
1.254 -  assumes "a dvd c"
1.255 -  shows "a dvd b + c \<longleftrightarrow> a dvd b"
1.256 -  using assms dvd_add_right_iff [of a c b] by (simp add: ac_simps)
1.257 +lemma dvd_add_left_iff: "a dvd c \<Longrightarrow> a dvd b + c \<longleftrightarrow> a dvd b"
1.258 +  using dvd_add_right_iff [of a c b] by (simp add: ac_simps)
1.259
1.260  end
1.261
1.262 @@ -317,44 +292,38 @@
1.263  text \<open>Distribution rules\<close>
1.264
1.265  lemma minus_mult_left: "- (a * b) = - a * b"
1.266 -by (rule minus_unique) (simp add: distrib_right [symmetric])
1.267 +  by (rule minus_unique) (simp add: distrib_right [symmetric])
1.268
1.269  lemma minus_mult_right: "- (a * b) = a * - b"
1.270 -by (rule minus_unique) (simp add: distrib_left [symmetric])
1.271 +  by (rule minus_unique) (simp add: distrib_left [symmetric])
1.272
1.273 -text\<open>Extract signs from products\<close>
1.274 +text \<open>Extract signs from products\<close>
1.275  lemmas mult_minus_left [simp] = minus_mult_left [symmetric]
1.276  lemmas mult_minus_right [simp] = minus_mult_right [symmetric]
1.277
1.278  lemma minus_mult_minus [simp]: "- a * - b = a * b"
1.279 -by simp
1.280 +  by simp
1.281
1.282  lemma minus_mult_commute: "- a * b = a * - b"
1.283 -by simp
1.284 +  by simp
1.285
1.286 -lemma right_diff_distrib [algebra_simps]:
1.287 -  "a * (b - c) = a * b - a * c"
1.288 +lemma right_diff_distrib [algebra_simps]: "a * (b - c) = a * b - a * c"
1.289    using distrib_left [of a b "-c "] by simp
1.290
1.291 -lemma left_diff_distrib [algebra_simps]:
1.292 -  "(a - b) * c = a * c - b * c"
1.293 +lemma left_diff_distrib [algebra_simps]: "(a - b) * c = a * c - b * c"
1.294    using distrib_right [of a "- b" c] by simp
1.295
1.296 -lemmas ring_distribs =
1.297 -  distrib_left distrib_right left_diff_distrib right_diff_distrib
1.298 +lemmas ring_distribs = distrib_left distrib_right left_diff_distrib right_diff_distrib
1.299
1.301 -  "a * e + c = b * e + d \<longleftrightarrow> (a - b) * e + c = d"
1.303 +lemma eq_add_iff1: "a * e + c = b * e + d \<longleftrightarrow> (a - b) * e + c = d"
1.304 +  by (simp add: algebra_simps)
1.305
1.307 -  "a * e + c = b * e + d \<longleftrightarrow> c = (b - a) * e + d"
1.309 +lemma eq_add_iff2: "a * e + c = b * e + d \<longleftrightarrow> c = (b - a) * e + d"
1.310 +  by (simp add: algebra_simps)
1.311
1.312  end
1.313
1.314 -lemmas ring_distribs =
1.315 -  distrib_left distrib_right left_diff_distrib right_diff_distrib
1.316 +lemmas ring_distribs = distrib_left distrib_right left_diff_distrib right_diff_distrib
1.317
1.318  class comm_ring = comm_semiring + ab_group_add
1.319  begin
1.320 @@ -362,8 +331,7 @@
1.321  subclass ring ..
1.322  subclass comm_semiring_0_cancel ..
1.323
1.324 -lemma square_diff_square_factored:
1.325 -  "x * x - y * y = (x + y) * (x - y)"
1.326 +lemma square_diff_square_factored: "x * x - y * y = (x + y) * (x - y)"
1.328
1.329  end
1.330 @@ -373,8 +341,7 @@
1.331
1.332  subclass semiring_1_cancel ..
1.333
1.334 -lemma square_diff_one_factored:
1.335 -  "x * x - 1 = (x + 1) * (x - 1)"
1.336 +lemma square_diff_one_factored: "x * x - 1 = (x + 1) * (x - 1)"
1.338
1.339  end
1.340 @@ -410,8 +377,7 @@
1.341    then show "- x dvd y" ..
1.342  qed
1.343
1.344 -lemma dvd_diff [simp]:
1.345 -  "x dvd y \<Longrightarrow> x dvd z \<Longrightarrow> x dvd (y - z)"
1.346 +lemma dvd_diff [simp]: "x dvd y \<Longrightarrow> x dvd z \<Longrightarrow> x dvd (y - z)"
1.347    using dvd_add [of x y "- z"] by simp
1.348
1.349  end
1.350 @@ -424,19 +390,20 @@
1.351    assumes "a * b = 0"
1.352    shows "a = 0 \<or> b = 0"
1.353  proof (rule classical)
1.354 -  assume "\<not> (a = 0 \<or> b = 0)"
1.355 +  assume "\<not> ?thesis"
1.356    then have "a \<noteq> 0" and "b \<noteq> 0" by auto
1.357    with no_zero_divisors have "a * b \<noteq> 0" by blast
1.358    with assms show ?thesis by simp
1.359  qed
1.360
1.361 -lemma mult_eq_0_iff [simp]:
1.362 -  shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
1.363 +lemma mult_eq_0_iff [simp]: "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0"
1.364  proof (cases "a = 0 \<or> b = 0")
1.365 -  case False then have "a \<noteq> 0" and "b \<noteq> 0" by auto
1.366 +  case False
1.367 +  then have "a \<noteq> 0" and "b \<noteq> 0" by auto
1.368      then show ?thesis using no_zero_divisors by simp
1.369  next
1.370 -  case True then show ?thesis by auto
1.371 +  case True
1.372 +  then show ?thesis by auto
1.373  qed
1.374
1.375  end
1.376 @@ -448,12 +415,10 @@
1.377      and mult_cancel_left [simp]: "c * a = c * b \<longleftrightarrow> c = 0 \<or> a = b"
1.378  begin
1.379
1.380 -lemma mult_left_cancel:
1.381 -  "c \<noteq> 0 \<Longrightarrow> c * a = c * b \<longleftrightarrow> a = b"
1.382 +lemma mult_left_cancel: "c \<noteq> 0 \<Longrightarrow> c * a = c * b \<longleftrightarrow> a = b"
1.383    by simp
1.384
1.385 -lemma mult_right_cancel:
1.386 -  "c \<noteq> 0 \<Longrightarrow> a * c = b * c \<longleftrightarrow> a = b"
1.387 +lemma mult_right_cancel: "c \<noteq> 0 \<Longrightarrow> a * c = b * c \<longleftrightarrow> a = b"
1.388    by simp
1.389
1.390  end
1.391 @@ -483,32 +448,27 @@
1.392
1.393  subclass semiring_1_no_zero_divisors ..
1.394
1.395 -lemma square_eq_1_iff:
1.396 -  "x * x = 1 \<longleftrightarrow> x = 1 \<or> x = - 1"
1.397 +lemma square_eq_1_iff: "x * x = 1 \<longleftrightarrow> x = 1 \<or> x = - 1"
1.398  proof -
1.399    have "(x - 1) * (x + 1) = x * x - 1"
1.401 -  hence "x * x = 1 \<longleftrightarrow> (x - 1) * (x + 1) = 0"
1.402 +  then have "x * x = 1 \<longleftrightarrow> (x - 1) * (x + 1) = 0"
1.403      by simp
1.404 -  thus ?thesis
1.405 +  then show ?thesis
1.407  qed
1.408
1.409 -lemma mult_cancel_right1 [simp]:
1.410 -  "c = b * c \<longleftrightarrow> c = 0 \<or> b = 1"
1.411 -by (insert mult_cancel_right [of 1 c b], force)
1.412 +lemma mult_cancel_right1 [simp]: "c = b * c \<longleftrightarrow> c = 0 \<or> b = 1"
1.413 +  using mult_cancel_right [of 1 c b] by auto
1.414
1.415 -lemma mult_cancel_right2 [simp]:
1.416 -  "a * c = c \<longleftrightarrow> c = 0 \<or> a = 1"
1.417 -by (insert mult_cancel_right [of a c 1], simp)
1.418 +lemma mult_cancel_right2 [simp]: "a * c = c \<longleftrightarrow> c = 0 \<or> a = 1"
1.419 +  using mult_cancel_right [of a c 1] by simp
1.420
1.421 -lemma mult_cancel_left1 [simp]:
1.422 -  "c = c * b \<longleftrightarrow> c = 0 \<or> b = 1"
1.423 -by (insert mult_cancel_left [of c 1 b], force)
1.424 +lemma mult_cancel_left1 [simp]: "c = c * b \<longleftrightarrow> c = 0 \<or> b = 1"
1.425 +  using mult_cancel_left [of c 1 b] by force
1.426
1.427 -lemma mult_cancel_left2 [simp]:
1.428 -  "c * a = c \<longleftrightarrow> c = 0 \<or> a = 1"
1.429 -by (insert mult_cancel_left [of c a 1], simp)
1.430 +lemma mult_cancel_left2 [simp]: "c * a = c \<longleftrightarrow> c = 0 \<or> a = 1"
1.431 +  using mult_cancel_left [of c a 1] by simp
1.432
1.433  end
1.434
1.435 @@ -526,8 +486,7 @@
1.436
1.437  subclass ring_1_no_zero_divisors ..
1.438
1.439 -lemma dvd_mult_cancel_right [simp]:
1.440 -  "a * c dvd b * c \<longleftrightarrow> c = 0 \<or> a dvd b"
1.441 +lemma dvd_mult_cancel_right [simp]: "a * c dvd b * c \<longleftrightarrow> c = 0 \<or> a dvd b"
1.442  proof -
1.443    have "a * c dvd b * c \<longleftrightarrow> (\<exists>k. b * c = (a * k) * c)"
1.444      unfolding dvd_def by (simp add: ac_simps)
1.445 @@ -536,8 +495,7 @@
1.446    finally show ?thesis .
1.447  qed
1.448
1.449 -lemma dvd_mult_cancel_left [simp]:
1.450 -  "c * a dvd c * b \<longleftrightarrow> c = 0 \<or> a dvd b"
1.451 +lemma dvd_mult_cancel_left [simp]: "c * a dvd c * b \<longleftrightarrow> c = 0 \<or> a dvd b"
1.452  proof -
1.453    have "c * a dvd c * b \<longleftrightarrow> (\<exists>k. b * c = (a * k) * c)"
1.454      unfolding dvd_def by (simp add: ac_simps)
1.455 @@ -562,15 +520,12 @@
1.456
1.457  text \<open>
1.458    The theory of partially ordered rings is taken from the books:
1.459 -  \begin{itemize}
1.460 -  \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979
1.461 -  \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
1.462 -  \end{itemize}
1.463 +    \<^item> \<^emph>\<open>Lattice Theory\<close> by Garret Birkhoff, American Mathematical Society, 1979
1.464 +    \<^item> \<^emph>\<open>Partially Ordered Algebraic Systems\<close>, Pergamon Press, 1963
1.465 +
1.466    Most of the used notions can also be looked up in
1.467 -  \begin{itemize}
1.468 -  \item @{url "http://www.mathworld.com"} by Eric Weisstein et. al.
1.469 -  \item \emph{Algebra I} by van der Waerden, Springer.
1.470 -  \end{itemize}
1.471 +    \<^item> @{url "http://www.mathworld.com"} by Eric Weisstein et. al.
1.472 +    \<^item> \<^emph>\<open>Algebra I\<close> by van der Waerden, Springer
1.473  \<close>
1.474
1.475  class divide =
1.476 @@ -605,49 +560,45 @@
1.477    assumes divide_zero [simp]: "a div 0 = 0"
1.478  begin
1.479
1.480 -lemma nonzero_mult_divide_cancel_left [simp]:
1.481 -  "a \<noteq> 0 \<Longrightarrow> (a * b) div a = b"
1.482 +lemma nonzero_mult_divide_cancel_left [simp]: "a \<noteq> 0 \<Longrightarrow> (a * b) div a = b"
1.483    using nonzero_mult_divide_cancel_right [of a b] by (simp add: ac_simps)
1.484
1.485  subclass semiring_no_zero_divisors_cancel
1.486  proof
1.487 -  fix a b c
1.488 -  { fix a b c
1.489 -    show "a * c = b * c \<longleftrightarrow> c = 0 \<or> a = b"
1.490 -    proof (cases "c = 0")
1.491 -      case True then show ?thesis by simp
1.492 -    next
1.493 -      case False
1.494 -      { assume "a * c = b * c"
1.495 -        then have "a * c div c = b * c div c"
1.496 -          by simp
1.497 -        with False have "a = b"
1.498 -          by simp
1.499 -      } then show ?thesis by auto
1.500 -    qed
1.501 -  }
1.502 -  from this [of a c b]
1.503 -  show "c * a = c * b \<longleftrightarrow> c = 0 \<or> a = b"
1.504 -    by (simp add: ac_simps)
1.505 +  show *: "a * c = b * c \<longleftrightarrow> c = 0 \<or> a = b" for a b c
1.506 +  proof (cases "c = 0")
1.507 +    case True
1.508 +    then show ?thesis by simp
1.509 +  next
1.510 +    case False
1.511 +    {
1.512 +      assume "a * c = b * c"
1.513 +      then have "a * c div c = b * c div c"
1.514 +        by simp
1.515 +      with False have "a = b"
1.516 +        by simp
1.517 +    }
1.518 +    then show ?thesis by auto
1.519 +  qed
1.520 +  show "c * a = c * b \<longleftrightarrow> c = 0 \<or> a = b" for a b c
1.521 +    using * [of a c b] by (simp add: ac_simps)
1.522  qed
1.523
1.524 -lemma div_self [simp]:
1.525 -  assumes "a \<noteq> 0"
1.526 -  shows "a div a = 1"
1.527 -  using assms nonzero_mult_divide_cancel_left [of a 1] by simp
1.528 +lemma div_self [simp]: "a \<noteq> 0 \<Longrightarrow> a div a = 1"
1.529 +  using nonzero_mult_divide_cancel_left [of a 1] by simp
1.530
1.531 -lemma divide_zero_left [simp]:
1.532 -  "0 div a = 0"
1.533 +lemma divide_zero_left [simp]: "0 div a = 0"
1.534  proof (cases "a = 0")
1.535 -  case True then show ?thesis by simp
1.536 +  case True
1.537 +  then show ?thesis by simp
1.538  next
1.539 -  case False then have "a * 0 div a = 0"
1.540 +  case False
1.541 +  then have "a * 0 div a = 0"
1.542      by (rule nonzero_mult_divide_cancel_left)
1.543    then show ?thesis by simp
1.544  qed
1.545
1.546 -lemma divide_1 [simp]:
1.547 -  "a div 1 = a"
1.548 +lemma divide_1 [simp]: "a div 1 = a"
1.549    using nonzero_mult_divide_cancel_left [of 1 a] by simp
1.550
1.551  end
1.552 @@ -668,11 +619,13 @@
1.553    assumes "a \<noteq> 0"
1.554    shows "a * b dvd a * c \<longleftrightarrow> b dvd c" (is "?P \<longleftrightarrow> ?Q")
1.555  proof
1.556 -  assume ?P then obtain d where "a * c = a * b * d" ..
1.557 +  assume ?P
1.558 +  then obtain d where "a * c = a * b * d" ..
1.559    with assms have "c = b * d" by (simp add: ac_simps)
1.560    then show ?Q ..
1.561  next
1.562 -  assume ?Q then obtain d where "c = b * d" ..
1.563 +  assume ?Q
1.564 +  then obtain d where "c = b * d" ..
1.565    then have "a * c = a * b * d" by (simp add: ac_simps)
1.566    then show ?P ..
1.567  qed
1.568 @@ -680,7 +633,7 @@
1.569  lemma dvd_times_right_cancel_iff [simp]:
1.570    assumes "a \<noteq> 0"
1.571    shows "b * a dvd c * a \<longleftrightarrow> b dvd c" (is "?P \<longleftrightarrow> ?Q")
1.572 -using dvd_times_left_cancel_iff [of a b c] assms by (simp add: ac_simps)
1.573 +  using dvd_times_left_cancel_iff [of a b c] assms by (simp add: ac_simps)
1.574
1.575  lemma div_dvd_iff_mult:
1.576    assumes "b \<noteq> 0" and "b dvd a"
1.577 @@ -702,7 +655,8 @@
1.578    assumes "a dvd b" and "a dvd c"
1.579    shows "b div a dvd c div a \<longleftrightarrow> b dvd c"
1.580  proof (cases "a = 0")
1.581 -  case True with assms show ?thesis by simp
1.582 +  case True
1.583 +  with assms show ?thesis by simp
1.584  next
1.585    case False
1.586    moreover from assms obtain k l where "b = a * k" and "c = a * l"
1.587 @@ -714,7 +668,8 @@
1.588    assumes "c dvd a" and "c dvd b"
1.589    shows "(a + b) div c = a div c + b div c"
1.590  proof (cases "c = 0")
1.591 -  case True then show ?thesis by simp
1.592 +  case True
1.593 +  then show ?thesis by simp
1.594  next
1.595    case False
1.596    moreover from assms obtain k l where "a = c * k" and "b = c * l"
1.597 @@ -729,7 +684,8 @@
1.598    assumes "b dvd a" and "d dvd c"
1.599    shows "(a div b) * (c div d) = (a * c) div (b * d)"
1.600  proof (cases "b = 0 \<or> c = 0")
1.601 -  case True with assms show ?thesis by auto
1.602 +  case True
1.603 +  with assms show ?thesis by auto
1.604  next
1.605    case False
1.606    moreover from assms obtain k l where "a = b * k" and "c = d * l"
1.607 @@ -748,42 +704,39 @@
1.608  next
1.609    assume "b div a = c"
1.610    then have "b div a * a = c * a" by simp
1.611 -  moreover from \<open>a \<noteq> 0\<close> \<open>a dvd b\<close> have "b div a * a = b"
1.612 +  moreover from assms have "b div a * a = b"
1.613      by (auto elim!: dvdE simp add: ac_simps)
1.614    ultimately show "b = c * a" by simp
1.615  qed
1.616
1.617 -lemma dvd_div_mult_self [simp]:
1.618 -  "a dvd b \<Longrightarrow> b div a * a = b"
1.619 +lemma dvd_div_mult_self [simp]: "a dvd b \<Longrightarrow> b div a * a = b"
1.620    by (cases "a = 0") (auto elim: dvdE simp add: ac_simps)
1.621
1.622 -lemma dvd_mult_div_cancel [simp]:
1.623 -  "a dvd b \<Longrightarrow> a * (b div a) = b"
1.624 +lemma dvd_mult_div_cancel [simp]: "a dvd b \<Longrightarrow> a * (b div a) = b"
1.625    using dvd_div_mult_self [of a b] by (simp add: ac_simps)
1.626
1.627  lemma div_mult_swap:
1.628    assumes "c dvd b"
1.629    shows "a * (b div c) = (a * b) div c"
1.630  proof (cases "c = 0")
1.631 -  case True then show ?thesis by simp
1.632 +  case True
1.633 +  then show ?thesis by simp
1.634  next
1.635 -  case False from assms obtain d where "b = c * d" ..
1.636 +  case False
1.637 +  from assms obtain d where "b = c * d" ..
1.638    moreover from False have "a * divide (d * c) c = ((a * d) * c) div c"
1.639      by simp
1.640    ultimately show ?thesis by (simp add: ac_simps)
1.641  qed
1.642
1.643 -lemma dvd_div_mult:
1.644 -  assumes "c dvd b"
1.645 -  shows "b div c * a = (b * a) div c"
1.646 -  using assms div_mult_swap [of c b a] by (simp add: ac_simps)
1.647 +lemma dvd_div_mult: "c dvd b \<Longrightarrow> b div c * a = (b * a) div c"
1.648 +  using div_mult_swap [of c b a] by (simp add: ac_simps)
1.649
1.650  lemma dvd_div_mult2_eq:
1.651    assumes "b * c dvd a"
1.652    shows "a div (b * c) = a div b div c"
1.653 -using assms proof
1.654 -  fix k
1.655 -  assume "a = b * c * k"
1.656 +proof -
1.657 +  from assms obtain k where "a = b * c * k" ..
1.658    then show ?thesis
1.659      by (cases "b = 0 \<or> c = 0") (auto, simp add: ac_simps)
1.660  qed
1.661 @@ -808,15 +761,12 @@
1.662  text \<open>Units: invertible elements in a ring\<close>
1.663
1.664  abbreviation is_unit :: "'a \<Rightarrow> bool"
1.665 -where
1.666 -  "is_unit a \<equiv> a dvd 1"
1.667 +  where "is_unit a \<equiv> a dvd 1"
1.668
1.669 -lemma not_is_unit_0 [simp]:
1.670 -  "\<not> is_unit 0"
1.671 +lemma not_is_unit_0 [simp]: "\<not> is_unit 0"
1.672    by simp
1.673
1.674 -lemma unit_imp_dvd [dest]:
1.675 -  "is_unit b \<Longrightarrow> b dvd a"
1.676 +lemma unit_imp_dvd [dest]: "is_unit b \<Longrightarrow> b dvd a"
1.677    by (rule dvd_trans [of _ 1]) simp_all
1.678
1.679  lemma unit_dvdE:
1.680 @@ -829,8 +779,7 @@
1.681    ultimately show thesis using that by blast
1.682  qed
1.683
1.684 -lemma dvd_unit_imp_unit:
1.685 -  "a dvd b \<Longrightarrow> is_unit b \<Longrightarrow> is_unit a"
1.686 +lemma dvd_unit_imp_unit: "a dvd b \<Longrightarrow> is_unit b \<Longrightarrow> is_unit a"
1.687    by (rule dvd_trans)
1.688
1.689  lemma unit_div_1_unit [simp, intro]:
1.690 @@ -849,27 +798,24 @@
1.691  proof (rule that)
1.692    define b where "b = 1 div a"
1.693    then show "1 div a = b" by simp
1.694 -  from b_def \<open>is_unit a\<close> show "is_unit b" by simp
1.695 -  from \<open>is_unit a\<close> and \<open>is_unit b\<close> show "a \<noteq> 0" and "b \<noteq> 0" by auto
1.696 -  from b_def \<open>is_unit a\<close> show "a * b = 1" by simp
1.697 +  from assms b_def show "is_unit b" by simp
1.698 +  with assms show "a \<noteq> 0" and "b \<noteq> 0" by auto
1.699 +  from assms b_def show "a * b = 1" by simp
1.700    then have "1 = a * b" ..
1.701    with b_def \<open>b \<noteq> 0\<close> show "1 div b = a" by simp
1.702 -  from \<open>is_unit a\<close> have "a dvd c" ..
1.703 +  from assms have "a dvd c" ..
1.704    then obtain d where "c = a * d" ..
1.705    with \<open>a \<noteq> 0\<close> \<open>a * b = 1\<close> show "c div a = c * b"
1.706      by (simp add: mult.assoc mult.left_commute [of a])
1.707  qed
1.708
1.709 -lemma unit_prod [intro]:
1.710 -  "is_unit a \<Longrightarrow> is_unit b \<Longrightarrow> is_unit (a * b)"
1.711 +lemma unit_prod [intro]: "is_unit a \<Longrightarrow> is_unit b \<Longrightarrow> is_unit (a * b)"
1.712    by (subst mult_1_left [of 1, symmetric]) (rule mult_dvd_mono)
1.713
1.714 -lemma is_unit_mult_iff:
1.715 -  "is_unit (a * b) \<longleftrightarrow> is_unit a \<and> is_unit b" (is "?P \<longleftrightarrow> ?Q")
1.716 +lemma is_unit_mult_iff: "is_unit (a * b) \<longleftrightarrow> is_unit a \<and> is_unit b"
1.717    by (auto dest: dvd_mult_left dvd_mult_right)
1.718
1.719 -lemma unit_div [intro]:
1.720 -  "is_unit a \<Longrightarrow> is_unit b \<Longrightarrow> is_unit (a div b)"
1.721 +lemma unit_div [intro]: "is_unit a \<Longrightarrow> is_unit b \<Longrightarrow> is_unit (a div b)"
1.722    by (erule is_unitE [of b a]) (simp add: ac_simps unit_prod)
1.723
1.724  lemma mult_unit_dvd_iff:
1.725 @@ -894,7 +840,8 @@
1.726    assume "a dvd c * b"
1.727    with assms have "c * b dvd c * (b * (1 div b))"
1.728      by (subst mult_assoc [symmetric]) simp
1.729 -  also from \<open>is_unit b\<close> have "b * (1 div b) = 1" by (rule is_unitE) simp
1.730 +  also from assms have "b * (1 div b) = 1"
1.731 +    by (rule is_unitE) simp
1.732    finally have "c * b dvd c" by simp
1.733    with \<open>a dvd c * b\<close> show "a dvd c" by (rule dvd_trans)
1.734  next
1.735 @@ -902,52 +849,40 @@
1.736    then show "a dvd c * b" by simp
1.737  qed
1.738
1.739 -lemma div_unit_dvd_iff:
1.740 -  "is_unit b \<Longrightarrow> a div b dvd c \<longleftrightarrow> a dvd c"
1.741 +lemma div_unit_dvd_iff: "is_unit b \<Longrightarrow> a div b dvd c \<longleftrightarrow> a dvd c"
1.742    by (erule is_unitE [of _ a]) (auto simp add: mult_unit_dvd_iff)
1.743
1.744 -lemma dvd_div_unit_iff:
1.745 -  "is_unit b \<Longrightarrow> a dvd c div b \<longleftrightarrow> a dvd c"
1.746 +lemma dvd_div_unit_iff: "is_unit b \<Longrightarrow> a dvd c div b \<longleftrightarrow> a dvd c"
1.747    by (erule is_unitE [of _ c]) (simp add: dvd_mult_unit_iff)
1.748
1.749  lemmas unit_dvd_iff = mult_unit_dvd_iff div_unit_dvd_iff
1.750 -  dvd_mult_unit_iff dvd_div_unit_iff \<comment> \<open>FIXME consider fact collection\<close>
1.751 +  dvd_mult_unit_iff dvd_div_unit_iff  (* FIXME consider named_theorems *)
1.752
1.753 -lemma unit_mult_div_div [simp]:
1.754 -  "is_unit a \<Longrightarrow> b * (1 div a) = b div a"
1.755 +lemma unit_mult_div_div [simp]: "is_unit a \<Longrightarrow> b * (1 div a) = b div a"
1.756    by (erule is_unitE [of _ b]) simp
1.757
1.758 -lemma unit_div_mult_self [simp]:
1.759 -  "is_unit a \<Longrightarrow> b div a * a = b"
1.760 +lemma unit_div_mult_self [simp]: "is_unit a \<Longrightarrow> b div a * a = b"
1.761    by (rule dvd_div_mult_self) auto
1.762
1.763 -lemma unit_div_1_div_1 [simp]:
1.764 -  "is_unit a \<Longrightarrow> 1 div (1 div a) = a"
1.765 +lemma unit_div_1_div_1 [simp]: "is_unit a \<Longrightarrow> 1 div (1 div a) = a"
1.766    by (erule is_unitE) simp
1.767
1.768 -lemma unit_div_mult_swap:
1.769 -  "is_unit c \<Longrightarrow> a * (b div c) = (a * b) div c"
1.770 +lemma unit_div_mult_swap: "is_unit c \<Longrightarrow> a * (b div c) = (a * b) div c"
1.771    by (erule unit_dvdE [of _ b]) (simp add: mult.left_commute [of _ c])
1.772
1.773 -lemma unit_div_commute:
1.774 -  "is_unit b \<Longrightarrow> (a div b) * c = (a * c) div b"
1.775 +lemma unit_div_commute: "is_unit b \<Longrightarrow> (a div b) * c = (a * c) div b"
1.776    using unit_div_mult_swap [of b c a] by (simp add: ac_simps)
1.777
1.778 -lemma unit_eq_div1:
1.779 -  "is_unit b \<Longrightarrow> a div b = c \<longleftrightarrow> a = c * b"
1.780 +lemma unit_eq_div1: "is_unit b \<Longrightarrow> a div b = c \<longleftrightarrow> a = c * b"
1.781    by (auto elim: is_unitE)
1.782
1.783 -lemma unit_eq_div2:
1.784 -  "is_unit b \<Longrightarrow> a = c div b \<longleftrightarrow> a * b = c"
1.785 +lemma unit_eq_div2: "is_unit b \<Longrightarrow> a = c div b \<longleftrightarrow> a * b = c"
1.786    using unit_eq_div1 [of b c a] by auto
1.787
1.788 -lemma unit_mult_left_cancel:
1.789 -  assumes "is_unit a"
1.790 -  shows "a * b = a * c \<longleftrightarrow> b = c" (is "?P \<longleftrightarrow> ?Q")
1.791 -  using assms mult_cancel_left [of a b c] by auto
1.792 +lemma unit_mult_left_cancel: "is_unit a \<Longrightarrow> a * b = a * c \<longleftrightarrow> b = c"
1.793 +  using mult_cancel_left [of a b c] by auto
1.794
1.795 -lemma unit_mult_right_cancel:
1.796 -  "is_unit a \<Longrightarrow> b * a = c * a \<longleftrightarrow> b = c"
1.797 +lemma unit_mult_right_cancel: "is_unit a \<Longrightarrow> b * a = c * a \<longleftrightarrow> b = c"
1.798    using unit_mult_left_cancel [of a b c] by (auto simp add: ac_simps)
1.799
1.800  lemma unit_div_cancel:
1.801 @@ -964,7 +899,8 @@
1.802    assumes "is_unit b" and "is_unit c"
1.803    shows "a div (b * c) = a div b div c"
1.804  proof -
1.805 -  from assms have "is_unit (b * c)" by (simp add: unit_prod)
1.806 +  from assms have "is_unit (b * c)"
1.807 +    by (simp add: unit_prod)
1.808    then have "b * c dvd a"
1.809      by (rule unit_imp_dvd)
1.810    then show ?thesis
1.811 @@ -1015,58 +951,57 @@
1.812    values rather than associated elements.
1.813  \<close>
1.814
1.815 -lemma unit_factor_dvd [simp]:
1.816 -  "a \<noteq> 0 \<Longrightarrow> unit_factor a dvd b"
1.817 +lemma unit_factor_dvd [simp]: "a \<noteq> 0 \<Longrightarrow> unit_factor a dvd b"
1.818    by (rule unit_imp_dvd) simp
1.819
1.820 -lemma unit_factor_self [simp]:
1.821 -  "unit_factor a dvd a"
1.822 +lemma unit_factor_self [simp]: "unit_factor a dvd a"
1.823    by (cases "a = 0") simp_all
1.824
1.825 -lemma normalize_mult_unit_factor [simp]:
1.826 -  "normalize a * unit_factor a = a"
1.827 +lemma normalize_mult_unit_factor [simp]: "normalize a * unit_factor a = a"
1.828    using unit_factor_mult_normalize [of a] by (simp add: ac_simps)
1.829
1.830 -lemma normalize_eq_0_iff [simp]:
1.831 -  "normalize a = 0 \<longleftrightarrow> a = 0" (is "?P \<longleftrightarrow> ?Q")
1.832 +lemma normalize_eq_0_iff [simp]: "normalize a = 0 \<longleftrightarrow> a = 0"
1.833 +  (is "?P \<longleftrightarrow> ?Q")
1.834  proof
1.835    assume ?P
1.836    moreover have "unit_factor a * normalize a = a" by simp
1.837    ultimately show ?Q by simp
1.838  next
1.839 -  assume ?Q then show ?P by simp
1.840 +  assume ?Q
1.841 +  then show ?P by simp
1.842  qed
1.843
1.844 -lemma unit_factor_eq_0_iff [simp]:
1.845 -  "unit_factor a = 0 \<longleftrightarrow> a = 0" (is "?P \<longleftrightarrow> ?Q")
1.846 +lemma unit_factor_eq_0_iff [simp]: "unit_factor a = 0 \<longleftrightarrow> a = 0"
1.847 +  (is "?P \<longleftrightarrow> ?Q")
1.848  proof
1.849    assume ?P
1.850    moreover have "unit_factor a * normalize a = a" by simp
1.851    ultimately show ?Q by simp
1.852  next
1.853 -  assume ?Q then show ?P by simp
1.854 +  assume ?Q
1.855 +  then show ?P by simp
1.856  qed
1.857
1.858  lemma is_unit_unit_factor:
1.859 -  assumes "is_unit a" shows "unit_factor a = a"
1.860 +  assumes "is_unit a"
1.861 +  shows "unit_factor a = a"
1.862  proof -
1.863    from assms have "normalize a = 1" by (rule is_unit_normalize)
1.864    moreover from unit_factor_mult_normalize have "unit_factor a * normalize a = a" .
1.865    ultimately show ?thesis by simp
1.866  qed
1.867
1.868 -lemma unit_factor_1 [simp]:
1.869 -  "unit_factor 1 = 1"
1.870 +lemma unit_factor_1 [simp]: "unit_factor 1 = 1"
1.871    by (rule is_unit_unit_factor) simp
1.872
1.873 -lemma normalize_1 [simp]:
1.874 -  "normalize 1 = 1"
1.875 +lemma normalize_1 [simp]: "normalize 1 = 1"
1.876    by (rule is_unit_normalize) simp
1.877
1.878 -lemma normalize_1_iff:
1.879 -  "normalize a = 1 \<longleftrightarrow> is_unit a" (is "?P \<longleftrightarrow> ?Q")
1.880 +lemma normalize_1_iff: "normalize a = 1 \<longleftrightarrow> is_unit a"
1.881 +  (is "?P \<longleftrightarrow> ?Q")
1.882  proof
1.883 -  assume ?Q then show ?P by (rule is_unit_normalize)
1.884 +  assume ?Q
1.885 +  then show ?P by (rule is_unit_normalize)
1.886  next
1.887    assume ?P
1.888    then have "a \<noteq> 0" by auto
1.889 @@ -1079,32 +1014,34 @@
1.890    ultimately show ?Q by simp
1.891  qed
1.892
1.893 -lemma div_normalize [simp]:
1.894 -  "a div normalize a = unit_factor a"
1.895 +lemma div_normalize [simp]: "a div normalize a = unit_factor a"
1.896  proof (cases "a = 0")
1.897 -  case True then show ?thesis by simp
1.898 +  case True
1.899 +  then show ?thesis by simp
1.900  next
1.901 -  case False then have "normalize a \<noteq> 0" by simp
1.902 +  case False
1.903 +  then have "normalize a \<noteq> 0" by simp
1.904    with nonzero_mult_divide_cancel_right
1.905    have "unit_factor a * normalize a div normalize a = unit_factor a" by blast
1.906    then show ?thesis by simp
1.907  qed
1.908
1.909 -lemma div_unit_factor [simp]:
1.910 -  "a div unit_factor a = normalize a"
1.911 +lemma div_unit_factor [simp]: "a div unit_factor a = normalize a"
1.912  proof (cases "a = 0")
1.913 -  case True then show ?thesis by simp
1.914 +  case True
1.915 +  then show ?thesis by simp
1.916  next
1.917 -  case False then have "unit_factor a \<noteq> 0" by simp
1.918 +  case False
1.919 +  then have "unit_factor a \<noteq> 0" by simp
1.920    with nonzero_mult_divide_cancel_left
1.921    have "unit_factor a * normalize a div unit_factor a = normalize a" by blast
1.922    then show ?thesis by simp
1.923  qed
1.924
1.925 -lemma normalize_div [simp]:
1.926 -  "normalize a div a = 1 div unit_factor a"
1.927 +lemma normalize_div [simp]: "normalize a div a = 1 div unit_factor a"
1.928  proof (cases "a = 0")
1.929 -  case True then show ?thesis by simp
1.930 +  case True
1.931 +  then show ?thesis by simp
1.932  next
1.933    case False
1.934    have "normalize a div a = normalize a div (unit_factor a * normalize a)"
1.935 @@ -1114,62 +1051,64 @@
1.936    finally show ?thesis .
1.937  qed
1.938
1.939 -lemma mult_one_div_unit_factor [simp]:
1.940 -  "a * (1 div unit_factor b) = a div unit_factor b"
1.941 +lemma mult_one_div_unit_factor [simp]: "a * (1 div unit_factor b) = a div unit_factor b"
1.942    by (cases "b = 0") simp_all
1.943
1.944 -lemma normalize_mult:
1.945 -  "normalize (a * b) = normalize a * normalize b"
1.946 +lemma normalize_mult: "normalize (a * b) = normalize a * normalize b"
1.947  proof (cases "a = 0 \<or> b = 0")
1.948 -  case True then show ?thesis by auto
1.949 +  case True
1.950 +  then show ?thesis by auto
1.951  next
1.952    case False
1.953    from unit_factor_mult_normalize have "unit_factor (a * b) * normalize (a * b) = a * b" .
1.954 -  then have "normalize (a * b) = a * b div unit_factor (a * b)" by simp
1.955 -  also have "\<dots> = a * b div unit_factor (b * a)" by (simp add: ac_simps)
1.956 +  then have "normalize (a * b) = a * b div unit_factor (a * b)"
1.957 +    by simp
1.958 +  also have "\<dots> = a * b div unit_factor (b * a)"
1.959 +    by (simp add: ac_simps)
1.960    also have "\<dots> = a * b div unit_factor b div unit_factor a"
1.961      using False by (simp add: unit_factor_mult is_unit_div_mult2_eq [symmetric])
1.962    also have "\<dots> = a * (b div unit_factor b) div unit_factor a"
1.963      using False by (subst unit_div_mult_swap) simp_all
1.964    also have "\<dots> = normalize a * normalize b"
1.965 -    using False by (simp add: mult.commute [of a] mult.commute [of "normalize a"] unit_div_mult_swap [symmetric])
1.966 +    using False
1.967 +    by (simp add: mult.commute [of a] mult.commute [of "normalize a"] unit_div_mult_swap [symmetric])
1.968    finally show ?thesis .
1.969  qed
1.970
1.971 -lemma unit_factor_idem [simp]:
1.972 -  "unit_factor (unit_factor a) = unit_factor a"
1.973 +lemma unit_factor_idem [simp]: "unit_factor (unit_factor a) = unit_factor a"
1.974    by (cases "a = 0") (auto intro: is_unit_unit_factor)
1.975
1.976 -lemma normalize_unit_factor [simp]:
1.977 -  "a \<noteq> 0 \<Longrightarrow> normalize (unit_factor a) = 1"
1.978 +lemma normalize_unit_factor [simp]: "a \<noteq> 0 \<Longrightarrow> normalize (unit_factor a) = 1"
1.979    by (rule is_unit_normalize) simp
1.980
1.981 -lemma normalize_idem [simp]:
1.982 -  "normalize (normalize a) = normalize a"
1.983 +lemma normalize_idem [simp]: "normalize (normalize a) = normalize a"
1.984  proof (cases "a = 0")
1.985 -  case True then show ?thesis by simp
1.986 +  case True
1.987 +  then show ?thesis by simp
1.988  next
1.989    case False
1.990 -  have "normalize a = normalize (unit_factor a * normalize a)" by simp
1.991 +  have "normalize a = normalize (unit_factor a * normalize a)"
1.992 +    by simp
1.993    also have "\<dots> = normalize (unit_factor a) * normalize (normalize a)"
1.994      by (simp only: normalize_mult)
1.995 -  finally show ?thesis using False by simp_all
1.996 +  finally show ?thesis
1.997 +    using False by simp_all
1.998  qed
1.999
1.1000  lemma unit_factor_normalize [simp]:
1.1001    assumes "a \<noteq> 0"
1.1002    shows "unit_factor (normalize a) = 1"
1.1003  proof -
1.1004 -  from assms have "normalize a \<noteq> 0" by simp
1.1005 +  from assms have *: "normalize a \<noteq> 0"
1.1006 +    by simp
1.1007    have "unit_factor (normalize a) * normalize (normalize a) = normalize a"
1.1008      by (simp only: unit_factor_mult_normalize)
1.1009    then have "unit_factor (normalize a) * normalize a = normalize a"
1.1010      by simp
1.1011 -  with \<open>normalize a \<noteq> 0\<close>
1.1012 -  have "unit_factor (normalize a) * normalize a div normalize a = normalize a div normalize a"
1.1013 +  with * have "unit_factor (normalize a) * normalize a div normalize a = normalize a div normalize a"
1.1014      by simp
1.1015 -  with \<open>normalize a \<noteq> 0\<close>
1.1016 -  show ?thesis by simp
1.1017 +  with * show ?thesis
1.1018 +    by simp
1.1019  qed
1.1020
1.1021  lemma dvd_unit_factor_div:
1.1022 @@ -1196,8 +1135,7 @@
1.1023      by (cases "b = 0") (simp_all add: normalize_mult)
1.1024  qed
1.1025
1.1026 -lemma normalize_dvd_iff [simp]:
1.1027 -  "normalize a dvd b \<longleftrightarrow> a dvd b"
1.1028 +lemma normalize_dvd_iff [simp]: "normalize a dvd b \<longleftrightarrow> a dvd b"
1.1029  proof -
1.1030    have "normalize a dvd b \<longleftrightarrow> unit_factor a * normalize a dvd b"
1.1031      using mult_unit_dvd_iff [of "unit_factor a" "normalize a" b]
1.1032 @@ -1205,8 +1143,7 @@
1.1033    then show ?thesis by simp
1.1034  qed
1.1035
1.1036 -lemma dvd_normalize_iff [simp]:
1.1037 -  "a dvd normalize b \<longleftrightarrow> a dvd b"
1.1038 +lemma dvd_normalize_iff [simp]: "a dvd normalize b \<longleftrightarrow> a dvd b"
1.1039  proof -
1.1040    have "a dvd normalize  b \<longleftrightarrow> a dvd normalize b * unit_factor b"
1.1041      using dvd_mult_unit_iff [of "unit_factor b" a "normalize b"]
1.1042 @@ -1226,36 +1163,38 @@
1.1043    assumes "a dvd b" and "b dvd a"
1.1044    shows "normalize a = normalize b"
1.1045  proof (cases "a = 0 \<or> b = 0")
1.1046 -  case True with assms show ?thesis by auto
1.1047 +  case True
1.1048 +  with assms show ?thesis by auto
1.1049  next
1.1050    case False
1.1051    from \<open>a dvd b\<close> obtain c where b: "b = a * c" ..
1.1052    moreover from \<open>b dvd a\<close> obtain d where a: "a = b * d" ..
1.1053 -  ultimately have "b * 1 = b * (c * d)" by (simp add: ac_simps)
1.1054 +  ultimately have "b * 1 = b * (c * d)"
1.1055 +    by (simp add: ac_simps)
1.1056    with False have "1 = c * d"
1.1057      unfolding mult_cancel_left by simp
1.1058 -  then have "is_unit c" and "is_unit d" by auto
1.1059 -  with a b show ?thesis by (simp add: normalize_mult is_unit_normalize)
1.1060 +  then have "is_unit c" and "is_unit d"
1.1061 +    by auto
1.1062 +  with a b show ?thesis
1.1063 +    by (simp add: normalize_mult is_unit_normalize)
1.1064  qed
1.1065
1.1066 -lemma associatedD1:
1.1067 -  "normalize a = normalize b \<Longrightarrow> a dvd b"
1.1068 +lemma associatedD1: "normalize a = normalize b \<Longrightarrow> a dvd b"
1.1069    using dvd_normalize_iff [of _ b, symmetric] normalize_dvd_iff [of a _, symmetric]
1.1070    by simp
1.1071
1.1072 -lemma associatedD2:
1.1073 -  "normalize a = normalize b \<Longrightarrow> b dvd a"
1.1074 +lemma associatedD2: "normalize a = normalize b \<Longrightarrow> b dvd a"
1.1075    using dvd_normalize_iff [of _ a, symmetric] normalize_dvd_iff [of b _, symmetric]
1.1076    by simp
1.1077
1.1078 -lemma associated_unit:
1.1079 -  "normalize a = normalize b \<Longrightarrow> is_unit a \<Longrightarrow> is_unit b"
1.1080 +lemma associated_unit: "normalize a = normalize b \<Longrightarrow> is_unit a \<Longrightarrow> is_unit b"
1.1081    using dvd_unit_imp_unit by (auto dest!: associatedD1 associatedD2)
1.1082
1.1083 -lemma associated_iff_dvd:
1.1084 -  "normalize a = normalize b \<longleftrightarrow> a dvd b \<and> b dvd a" (is "?P \<longleftrightarrow> ?Q")
1.1085 +lemma associated_iff_dvd: "normalize a = normalize b \<longleftrightarrow> a dvd b \<and> b dvd a"
1.1086 +  (is "?P \<longleftrightarrow> ?Q")
1.1087  proof
1.1088 -  assume ?Q then show ?P by (auto intro!: associatedI)
1.1089 +  assume ?Q
1.1090 +  then show ?P by (auto intro!: associatedI)
1.1091  next
1.1092    assume ?P
1.1093    then have "unit_factor a * normalize a = unit_factor a * normalize b"
1.1094 @@ -1264,7 +1203,8 @@
1.1096    show ?Q
1.1097    proof (cases "a = 0 \<or> b = 0")
1.1098 -    case True with \<open>?P\<close> show ?thesis by auto
1.1099 +    case True
1.1100 +    with \<open>?P\<close> show ?thesis by auto
1.1101    next
1.1102      case False
1.1103      then have "b dvd normalize b * unit_factor a" and "normalize b * unit_factor a dvd b"
1.1104 @@ -1291,38 +1231,38 @@
1.1105    assumes mult_right_mono: "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * c"
1.1106  begin
1.1107
1.1108 -lemma mult_mono:
1.1109 -  "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * d"
1.1110 -apply (erule mult_right_mono [THEN order_trans], assumption)
1.1111 -apply (erule mult_left_mono, assumption)
1.1112 -done
1.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"
1.1114 +  apply (erule (1) mult_right_mono [THEN order_trans])
1.1115 +  apply (erule (1) mult_left_mono)
1.1116 +  done
1.1117
1.1118 -lemma mult_mono':
1.1119 -  "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> 0 \<le> a \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * d"
1.1120 -apply (rule mult_mono)
1.1121 -apply (fast intro: order_trans)+
1.1122 -done
1.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"
1.1124 +  apply (rule mult_mono)
1.1125 +  apply (fast intro: order_trans)+
1.1126 +  done
1.1127
1.1128  end
1.1129
1.1130  class ordered_semiring_0 = semiring_0 + ordered_semiring
1.1131  begin
1.1132
1.1133 -lemma mult_nonneg_nonneg[simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * b"
1.1134 -using mult_left_mono [of 0 b a] by simp
1.1135 +lemma mult_nonneg_nonneg [simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * b"
1.1136 +  using mult_left_mono [of 0 b a] by simp
1.1137
1.1138  lemma mult_nonneg_nonpos: "0 \<le> a \<Longrightarrow> b \<le> 0 \<Longrightarrow> a * b \<le> 0"
1.1139 -using mult_left_mono [of b 0 a] by simp
1.1140 +  using mult_left_mono [of b 0 a] by simp
1.1141
1.1142  lemma mult_nonpos_nonneg: "a \<le> 0 \<Longrightarrow> 0 \<le> b \<Longrightarrow> a * b \<le> 0"
1.1143 -using mult_right_mono [of a 0 b] by simp
1.1144 +  using mult_right_mono [of a 0 b] by simp
1.1145
1.1146  text \<open>Legacy - use \<open>mult_nonpos_nonneg\<close>\<close>
1.1147  lemma mult_nonneg_nonpos2: "0 \<le> a \<Longrightarrow> b \<le> 0 \<Longrightarrow> b * a \<le> 0"
1.1148 -by (drule mult_right_mono [of b 0], auto)
1.1149 +  apply (drule mult_right_mono [of b 0])
1.1150 +  apply auto
1.1151 +  done
1.1152
1.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"
1.1154 -by (auto simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)
1.1155 +  by (auto simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)
1.1156
1.1157  end
1.1158
1.1159 @@ -1341,44 +1281,34 @@
1.1160
1.1162
1.1163 -lemma mult_left_less_imp_less:
1.1164 -  "c * a < c * b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b"
1.1165 -by (force simp add: mult_left_mono not_le [symmetric])
1.1166 +lemma mult_left_less_imp_less: "c * a < c * b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b"
1.1167 +  by (force simp add: mult_left_mono not_le [symmetric])
1.1168
1.1169 -lemma mult_right_less_imp_less:
1.1170 -  "a * c < b * c \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b"
1.1171 -by (force simp add: mult_right_mono not_le [symmetric])
1.1172 +lemma mult_right_less_imp_less: "a * c < b * c \<Longrightarrow> 0 \<le> c \<Longrightarrow> a < b"
1.1173 +  by (force simp add: mult_right_mono not_le [symmetric])
1.1174
1.1176 -  "a \<le> a + b \<longleftrightarrow> 0 \<le> b"
1.1177 +lemma less_eq_add_cancel_left_greater_eq_zero [simp]: "a \<le> a + b \<longleftrightarrow> 0 \<le> b"
1.1178    using add_le_cancel_left [of a 0 b] by simp
1.1179
1.1181 -  "a + b \<le> a \<longleftrightarrow> b \<le> 0"
1.1182 +lemma less_eq_add_cancel_left_less_eq_zero [simp]: "a + b \<le> a \<longleftrightarrow> b \<le> 0"
1.1183    using add_le_cancel_left [of a b 0] by simp
1.1184
1.1186 -  "a \<le> b + a \<longleftrightarrow> 0 \<le> b"
1.1187 +lemma less_eq_add_cancel_right_greater_eq_zero [simp]: "a \<le> b + a \<longleftrightarrow> 0 \<le> b"
1.1188    using add_le_cancel_right [of 0 a b] by simp
1.1189
1.1191 -  "b + a \<le> a \<longleftrightarrow> b \<le> 0"
1.1192 +lemma less_eq_add_cancel_right_less_eq_zero [simp]: "b + a \<le> a \<longleftrightarrow> b \<le> 0"
1.1193    using add_le_cancel_right [of b a 0] by simp
1.1194
1.1196 -  "a < a + b \<longleftrightarrow> 0 < b"
1.1197 +lemma less_add_cancel_left_greater_zero [simp]: "a < a + b \<longleftrightarrow> 0 < b"
1.1198    using add_less_cancel_left [of a 0 b] by simp
1.1199
1.1201 -  "a + b < a \<longleftrightarrow> b < 0"
1.1202 +lemma less_add_cancel_left_less_zero [simp]: "a + b < a \<longleftrightarrow> b < 0"
1.1203    using add_less_cancel_left [of a b 0] by simp
1.1204
1.1206 -  "a < b + a \<longleftrightarrow> 0 < b"
1.1207 +lemma less_add_cancel_right_greater_zero [simp]: "a < b + a \<longleftrightarrow> 0 < b"
1.1208    using add_less_cancel_right [of 0 a b] by simp
1.1209
1.1211 -  "b + a < a \<longleftrightarrow> b < 0"
1.1212 +lemma less_add_cancel_right_less_zero [simp]: "b + a < a \<longleftrightarrow> b < 0"
1.1213    using add_less_cancel_right [of b a 0] by simp
1.1214
1.1215  end
1.1216 @@ -1392,7 +1322,8 @@
1.1217  proof-
1.1218    from assms have "u * x + v * y \<le> u * a + v * a"
1.1220 -  thus ?thesis using assms unfolding distrib_right[symmetric] by simp
1.1221 +  with assms show ?thesis
1.1222 +    unfolding distrib_right[symmetric] by simp
1.1223  qed
1.1224
1.1225  end
1.1226 @@ -1416,80 +1347,79 @@
1.1227      using mult_strict_right_mono by (cases "c = 0") auto
1.1228  qed
1.1229
1.1230 -lemma mult_left_le_imp_le:
1.1231 -  "c * a \<le> c * b \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b"
1.1232 -by (force simp add: mult_strict_left_mono _not_less [symmetric])
1.1233 +lemma mult_left_le_imp_le: "c * a \<le> c * b \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b"
1.1234 +  by (auto simp add: mult_strict_left_mono _not_less [symmetric])
1.1235
1.1236 -lemma mult_right_le_imp_le:
1.1237 -  "a * c \<le> b * c \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b"
1.1238 -by (force simp add: mult_strict_right_mono not_less [symmetric])
1.1239 +lemma mult_right_le_imp_le: "a * c \<le> b * c \<Longrightarrow> 0 < c \<Longrightarrow> a \<le> b"
1.1240 +  by (auto simp add: mult_strict_right_mono not_less [symmetric])
1.1241
1.1242  lemma mult_pos_pos[simp]: "0 < a \<Longrightarrow> 0 < b \<Longrightarrow> 0 < a * b"
1.1243 -using mult_strict_left_mono [of 0 b a] by simp
1.1244 +  using mult_strict_left_mono [of 0 b a] by simp
1.1245
1.1246  lemma mult_pos_neg: "0 < a \<Longrightarrow> b < 0 \<Longrightarrow> a * b < 0"
1.1247 -using mult_strict_left_mono [of b 0 a] by simp
1.1248 +  using mult_strict_left_mono [of b 0 a] by simp
1.1249
1.1250  lemma mult_neg_pos: "a < 0 \<Longrightarrow> 0 < b \<Longrightarrow> a * b < 0"
1.1251 -using mult_strict_right_mono [of a 0 b] by simp
1.1252 +  using mult_strict_right_mono [of a 0 b] by simp
1.1253
1.1254  text \<open>Legacy - use \<open>mult_neg_pos\<close>\<close>
1.1255  lemma mult_pos_neg2: "0 < a \<Longrightarrow> b < 0 \<Longrightarrow> b * a < 0"
1.1256 -by (drule mult_strict_right_mono [of b 0], auto)
1.1257 -
1.1258 -lemma zero_less_mult_pos:
1.1259 -  "0 < a * b \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b"
1.1260 -apply (cases "b\<le>0")
1.1261 - apply (auto simp add: le_less not_less)
1.1262 -apply (drule_tac mult_pos_neg [of a b])
1.1263 - apply (auto dest: less_not_sym)
1.1264 -done
1.1265 +  apply (drule mult_strict_right_mono [of b 0])
1.1266 +  apply auto
1.1267 +  done
1.1268
1.1269 -lemma zero_less_mult_pos2:
1.1270 -  "0 < b * a \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b"
1.1271 -apply (cases "b\<le>0")
1.1272 - apply (auto simp add: le_less not_less)
1.1273 -apply (drule_tac mult_pos_neg2 [of a b])
1.1274 - apply (auto dest: less_not_sym)
1.1275 -done
1.1276 +lemma zero_less_mult_pos: "0 < a * b \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b"
1.1277 +  apply (cases "b \<le> 0")
1.1278 +   apply (auto simp add: le_less not_less)
1.1279 +  apply (drule_tac mult_pos_neg [of a b])
1.1280 +   apply (auto dest: less_not_sym)
1.1281 +  done
1.1282
1.1283 -text\<open>Strict monotonicity in both arguments\<close>
1.1284 +lemma zero_less_mult_pos2: "0 < b * a \<Longrightarrow> 0 < a \<Longrightarrow> 0 < b"
1.1285 +  apply (cases "b \<le> 0")
1.1286 +   apply (auto simp add: le_less not_less)
1.1287 +  apply (drule_tac mult_pos_neg2 [of a b])
1.1288 +   apply (auto dest: less_not_sym)
1.1289 +  done
1.1290 +
1.1291 +text \<open>Strict monotonicity in both arguments\<close>
1.1292  lemma mult_strict_mono:
1.1293    assumes "a < b" and "c < d" and "0 < b" and "0 \<le> c"
1.1294    shows "a * c < b * d"
1.1295 -  using assms apply (cases "c=0")
1.1296 -  apply (simp)
1.1297 +  using assms
1.1298 +  apply (cases "c = 0")
1.1299 +  apply simp
1.1300    apply (erule mult_strict_right_mono [THEN less_trans])
1.1301 -  apply (force simp add: le_less)
1.1302 -  apply (erule mult_strict_left_mono, assumption)
1.1303 +  apply (auto simp add: le_less)
1.1304 +  apply (erule (1) mult_strict_left_mono)
1.1305    done
1.1306
1.1307 -text\<open>This weaker variant has more natural premises\<close>
1.1308 +text \<open>This weaker variant has more natural premises\<close>
1.1309  lemma mult_strict_mono':
1.1310    assumes "a < b" and "c < d" and "0 \<le> a" and "0 \<le> c"
1.1311    shows "a * c < b * d"
1.1312 -by (rule mult_strict_mono) (insert assms, auto)
1.1313 +  by (rule mult_strict_mono) (insert assms, auto)
1.1314
1.1315  lemma mult_less_le_imp_less:
1.1316    assumes "a < b" and "c \<le> d" and "0 \<le> a" and "0 < c"
1.1317    shows "a * c < b * d"
1.1318 -  using assms apply (subgoal_tac "a * c < b * c")
1.1319 +  using assms
1.1320 +  apply (subgoal_tac "a * c < b * c")
1.1321    apply (erule less_le_trans)
1.1322    apply (erule mult_left_mono)
1.1323    apply simp
1.1324 -  apply (erule mult_strict_right_mono)
1.1325 -  apply assumption
1.1326 +  apply (erule (1) mult_strict_right_mono)
1.1327    done
1.1328
1.1329  lemma mult_le_less_imp_less:
1.1330    assumes "a \<le> b" and "c < d" and "0 < a" and "0 \<le> c"
1.1331    shows "a * c < b * d"
1.1332 -  using assms apply (subgoal_tac "a * c \<le> b * c")
1.1333 +  using assms
1.1334 +  apply (subgoal_tac "a * c \<le> b * c")
1.1335    apply (erule le_less_trans)
1.1336    apply (erule mult_strict_left_mono)
1.1337    apply simp
1.1338 -  apply (erule mult_right_mono)
1.1339 -  apply simp
1.1340 +  apply (erule (1) mult_right_mono)
1.1341    done
1.1342
1.1343  end
1.1344 @@ -1504,9 +1434,9 @@
1.1345    shows "u * x + v * y < a"
1.1346  proof -
1.1347    from assms have "u * x + v * y < u * a + v * a"
1.1348 -    by (cases "u = 0")
1.1349 -       (auto intro!: add_less_le_mono mult_strict_left_mono mult_left_mono)
1.1350 -  thus ?thesis using assms unfolding distrib_right[symmetric] by simp
1.1351 +    by (cases "u = 0") (auto intro!: add_less_le_mono mult_strict_left_mono mult_left_mono)
1.1352 +  with assms show ?thesis
1.1353 +    unfolding distrib_right[symmetric] by simp
1.1354  qed
1.1355
1.1356  end
1.1357 @@ -1519,8 +1449,8 @@
1.1358  proof
1.1359    fix a b c :: 'a
1.1360    assume "a \<le> b" "0 \<le> c"
1.1361 -  thus "c * a \<le> c * b" by (rule comm_mult_left_mono)
1.1362 -  thus "a * c \<le> b * c" by (simp only: mult.commute)
1.1363 +  then show "c * a \<le> c * b" by (rule comm_mult_left_mono)
1.1364 +  then show "a * c \<le> b * c" by (simp only: mult.commute)
1.1365  qed
1.1366
1.1367  end
1.1368 @@ -1542,15 +1472,15 @@
1.1369  proof
1.1370    fix a b c :: 'a
1.1371    assume "a < b" "0 < c"
1.1372 -  thus "c * a < c * b" by (rule comm_mult_strict_left_mono)
1.1373 -  thus "a * c < b * c" by (simp only: mult.commute)
1.1374 +  then show "c * a < c * b" by (rule comm_mult_strict_left_mono)
1.1375 +  then show "a * c < b * c" by (simp only: mult.commute)
1.1376  qed
1.1377
1.1378  subclass ordered_cancel_comm_semiring
1.1379  proof
1.1380    fix a b c :: 'a
1.1381    assume "a \<le> b" "0 \<le> c"
1.1382 -  thus "c * a \<le> c * b"
1.1383 +  then show "c * a \<le> c * b"
1.1384      unfolding le_less
1.1385      using mult_strict_left_mono by (cases "c = 0") auto
1.1386  qed
1.1387 @@ -1562,40 +1492,33 @@
1.1388
1.1390
1.1392 -  "a * e + c < b * e + d \<longleftrightarrow> (a - b) * e + c < d"
1.1394 +lemma less_add_iff1: "a * e + c < b * e + d \<longleftrightarrow> (a - b) * e + c < d"
1.1395 +  by (simp add: algebra_simps)
1.1396
1.1398 -  "a * e + c < b * e + d \<longleftrightarrow> c < (b - a) * e + d"
1.1400 +lemma less_add_iff2: "a * e + c < b * e + d \<longleftrightarrow> c < (b - a) * e + d"
1.1401 +  by (simp add: algebra_simps)
1.1402
1.1404 -  "a * e + c \<le> b * e + d \<longleftrightarrow> (a - b) * e + c \<le> d"
1.1406 +lemma le_add_iff1: "a * e + c \<le> b * e + d \<longleftrightarrow> (a - b) * e + c \<le> d"
1.1407 +  by (simp add: algebra_simps)
1.1408
1.1410 -  "a * e + c \<le> b * e + d \<longleftrightarrow> c \<le> (b - a) * e + d"
1.1412 +lemma le_add_iff2: "a * e + c \<le> b * e + d \<longleftrightarrow> c \<le> (b - a) * e + d"
1.1413 +  by (simp add: algebra_simps)
1.1414
1.1415 -lemma mult_left_mono_neg:
1.1416 -  "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> c * a \<le> c * b"
1.1417 +lemma mult_left_mono_neg: "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> c * a \<le> c * b"
1.1418    apply (drule mult_left_mono [of _ _ "- c"])
1.1419    apply simp_all
1.1420    done
1.1421
1.1422 -lemma mult_right_mono_neg:
1.1423 -  "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> a * c \<le> b * c"
1.1424 +lemma mult_right_mono_neg: "b \<le> a \<Longrightarrow> c \<le> 0 \<Longrightarrow> a * c \<le> b * c"
1.1425    apply (drule mult_right_mono [of _ _ "- c"])
1.1426    apply simp_all
1.1427    done
1.1428
1.1429  lemma mult_nonpos_nonpos: "a \<le> 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> 0 \<le> a * b"
1.1430 -using mult_right_mono_neg [of a 0 b] by simp
1.1431 +  using mult_right_mono_neg [of a 0 b] by simp
1.1432
1.1433 -lemma split_mult_pos_le:
1.1434 -  "(0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0) \<Longrightarrow> 0 \<le> a * b"
1.1435 -by (auto simp add: mult_nonpos_nonpos)
1.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"
1.1437 +  by (auto simp add: mult_nonpos_nonpos)
1.1438
1.1439  end
1.1440
1.1441 @@ -1608,12 +1531,12 @@
1.1442  proof
1.1443    fix a b
1.1444    show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>"
1.1446 +    by (auto simp add: abs_if not_le not_less algebra_simps
1.1448  qed (auto simp add: abs_if)
1.1449
1.1450  lemma zero_le_square [simp]: "0 \<le> a * a"
1.1451 -  using linear [of 0 a]
1.1452 -  by (auto simp add: mult_nonpos_nonpos)
1.1453 +  using linear [of 0 a] by (auto simp add: mult_nonpos_nonpos)
1.1454
1.1455  lemma not_square_less_zero [simp]: "\<not> (a * a < 0)"
1.1457 @@ -1621,12 +1544,10 @@
1.1458  proposition abs_eq_iff: "\<bar>x\<bar> = \<bar>y\<bar> \<longleftrightarrow> x = y \<or> x = -y"
1.1459    by (auto simp add: abs_if split: if_split_asm)
1.1460
1.1461 -lemma sum_squares_ge_zero:
1.1462 -  "0 \<le> x * x + y * y"
1.1463 +lemma sum_squares_ge_zero: "0 \<le> x * x + y * y"
1.1465
1.1466 -lemma not_sum_squares_lt_zero:
1.1467 -  "\<not> x * x + y * y < 0"
1.1468 +lemma not_sum_squares_lt_zero: "\<not> x * x + y * y < 0"
1.1469    by (simp add: not_less sum_squares_ge_zero)
1.1470
1.1471  end
1.1472 @@ -1638,40 +1559,49 @@
1.1473  subclass linordered_ring ..
1.1474
1.1475  lemma mult_strict_left_mono_neg: "b < a \<Longrightarrow> c < 0 \<Longrightarrow> c * a < c * b"
1.1476 -using mult_strict_left_mono [of b a "- c"] by simp
1.1477 +  using mult_strict_left_mono [of b a "- c"] by simp
1.1478
1.1479  lemma mult_strict_right_mono_neg: "b < a \<Longrightarrow> c < 0 \<Longrightarrow> a * c < b * c"
1.1480 -using mult_strict_right_mono [of b a "- c"] by simp
1.1481 +  using mult_strict_right_mono [of b a "- c"] by simp
1.1482
1.1483  lemma mult_neg_neg: "a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> 0 < a * b"
1.1484 -using mult_strict_right_mono_neg [of a 0 b] by simp
1.1485 +  using mult_strict_right_mono_neg [of a 0 b] by simp
1.1486
1.1487  subclass ring_no_zero_divisors
1.1488  proof
1.1489    fix a b
1.1490 -  assume "a \<noteq> 0" then have A: "a < 0 \<or> 0 < a" by (simp add: neq_iff)
1.1491 -  assume "b \<noteq> 0" then have B: "b < 0 \<or> 0 < b" by (simp add: neq_iff)
1.1492 +  assume "a \<noteq> 0"
1.1493 +  then have A: "a < 0 \<or> 0 < a" by (simp add: neq_iff)
1.1494 +  assume "b \<noteq> 0"
1.1495 +  then have B: "b < 0 \<or> 0 < b" by (simp add: neq_iff)
1.1496    have "a * b < 0 \<or> 0 < a * b"
1.1497    proof (cases "a < 0")
1.1498 -    case True note A' = this
1.1499 -    show ?thesis proof (cases "b < 0")
1.1500 -      case True with A'
1.1501 -      show ?thesis by (auto dest: mult_neg_neg)
1.1502 +    case A': True
1.1503 +    show ?thesis
1.1504 +    proof (cases "b < 0")
1.1505 +      case True
1.1506 +      with A' show ?thesis by (auto dest: mult_neg_neg)
1.1507      next
1.1508 -      case False with B have "0 < b" by auto
1.1509 +      case False
1.1510 +      with B have "0 < b" by auto
1.1511        with A' show ?thesis by (auto dest: mult_strict_right_mono)
1.1512      qed
1.1513    next
1.1514 -    case False with A have A': "0 < a" by auto
1.1515 -    show ?thesis proof (cases "b < 0")
1.1516 -      case True with A'
1.1517 -      show ?thesis by (auto dest: mult_strict_right_mono_neg)
1.1518 +    case False
1.1519 +    with A have A': "0 < a" by auto
1.1520 +    show ?thesis
1.1521 +    proof (cases "b < 0")
1.1522 +      case True
1.1523 +      with A' show ?thesis
1.1524 +        by (auto dest: mult_strict_right_mono_neg)
1.1525      next
1.1526 -      case False with B have "0 < b" by auto
1.1527 +      case False
1.1528 +      with B have "0 < b" by auto
1.1529        with A' show ?thesis by auto
1.1530      qed
1.1531    qed
1.1532 -  then show "a * b \<noteq> 0" by (simp add: neq_iff)
1.1533 +  then show "a * b \<noteq> 0"
1.1534 +    by (simp add: neq_iff)
1.1535  qed
1.1536
1.1537  lemma zero_less_mult_iff: "0 < a * b \<longleftrightarrow> 0 < a \<and> 0 < b \<or> a < 0 \<and> b < 0"
1.1538 @@ -1681,84 +1611,66 @@
1.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"
1.1540    by (auto simp add: eq_commute [of 0] le_less not_less zero_less_mult_iff)
1.1541
1.1542 -lemma mult_less_0_iff:
1.1543 -  "a * b < 0 \<longleftrightarrow> 0 < a \<and> b < 0 \<or> a < 0 \<and> 0 < b"
1.1544 -  apply (insert zero_less_mult_iff [of "-a" b])
1.1545 -  apply force
1.1546 -  done
1.1547 +lemma mult_less_0_iff: "a * b < 0 \<longleftrightarrow> 0 < a \<and> b < 0 \<or> a < 0 \<and> 0 < b"
1.1548 +  using zero_less_mult_iff [of "- a" b] by auto
1.1549
1.1550 -lemma mult_le_0_iff:
1.1551 -  "a * b \<le> 0 \<longleftrightarrow> 0 \<le> a \<and> b \<le> 0 \<or> a \<le> 0 \<and> 0 \<le> b"
1.1552 -  apply (insert zero_le_mult_iff [of "-a" b])
1.1553 -  apply force
1.1554 -  done
1.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"
1.1556 +  using zero_le_mult_iff [of "- a" b] by auto
1.1557
1.1558 -text\<open>Cancellation laws for @{term "c*a < c*b"} and @{term "a*c < b*c"},
1.1559 -   also with the relations \<open>\<le>\<close> and equality.\<close>
1.1560 +text \<open>
1.1561 +  Cancellation laws for @{term "c * a < c * b"} and @{term "a * c < b * c"},
1.1562 +  also with the relations \<open>\<le>\<close> and equality.
1.1563 +\<close>
1.1564
1.1565 -text\<open>These disjunction'' versions produce two cases when the comparison is
1.1566 - an assumption, but effectively four when the comparison is a goal.\<close>
1.1567 +text \<open>
1.1568 +  These disjunction'' versions produce two cases when the comparison is
1.1569 +  an assumption, but effectively four when the comparison is a goal.
1.1570 +\<close>
1.1571
1.1572 -lemma mult_less_cancel_right_disj:
1.1573 -  "a * c < b * c \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and>  b < a"
1.1574 +lemma mult_less_cancel_right_disj: "a * c < b * c \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and>  b < a"
1.1575    apply (cases "c = 0")
1.1576 -  apply (auto simp add: neq_iff mult_strict_right_mono
1.1577 -                      mult_strict_right_mono_neg)
1.1578 -  apply (auto simp add: not_less
1.1579 -                      not_le [symmetric, of "a*c"]
1.1580 -                      not_le [symmetric, of a])
1.1581 +  apply (auto simp add: neq_iff mult_strict_right_mono mult_strict_right_mono_neg)
1.1582 +  apply (auto simp add: not_less not_le [symmetric, of "a*c"] not_le [symmetric, of a])
1.1583    apply (erule_tac [!] notE)
1.1584 -  apply (auto simp add: less_imp_le mult_right_mono
1.1585 -                      mult_right_mono_neg)
1.1586 +  apply (auto simp add: less_imp_le mult_right_mono mult_right_mono_neg)
1.1587    done
1.1588
1.1589 -lemma mult_less_cancel_left_disj:
1.1590 -  "c * a < c * b \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and>  b < a"
1.1591 +lemma mult_less_cancel_left_disj: "c * a < c * b \<longleftrightarrow> 0 < c \<and> a < b \<or> c < 0 \<and>  b < a"
1.1592    apply (cases "c = 0")
1.1593 -  apply (auto simp add: neq_iff mult_strict_left_mono
1.1594 -                      mult_strict_left_mono_neg)
1.1595 -  apply (auto simp add: not_less
1.1596 -                      not_le [symmetric, of "c*a"]
1.1597 -                      not_le [symmetric, of a])
1.1598 +  apply (auto simp add: neq_iff mult_strict_left_mono mult_strict_left_mono_neg)
1.1599 +  apply (auto simp add: not_less not_le [symmetric, of "c * a"] not_le [symmetric, of a])
1.1600    apply (erule_tac [!] notE)
1.1601 -  apply (auto simp add: less_imp_le mult_left_mono
1.1602 -                      mult_left_mono_neg)
1.1603 +  apply (auto simp add: less_imp_le mult_left_mono mult_left_mono_neg)
1.1604    done
1.1605
1.1606 -text\<open>The conjunction of implication'' lemmas produce two cases when the
1.1607 -comparison is a goal, but give four when the comparison is an assumption.\<close>
1.1608 +text \<open>
1.1609 +  The conjunction of implication'' lemmas produce two cases when the
1.1610 +  comparison is a goal, but give four when the comparison is an assumption.
1.1611 +\<close>
1.1612
1.1613 -lemma mult_less_cancel_right:
1.1614 -  "a * c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)"
1.1615 +lemma mult_less_cancel_right: "a * c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)"
1.1616    using mult_less_cancel_right_disj [of a c b] by auto
1.1617
1.1618 -lemma mult_less_cancel_left:
1.1619 -  "c * a < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)"
1.1620 +lemma mult_less_cancel_left: "c * a < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < b) \<and> (c \<le> 0 \<longrightarrow> b < a)"
1.1621    using mult_less_cancel_left_disj [of c a b] by auto
1.1622
1.1623 -lemma mult_le_cancel_right:
1.1624 -   "a * c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
1.1625 -by (simp add: not_less [symmetric] mult_less_cancel_right_disj)
1.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)"
1.1627 +  by (simp add: not_less [symmetric] mult_less_cancel_right_disj)
1.1628
1.1629 -lemma mult_le_cancel_left:
1.1630 -  "c * a \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)"
1.1631 -by (simp add: not_less [symmetric] mult_less_cancel_left_disj)
1.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)"
1.1633 +  by (simp add: not_less [symmetric] mult_less_cancel_left_disj)
1.1634
1.1635 -lemma mult_le_cancel_left_pos:
1.1636 -  "0 < c \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> a \<le> b"
1.1637 -by (auto simp: mult_le_cancel_left)
1.1638 +lemma mult_le_cancel_left_pos: "0 < c \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> a \<le> b"
1.1639 +  by (auto simp: mult_le_cancel_left)
1.1640
1.1641 -lemma mult_le_cancel_left_neg:
1.1642 -  "c < 0 \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> b \<le> a"
1.1643 -by (auto simp: mult_le_cancel_left)
1.1644 +lemma mult_le_cancel_left_neg: "c < 0 \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> b \<le> a"
1.1645 +  by (auto simp: mult_le_cancel_left)
1.1646
1.1647 -lemma mult_less_cancel_left_pos:
1.1648 -  "0 < c \<Longrightarrow> c * a < c * b \<longleftrightarrow> a < b"
1.1649 -by (auto simp: mult_less_cancel_left)
1.1650 +lemma mult_less_cancel_left_pos: "0 < c \<Longrightarrow> c * a < c * b \<longleftrightarrow> a < b"
1.1651 +  by (auto simp: mult_less_cancel_left)
1.1652
1.1653 -lemma mult_less_cancel_left_neg:
1.1654 -  "c < 0 \<Longrightarrow> c * a < c * b \<longleftrightarrow> b < a"
1.1655 -by (auto simp: mult_less_cancel_left)
1.1656 +lemma mult_less_cancel_left_neg: "c < 0 \<Longrightarrow> c * a < c * b \<longleftrightarrow> b < a"
1.1657 +  by (auto simp: mult_less_cancel_left)
1.1658
1.1659  end
1.1660
1.1661 @@ -1783,19 +1695,19 @@
1.1662  begin
1.1663
1.1664  subclass zero_neq_one
1.1665 -  proof qed (insert zero_less_one, blast)
1.1666 +  by standard (insert zero_less_one, blast)
1.1667
1.1668  subclass comm_semiring_1
1.1669 -  proof qed (rule mult_1_left)
1.1670 +  by standard (rule mult_1_left)
1.1671
1.1672  lemma zero_le_one [simp]: "0 \<le> 1"
1.1673 -by (rule zero_less_one [THEN less_imp_le])
1.1674 +  by (rule zero_less_one [THEN less_imp_le])
1.1675
1.1676  lemma not_one_le_zero [simp]: "\<not> 1 \<le> 0"
1.1678 +  by (simp add: not_le)
1.1679
1.1680  lemma not_one_less_zero [simp]: "\<not> 1 < 0"
1.1682 +  by (simp add: not_less)
1.1683
1.1684  lemma mult_left_le: "c \<le> 1 \<Longrightarrow> 0 \<le> a \<Longrightarrow> a * c \<le> a"
1.1685    using mult_left_mono[of c 1 a] by simp
1.1686 @@ -1812,8 +1724,7 @@
1.1687    assumes le_add_diff_inverse2 [simp]: "b \<le> a \<Longrightarrow> a - b + b = a"
1.1688  begin
1.1689
1.1690 -subclass linordered_nonzero_semiring
1.1691 -  proof qed
1.1692 +subclass linordered_nonzero_semiring ..
1.1693
1.1694  text \<open>Addition is the inverse of subtraction.\<close>
1.1695
1.1696 @@ -1823,31 +1734,31 @@
1.1697  lemma add_diff_inverse: "\<not> a < b \<Longrightarrow> b + (a - b) = a"
1.1698    by simp
1.1699
1.1701 -  shows "i + k \<le> n \<Longrightarrow> i \<le> n - k"
1.1702 +lemma add_le_imp_le_diff: "i + k \<le> n \<Longrightarrow> i \<le> n - k"
1.1703    apply (subst add_le_cancel_right [where c=k, symmetric])
1.1705    apply (simp only: add.assoc [symmetric])
1.1706 -  using add_implies_diff by fastforce
1.1707 +  using add_implies_diff apply fastforce
1.1708 +  done
1.1709
1.1711 -  assumes a1: "i + k \<le> n"
1.1712 -      and a2: "n \<le> j + k"
1.1713 -  shows "\<lbrakk>i + k \<le> n; n \<le> j + k\<rbrakk> \<Longrightarrow> n - k \<le> j"
1.1714 +  assumes 1: "i + k \<le> n"
1.1715 +    and 2: "n \<le> j + k"
1.1716 +  shows "i + k \<le> n \<Longrightarrow> n \<le> j + k \<Longrightarrow> n - k \<le> j"
1.1717  proof -
1.1718    have "n - (i + k) + (i + k) = n"
1.1719 -    using a1 by simp
1.1720 +    using 1 by simp
1.1721    moreover have "n - k = n - k - i + i"
1.1724    ultimately show ?thesis
1.1725 -    using a2
1.1726 +    using 2
1.1730 +    apply (rule add_le_imp_le_diff [of _ k "j + k", simplified add_diff_cancel_right'])
1.1732 +    done
1.1733  qed
1.1734
1.1735 -lemma less_1_mult:
1.1736 -  "1 < m \<Longrightarrow> 1 < n \<Longrightarrow> 1 < m * n"
1.1737 +lemma less_1_mult: "1 < m \<Longrightarrow> 1 < n \<Longrightarrow> 1 < m * n"
1.1738    using mult_strict_mono [of 1 m 1 n] by (simp add: less_trans [OF zero_less_one])
1.1739
1.1740  end
1.1741 @@ -1864,90 +1775,73 @@
1.1742  subclass linordered_semidom
1.1743  proof
1.1744    have "0 \<le> 1 * 1" by (rule zero_le_square)
1.1745 -  thus "0 < 1" by (simp add: le_less)
1.1746 -  show "\<And>b a. b \<le> a \<Longrightarrow> a - b + b = a"
1.1747 +  then show "0 < 1" by (simp add: le_less)
1.1748 +  show "b \<le> a \<Longrightarrow> a - b + b = a" for a b
1.1749      by simp
1.1750  qed
1.1751
1.1752  lemma linorder_neqE_linordered_idom:
1.1753 -  assumes "x \<noteq> y" obtains "x < y" | "y < x"
1.1754 +  assumes "x \<noteq> y"
1.1755 +  obtains "x < y" | "y < x"
1.1756    using assms by (rule neqE)
1.1757
1.1758  text \<open>These cancellation simprules also produce two cases when the comparison is a goal.\<close>
1.1759
1.1760 -lemma mult_le_cancel_right1:
1.1761 -  "c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)"
1.1762 -by (insert mult_le_cancel_right [of 1 c b], simp)
1.1763 +lemma mult_le_cancel_right1: "c \<le> b * c \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)"
1.1764 +  using mult_le_cancel_right [of 1 c b] by simp
1.1765
1.1766 -lemma mult_le_cancel_right2:
1.1767 -  "a * c \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)"
1.1768 -by (insert mult_le_cancel_right [of a c 1], simp)
1.1769 +lemma mult_le_cancel_right2: "a * c \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)"
1.1770 +  using mult_le_cancel_right [of a c 1] by simp
1.1771
1.1772 -lemma mult_le_cancel_left1:
1.1773 -  "c \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)"
1.1774 -by (insert mult_le_cancel_left [of c 1 b], simp)
1.1775 +lemma mult_le_cancel_left1: "c \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> 1 \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> 1)"
1.1776 +  using mult_le_cancel_left [of c 1 b] by simp
1.1777
1.1778 -lemma mult_le_cancel_left2:
1.1779 -  "c * a \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)"
1.1780 -by (insert mult_le_cancel_left [of c a 1], simp)
1.1781 +lemma mult_le_cancel_left2: "c * a \<le> c \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> 1) \<and> (c < 0 \<longrightarrow> 1 \<le> a)"
1.1782 +  using mult_le_cancel_left [of c a 1] by simp
1.1783
1.1784 -lemma mult_less_cancel_right1:
1.1785 -  "c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)"
1.1786 -by (insert mult_less_cancel_right [of 1 c b], simp)
1.1787 +lemma mult_less_cancel_right1: "c < b * c \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)"
1.1788 +  using mult_less_cancel_right [of 1 c b] by simp
1.1789
1.1790 -lemma mult_less_cancel_right2:
1.1791 -  "a * c < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)"
1.1792 -by (insert mult_less_cancel_right [of a c 1], simp)
1.1793 +lemma mult_less_cancel_right2: "a * c < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)"
1.1794 +  using mult_less_cancel_right [of a c 1] by simp
1.1795
1.1796 -lemma mult_less_cancel_left1:
1.1797 -  "c < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)"
1.1798 -by (insert mult_less_cancel_left [of c 1 b], simp)
1.1799 +lemma mult_less_cancel_left1: "c < c * b \<longleftrightarrow> (0 \<le> c \<longrightarrow> 1 < b) \<and> (c \<le> 0 \<longrightarrow> b < 1)"
1.1800 +  using mult_less_cancel_left [of c 1 b] by simp
1.1801
1.1802 -lemma mult_less_cancel_left2:
1.1803 -  "c * a < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)"
1.1804 -by (insert mult_less_cancel_left [of c a 1], simp)
1.1805 +lemma mult_less_cancel_left2: "c * a < c \<longleftrightarrow> (0 \<le> c \<longrightarrow> a < 1) \<and> (c \<le> 0 \<longrightarrow> 1 < a)"
1.1806 +  using mult_less_cancel_left [of c a 1] by simp
1.1807
1.1808 -lemma sgn_sgn [simp]:
1.1809 -  "sgn (sgn a) = sgn a"
1.1810 -unfolding sgn_if by simp
1.1811 +lemma sgn_sgn [simp]: "sgn (sgn a) = sgn a"
1.1812 +  unfolding sgn_if by simp
1.1813
1.1814 -lemma sgn_0_0:
1.1815 -  "sgn a = 0 \<longleftrightarrow> a = 0"
1.1816 -unfolding sgn_if by simp
1.1817 +lemma sgn_0_0: "sgn a = 0 \<longleftrightarrow> a = 0"
1.1818 +  unfolding sgn_if by simp
1.1819
1.1820 -lemma sgn_1_pos:
1.1821 -  "sgn a = 1 \<longleftrightarrow> a > 0"
1.1822 -unfolding sgn_if by simp
1.1823 +lemma sgn_1_pos: "sgn a = 1 \<longleftrightarrow> a > 0"
1.1824 +  unfolding sgn_if by simp
1.1825
1.1826 -lemma sgn_1_neg:
1.1827 -  "sgn a = - 1 \<longleftrightarrow> a < 0"
1.1828 -unfolding sgn_if by auto
1.1829 +lemma sgn_1_neg: "sgn a = - 1 \<longleftrightarrow> a < 0"
1.1830 +  unfolding sgn_if by auto
1.1831
1.1832 -lemma sgn_pos [simp]:
1.1833 -  "0 < a \<Longrightarrow> sgn a = 1"
1.1834 -unfolding sgn_1_pos .
1.1835 +lemma sgn_pos [simp]: "0 < a \<Longrightarrow> sgn a = 1"
1.1836 +  by (simp only: sgn_1_pos)
1.1837
1.1838 -lemma sgn_neg [simp]:
1.1839 -  "a < 0 \<Longrightarrow> sgn a = - 1"
1.1840 -unfolding sgn_1_neg .
1.1841 +lemma sgn_neg [simp]: "a < 0 \<Longrightarrow> sgn a = - 1"
1.1842 +  by (simp only: sgn_1_neg)
1.1843
1.1844 -lemma sgn_times:
1.1845 -  "sgn (a * b) = sgn a * sgn b"
1.1846 -by (auto simp add: sgn_if zero_less_mult_iff)
1.1847 +lemma sgn_times: "sgn (a * b) = sgn a * sgn b"
1.1848 +  by (auto simp add: sgn_if zero_less_mult_iff)
1.1849
1.1850  lemma abs_sgn: "\<bar>k\<bar> = k * sgn k"
1.1851 -unfolding sgn_if abs_if by auto
1.1852 +  unfolding sgn_if abs_if by auto
1.1853
1.1854 -lemma sgn_greater [simp]:
1.1855 -  "0 < sgn a \<longleftrightarrow> 0 < a"
1.1856 +lemma sgn_greater [simp]: "0 < sgn a \<longleftrightarrow> 0 < a"
1.1857    unfolding sgn_if by auto
1.1858
1.1859 -lemma sgn_less [simp]:
1.1860 -  "sgn a < 0 \<longleftrightarrow> a < 0"
1.1861 +lemma sgn_less [simp]: "sgn a < 0 \<longleftrightarrow> a < 0"
1.1862    unfolding sgn_if by auto
1.1863
1.1864 -lemma abs_sgn_eq:
1.1865 -  "\<bar>sgn a\<bar> = (if a = 0 then 0 else 1)"
1.1866 +lemma abs_sgn_eq: "\<bar>sgn a\<bar> = (if a = 0 then 0 else 1)"
1.1868
1.1869  lemma abs_dvd_iff [simp]: "\<bar>m\<bar> dvd k \<longleftrightarrow> m dvd k"
1.1870 @@ -1956,36 +1850,31 @@
1.1871  lemma dvd_abs_iff [simp]: "m dvd \<bar>k\<bar> \<longleftrightarrow> m dvd k"
1.1873
1.1874 -lemma dvd_if_abs_eq:
1.1875 -  "\<bar>l\<bar> = \<bar>k\<bar> \<Longrightarrow> l dvd k"
1.1876 -by(subst abs_dvd_iff[symmetric]) simp
1.1877 +lemma dvd_if_abs_eq: "\<bar>l\<bar> = \<bar>k\<bar> \<Longrightarrow> l dvd k"
1.1878 +  by (subst abs_dvd_iff [symmetric]) simp
1.1879
1.1880 -text \<open>The following lemmas can be proven in more general structures, but
1.1881 -are dangerous as simp rules in absence of @{thm neg_equal_zero},
1.1882 -@{thm neg_less_pos}, @{thm neg_less_eq_nonneg}.\<close>
1.1883 +text \<open>
1.1884 +  The following lemmas can be proven in more general structures, but
1.1885 +  are dangerous as simp rules in absence of @{thm neg_equal_zero},
1.1886 +  @{thm neg_less_pos}, @{thm neg_less_eq_nonneg}.
1.1887 +\<close>
1.1888
1.1889 -lemma equation_minus_iff_1 [simp, no_atp]:
1.1890 -  "1 = - a \<longleftrightarrow> a = - 1"
1.1891 +lemma equation_minus_iff_1 [simp, no_atp]: "1 = - a \<longleftrightarrow> a = - 1"
1.1892    by (fact equation_minus_iff)
1.1893
1.1894 -lemma minus_equation_iff_1 [simp, no_atp]:
1.1895 -  "- a = 1 \<longleftrightarrow> a = - 1"
1.1896 +lemma minus_equation_iff_1 [simp, no_atp]: "- a = 1 \<longleftrightarrow> a = - 1"
1.1897    by (subst minus_equation_iff, auto)
1.1898
1.1899 -lemma le_minus_iff_1 [simp, no_atp]:
1.1900 -  "1 \<le> - b \<longleftrightarrow> b \<le> - 1"
1.1901 +lemma le_minus_iff_1 [simp, no_atp]: "1 \<le> - b \<longleftrightarrow> b \<le> - 1"
1.1902    by (fact le_minus_iff)
1.1903
1.1904 -lemma minus_le_iff_1 [simp, no_atp]:
1.1905 -  "- a \<le> 1 \<longleftrightarrow> - 1 \<le> a"
1.1906 +lemma minus_le_iff_1 [simp, no_atp]: "- a \<le> 1 \<longleftrightarrow> - 1 \<le> a"
1.1907    by (fact minus_le_iff)
1.1908
1.1909 -lemma less_minus_iff_1 [simp, no_atp]:
1.1910 -  "1 < - b \<longleftrightarrow> b < - 1"
1.1911 +lemma less_minus_iff_1 [simp, no_atp]: "1 < - b \<longleftrightarrow> b < - 1"
1.1912    by (fact less_minus_iff)
1.1913
1.1914 -lemma minus_less_iff_1 [simp, no_atp]:
1.1915 -  "- a < 1 \<longleftrightarrow> - 1 < a"
1.1916 +lemma minus_less_iff_1 [simp, no_atp]: "- a < 1 \<longleftrightarrow> - 1 < a"
1.1917    by (fact minus_less_iff)
1.1918
1.1919  end
1.1920 @@ -1993,15 +1882,16 @@
1.1921  text \<open>Simprules for comparisons where common factors can be cancelled.\<close>
1.1922
1.1923  lemmas mult_compare_simps =
1.1924 -    mult_le_cancel_right mult_le_cancel_left
1.1925 -    mult_le_cancel_right1 mult_le_cancel_right2
1.1926 -    mult_le_cancel_left1 mult_le_cancel_left2
1.1927 -    mult_less_cancel_right mult_less_cancel_left
1.1928 -    mult_less_cancel_right1 mult_less_cancel_right2
1.1929 -    mult_less_cancel_left1 mult_less_cancel_left2
1.1930 -    mult_cancel_right mult_cancel_left
1.1931 -    mult_cancel_right1 mult_cancel_right2
1.1932 -    mult_cancel_left1 mult_cancel_left2
1.1933 +  mult_le_cancel_right mult_le_cancel_left
1.1934 +  mult_le_cancel_right1 mult_le_cancel_right2
1.1935 +  mult_le_cancel_left1 mult_le_cancel_left2
1.1936 +  mult_less_cancel_right mult_less_cancel_left
1.1937 +  mult_less_cancel_right1 mult_less_cancel_right2
1.1938 +  mult_less_cancel_left1 mult_less_cancel_left2
1.1939 +  mult_cancel_right mult_cancel_left
1.1940 +  mult_cancel_right1 mult_cancel_right2
1.1941 +  mult_cancel_left1 mult_cancel_left2
1.1942 +
1.1943
1.1944  text \<open>Reasoning about inequalities with division\<close>
1.1945
1.1946 @@ -2012,7 +1902,7 @@
1.1947  proof -
1.1948    have "a + 0 < a + 1"
1.1949      by (blast intro: zero_less_one add_strict_left_mono)
1.1950 -  thus ?thesis by simp
1.1951 +  then show ?thesis by simp
1.1952  qed
1.1953
1.1954  end
1.1955 @@ -2020,12 +1910,10 @@
1.1956  context linordered_idom
1.1957  begin
1.1958
1.1959 -lemma mult_right_le_one_le:
1.1960 -  "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> x * y \<le> x"
1.1961 +lemma mult_right_le_one_le: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> x * y \<le> x"
1.1962    by (rule mult_left_le)
1.1963
1.1964 -lemma mult_left_le_one_le:
1.1965 -  "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> y * x \<le> x"
1.1966 +lemma mult_left_le_one_le: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> y * x \<le> x"
1.1967    by (auto simp add: mult_le_cancel_right2)
1.1968
1.1969  end
1.1970 @@ -2035,12 +1923,10 @@
1.1971  context linordered_idom
1.1972  begin
1.1973
1.1974 -lemma mult_sgn_abs:
1.1975 -  "sgn x * \<bar>x\<bar> = x"
1.1976 +lemma mult_sgn_abs: "sgn x * \<bar>x\<bar> = x"
1.1977    unfolding abs_if sgn_if by auto
1.1978
1.1979 -lemma abs_one [simp]:
1.1980 -  "\<bar>1\<bar> = 1"
1.1981 +lemma abs_one [simp]: "\<bar>1\<bar> = 1"
1.1983
1.1984  end
1.1985 @@ -2052,57 +1938,54 @@
1.1986  context linordered_idom
1.1987  begin
1.1988
1.1989 -subclass ordered_ring_abs proof
1.1990 -qed (auto simp add: abs_if not_less mult_less_0_iff)
1.1991 +subclass ordered_ring_abs
1.1992 +  by standard (auto simp add: abs_if not_less mult_less_0_iff)
1.1993
1.1994 -lemma abs_mult:
1.1995 -  "\<bar>a * b\<bar> = \<bar>a\<bar> * \<bar>b\<bar>"
1.1996 +lemma abs_mult: "\<bar>a * b\<bar> = \<bar>a\<bar> * \<bar>b\<bar>"
1.1997    by (rule abs_eq_mult) auto
1.1998
1.1999 -lemma abs_mult_self [simp]:
1.2000 -  "\<bar>a\<bar> * \<bar>a\<bar> = a * a"
1.2001 +lemma abs_mult_self [simp]: "\<bar>a\<bar> * \<bar>a\<bar> = a * a"
1.2003
1.2004  lemma abs_mult_less:
1.2005 -  "\<bar>a\<bar> < c \<Longrightarrow> \<bar>b\<bar> < d \<Longrightarrow> \<bar>a\<bar> * \<bar>b\<bar> < c * d"
1.2006 +  assumes ac: "\<bar>a\<bar> < c"
1.2007 +    and bd: "\<bar>b\<bar> < d"
1.2008 +  shows "\<bar>a\<bar> * \<bar>b\<bar> < c * d"
1.2009  proof -
1.2010 -  assume ac: "\<bar>a\<bar> < c"
1.2011 -  hence cpos: "0<c" by (blast intro: le_less_trans abs_ge_zero)
1.2012 -  assume "\<bar>b\<bar> < d"
1.2013 -  thus ?thesis by (simp add: ac cpos mult_strict_mono)
1.2014 +  from ac have "0 < c"
1.2015 +    by (blast intro: le_less_trans abs_ge_zero)
1.2016 +  with bd show ?thesis by (simp add: ac mult_strict_mono)
1.2017  qed
1.2018
1.2019 -lemma abs_less_iff:
1.2020 -  "\<bar>a\<bar> < b \<longleftrightarrow> a < b \<and> - a < b"
1.2021 +lemma abs_less_iff: "\<bar>a\<bar> < b \<longleftrightarrow> a < b \<and> - a < b"
1.2023
1.2024 -lemma abs_mult_pos:
1.2025 -  "0 \<le> x \<Longrightarrow> \<bar>y\<bar> * x = \<bar>y * x\<bar>"
1.2026 +lemma abs_mult_pos: "0 \<le> x \<Longrightarrow> \<bar>y\<bar> * x = \<bar>y * x\<bar>"
1.2028
1.2029 -lemma abs_diff_less_iff:
1.2030 -  "\<bar>x - a\<bar> < r \<longleftrightarrow> a - r < x \<and> x < a + r"
1.2031 +lemma abs_diff_less_iff: "\<bar>x - a\<bar> < r \<longleftrightarrow> a - r < x \<and> x < a + r"
1.2032    by (auto simp add: diff_less_eq ac_simps abs_less_iff)
1.2033
1.2034 -lemma abs_diff_le_iff:
1.2035 -   "\<bar>x - a\<bar> \<le> r \<longleftrightarrow> a - r \<le> x \<and> x \<le> a + r"
1.2036 +lemma abs_diff_le_iff: "\<bar>x - a\<bar> \<le> r \<longleftrightarrow> a - r \<le> x \<and> x \<le> a + r"
1.2037    by (auto simp add: diff_le_eq ac_simps abs_le_iff)
1.2038
1.2039  lemma abs_add_one_gt_zero: "0 < 1 + \<bar>x\<bar>"
1.2040 -  by (force simp: abs_if not_less intro: zero_less_one add_strict_increasing less_trans)
1.2041 +  by (auto simp: abs_if not_less intro: zero_less_one add_strict_increasing less_trans)
1.2042
1.2043  end
1.2044
1.2045  subsection \<open>Dioids\<close>
1.2046
1.2047 -text \<open>Dioids are the alternative extensions of semirings, a semiring can either be a ring or a dioid
1.2048 -but never both.\<close>
1.2049 +text \<open>
1.2050 +  Dioids are the alternative extensions of semirings, a semiring can
1.2051 +  either be a ring or a dioid but never both.
1.2052 +\<close>
1.2053
1.2054  class dioid = semiring_1 + canonically_ordered_monoid_add
1.2055  begin
1.2056
1.2057  subclass ordered_semiring
1.2058 -  proof qed (auto simp: le_iff_add distrib_left distrib_right)
1.2059 +  by standard (auto simp: le_iff_add distrib_left distrib_right)
1.2060
1.2061  end
1.2062