src/HOL/Library/Lattice_Algebras.thy
changeset 53240 07593a0a27f4
parent 46986 8198cbff1771
child 54230 b1d955791529
     1.1 --- a/src/HOL/Library/Lattice_Algebras.thy	Tue Aug 27 23:21:12 2013 +0200
     1.2 +++ b/src/HOL/Library/Lattice_Algebras.thy	Tue Aug 27 23:54:23 2013 +0200
     1.3 @@ -9,20 +9,19 @@
     1.4  class semilattice_inf_ab_group_add = ordered_ab_group_add + semilattice_inf
     1.5  begin
     1.6  
     1.7 -lemma add_inf_distrib_left:
     1.8 -  "a + inf b c = inf (a + b) (a + c)"
     1.9 -apply (rule antisym)
    1.10 -apply (simp_all add: le_infI)
    1.11 -apply (rule add_le_imp_le_left [of "uminus a"])
    1.12 -apply (simp only: add_assoc [symmetric], simp)
    1.13 -apply rule
    1.14 -apply (rule add_le_imp_le_left[of "a"], simp only: add_assoc[symmetric], simp)+
    1.15 -done
    1.16 +lemma add_inf_distrib_left: "a + inf b c = inf (a + b) (a + c)"
    1.17 +  apply (rule antisym)
    1.18 +  apply (simp_all add: le_infI)
    1.19 +  apply (rule add_le_imp_le_left [of "uminus a"])
    1.20 +  apply (simp only: add_assoc [symmetric], simp)
    1.21 +  apply rule
    1.22 +  apply (rule add_le_imp_le_left[of "a"], simp only: add_assoc[symmetric], simp)+
    1.23 +  done
    1.24  
    1.25 -lemma add_inf_distrib_right:
    1.26 -  "inf a b + c = inf (a + c) (b + c)"
    1.27 +lemma add_inf_distrib_right: "inf a b + c = inf (a + c) (b + c)"
    1.28  proof -
    1.29 -  have "c + inf a b = inf (c+a) (c+b)" by (simp add: add_inf_distrib_left)
    1.30 +  have "c + inf a b = inf (c+a) (c+b)"
    1.31 +    by (simp add: add_inf_distrib_left)
    1.32    thus ?thesis by (simp add: add_commute)
    1.33  qed
    1.34  
    1.35 @@ -31,19 +30,17 @@
    1.36  class semilattice_sup_ab_group_add = ordered_ab_group_add + semilattice_sup
    1.37  begin
    1.38  
    1.39 -lemma add_sup_distrib_left:
    1.40 -  "a + sup b c = sup (a + b) (a + c)" 
    1.41 -apply (rule antisym)
    1.42 -apply (rule add_le_imp_le_left [of "uminus a"])
    1.43 -apply (simp only: add_assoc[symmetric], simp)
    1.44 -apply rule
    1.45 -apply (rule add_le_imp_le_left [of "a"], simp only: add_assoc[symmetric], simp)+
    1.46 -apply (rule le_supI)
    1.47 -apply (simp_all)
    1.48 -done
    1.49 +lemma add_sup_distrib_left: "a + sup b c = sup (a + b) (a + c)"
    1.50 +  apply (rule antisym)
    1.51 +  apply (rule add_le_imp_le_left [of "uminus a"])
    1.52 +  apply (simp only: add_assoc[symmetric], simp)
    1.53 +  apply rule
    1.54 +  apply (rule add_le_imp_le_left [of "a"], simp only: add_assoc[symmetric], simp)+
    1.55 +  apply (rule le_supI)
    1.56 +  apply (simp_all)
    1.57 +  done
    1.58  
    1.59 -lemma add_sup_distrib_right:
    1.60 -  "sup a b + c = sup (a+c) (b+c)"
    1.61 +lemma add_sup_distrib_right: "sup a b + c = sup (a+c) (b+c)"
    1.62  proof -
    1.63    have "c + sup a b = sup (c+a) (c+b)" by (simp add: add_sup_distrib_left)
    1.64    thus ?thesis by (simp add: add_commute)
    1.65 @@ -57,69 +54,61 @@
    1.66  subclass semilattice_inf_ab_group_add ..
    1.67  subclass semilattice_sup_ab_group_add ..
    1.68  
    1.69 -lemmas add_sup_inf_distribs = add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left
    1.70 +lemmas add_sup_inf_distribs =
    1.71 +  add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left
    1.72  
    1.73  lemma inf_eq_neg_sup: "inf a b = - sup (-a) (-b)"
    1.74  proof (rule inf_unique)
    1.75 -  fix a b :: 'a
    1.76 +  fix a b c :: 'a
    1.77    show "- sup (-a) (-b) \<le> a"
    1.78      by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"])
    1.79        (simp, simp add: add_sup_distrib_left)
    1.80 -next
    1.81 -  fix a b :: 'a
    1.82    show "- sup (-a) (-b) \<le> b"
    1.83      by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"])
    1.84        (simp, simp add: add_sup_distrib_left)
    1.85 -next
    1.86 -  fix a b c :: 'a
    1.87    assume "a \<le> b" "a \<le> c"
    1.88 -  then show "a \<le> - sup (-b) (-c)" by (subst neg_le_iff_le [symmetric])
    1.89 -    (simp add: le_supI)
    1.90 +  then show "a \<le> - sup (-b) (-c)"
    1.91 +    by (subst neg_le_iff_le [symmetric]) (simp add: le_supI)
    1.92  qed
    1.93 -  
    1.94 +
    1.95  lemma sup_eq_neg_inf: "sup a b = - inf (-a) (-b)"
    1.96  proof (rule sup_unique)
    1.97 -  fix a b :: 'a
    1.98 +  fix a b c :: 'a
    1.99    show "a \<le> - inf (-a) (-b)"
   1.100      by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"])
   1.101        (simp, simp add: add_inf_distrib_left)
   1.102 -next
   1.103 -  fix a b :: 'a
   1.104    show "b \<le> - inf (-a) (-b)"
   1.105      by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"])
   1.106        (simp, simp add: add_inf_distrib_left)
   1.107 -next
   1.108 -  fix a b c :: 'a
   1.109    assume "a \<le> c" "b \<le> c"
   1.110 -  then show "- inf (-a) (-b) \<le> c" by (subst neg_le_iff_le [symmetric])
   1.111 -    (simp add: le_infI)
   1.112 +  then show "- inf (-a) (-b) \<le> c" by (subst neg_le_iff_le [symmetric]) (simp add: le_infI)
   1.113  qed
   1.114  
   1.115  lemma neg_inf_eq_sup: "- inf a b = sup (-a) (-b)"
   1.116 -by (simp add: inf_eq_neg_sup)
   1.117 +  by (simp add: inf_eq_neg_sup)
   1.118  
   1.119  lemma neg_sup_eq_inf: "- sup a b = inf (-a) (-b)"
   1.120 -by (simp add: sup_eq_neg_inf)
   1.121 +  by (simp add: sup_eq_neg_inf)
   1.122  
   1.123  lemma add_eq_inf_sup: "a + b = sup a b + inf a b"
   1.124  proof -
   1.125 -  have "0 = - inf 0 (a-b) + inf (a-b) 0" by (simp add: inf_commute)
   1.126 -  hence "0 = sup 0 (b-a) + inf (a-b) 0" by (simp add: inf_eq_neg_sup)
   1.127 +  have "0 = - inf 0 (a-b) + inf (a-b) 0"
   1.128 +    by (simp add: inf_commute)
   1.129 +  hence "0 = sup 0 (b-a) + inf (a-b) 0"
   1.130 +    by (simp add: inf_eq_neg_sup)
   1.131    hence "0 = (-a + sup a b) + (inf a b + (-b))"
   1.132 -    by (simp add: add_sup_distrib_left add_inf_distrib_right)
   1.133 -       (simp add: algebra_simps)
   1.134 +    by (simp add: add_sup_distrib_left add_inf_distrib_right) (simp add: algebra_simps)
   1.135    thus ?thesis by (simp add: algebra_simps)
   1.136  qed
   1.137  
   1.138 +
   1.139  subsection {* Positive Part, Negative Part, Absolute Value *}
   1.140  
   1.141 -definition
   1.142 -  nprt :: "'a \<Rightarrow> 'a" where
   1.143 -  "nprt x = inf x 0"
   1.144 +definition nprt :: "'a \<Rightarrow> 'a"
   1.145 +  where "nprt x = inf x 0"
   1.146  
   1.147 -definition
   1.148 -  pprt :: "'a \<Rightarrow> 'a" where
   1.149 -  "pprt x = sup x 0"
   1.150 +definition pprt :: "'a \<Rightarrow> 'a"
   1.151 +  where "pprt x = sup x 0"
   1.152  
   1.153  lemma pprt_neg: "pprt (- x) = - nprt x"
   1.154  proof -
   1.155 @@ -137,27 +126,29 @@
   1.156  qed
   1.157  
   1.158  lemma prts: "a = pprt a + nprt a"
   1.159 -by (simp add: pprt_def nprt_def add_eq_inf_sup[symmetric])
   1.160 +  by (simp add: pprt_def nprt_def add_eq_inf_sup[symmetric])
   1.161  
   1.162  lemma zero_le_pprt[simp]: "0 \<le> pprt a"
   1.163 -by (simp add: pprt_def)
   1.164 +  by (simp add: pprt_def)
   1.165  
   1.166  lemma nprt_le_zero[simp]: "nprt a \<le> 0"
   1.167 -by (simp add: nprt_def)
   1.168 +  by (simp add: nprt_def)
   1.169  
   1.170  lemma le_eq_neg: "a \<le> - b \<longleftrightarrow> a + b \<le> 0" (is "?l = ?r")
   1.171 -proof -
   1.172 -  have a: "?l \<longrightarrow> ?r"
   1.173 -    apply (auto)
   1.174 +proof
   1.175 +  assume ?l
   1.176 +  then show ?r
   1.177 +    apply -
   1.178      apply (rule add_le_imp_le_right[of _ "uminus b" _])
   1.179      apply (simp add: add_assoc)
   1.180      done
   1.181 -  have b: "?r \<longrightarrow> ?l"
   1.182 -    apply (auto)
   1.183 +next
   1.184 +  assume ?r
   1.185 +  then show ?l
   1.186 +    apply -
   1.187      apply (rule add_le_imp_le_right[of _ "b" _])
   1.188 -    apply (simp)
   1.189 +    apply simp
   1.190      done
   1.191 -  from a b show ?thesis by blast
   1.192  qed
   1.193  
   1.194  lemma pprt_0[simp]: "pprt 0 = 0" by (simp add: pprt_def)
   1.195 @@ -181,7 +172,7 @@
   1.196      fix a::'a
   1.197      assume hyp: "sup a (-a) = 0"
   1.198      hence "sup a (-a) + a = a" by (simp)
   1.199 -    hence "sup (a+a) 0 = a" by (simp add: add_sup_distrib_right) 
   1.200 +    hence "sup (a+a) 0 = a" by (simp add: add_sup_distrib_right)
   1.201      hence "sup (a+a) 0 <= a" by (simp)
   1.202      hence "0 <= a" by (blast intro: order_trans inf_sup_ord)
   1.203    }
   1.204 @@ -192,16 +183,22 @@
   1.205  qed
   1.206  
   1.207  lemma inf_0_imp_0: "inf a (-a) = 0 \<Longrightarrow> a = 0"
   1.208 -apply (simp add: inf_eq_neg_sup)
   1.209 -apply (simp add: sup_commute)
   1.210 -apply (erule sup_0_imp_0)
   1.211 -done
   1.212 +  apply (simp add: inf_eq_neg_sup)
   1.213 +  apply (simp add: sup_commute)
   1.214 +  apply (erule sup_0_imp_0)
   1.215 +  done
   1.216  
   1.217  lemma inf_0_eq_0 [simp, no_atp]: "inf a (- a) = 0 \<longleftrightarrow> a = 0"
   1.218 -by (rule, erule inf_0_imp_0) simp
   1.219 +  apply rule
   1.220 +  apply (erule inf_0_imp_0)
   1.221 +  apply simp
   1.222 +  done
   1.223  
   1.224  lemma sup_0_eq_0 [simp, no_atp]: "sup a (- a) = 0 \<longleftrightarrow> a = 0"
   1.225 -by (rule, erule sup_0_imp_0) simp
   1.226 +  apply rule
   1.227 +  apply (erule sup_0_imp_0)
   1.228 +  apply simp
   1.229 +  done
   1.230  
   1.231  lemma zero_le_double_add_iff_zero_le_single_add [simp]:
   1.232    "0 \<le> a + a \<longleftrightarrow> 0 \<le> a"
   1.233 @@ -218,39 +215,48 @@
   1.234    show "0 <= a + a" by (simp add: add_mono[OF a a, simplified])
   1.235  qed
   1.236  
   1.237 -lemma double_zero [simp]:
   1.238 -  "a + a = 0 \<longleftrightarrow> a = 0"
   1.239 +lemma double_zero [simp]: "a + a = 0 \<longleftrightarrow> a = 0"
   1.240  proof
   1.241    assume assm: "a + a = 0"
   1.242    then have "a + a + - a = - a" by simp
   1.243    then have "a + (a + - a) = - a" by (simp only: add_assoc)
   1.244    then have a: "- a = a" by simp
   1.245 -  show "a = 0" apply (rule antisym)
   1.246 -  apply (unfold neg_le_iff_le [symmetric, of a])
   1.247 -  unfolding a apply simp
   1.248 -  unfolding zero_le_double_add_iff_zero_le_single_add [symmetric, of a]
   1.249 -  unfolding assm unfolding le_less apply simp_all done
   1.250 +  show "a = 0"
   1.251 +    apply (rule antisym)
   1.252 +    apply (unfold neg_le_iff_le [symmetric, of a])
   1.253 +    unfolding a
   1.254 +    apply simp
   1.255 +    unfolding zero_le_double_add_iff_zero_le_single_add [symmetric, of a]
   1.256 +    unfolding assm
   1.257 +    unfolding le_less
   1.258 +    apply simp_all
   1.259 +    done
   1.260  next
   1.261 -  assume "a = 0" then show "a + a = 0" by simp
   1.262 +  assume "a = 0"
   1.263 +  then show "a + a = 0" by simp
   1.264  qed
   1.265  
   1.266 -lemma zero_less_double_add_iff_zero_less_single_add [simp]:
   1.267 -  "0 < a + a \<longleftrightarrow> 0 < a"
   1.268 +lemma zero_less_double_add_iff_zero_less_single_add [simp]: "0 < a + a \<longleftrightarrow> 0 < a"
   1.269  proof (cases "a = 0")
   1.270 -  case True then show ?thesis by auto
   1.271 +  case True
   1.272 +  then show ?thesis by auto
   1.273  next
   1.274 -  case False then show ?thesis (*FIXME tune proof*)
   1.275 -  unfolding less_le apply simp apply rule
   1.276 -  apply clarify
   1.277 -  apply rule
   1.278 -  apply assumption
   1.279 -  apply (rule notI)
   1.280 -  unfolding double_zero [symmetric, of a] apply simp
   1.281 -  done
   1.282 +  case False
   1.283 +  then show ?thesis
   1.284 +    unfolding less_le
   1.285 +    apply simp
   1.286 +    apply rule
   1.287 +    apply clarify
   1.288 +    apply rule
   1.289 +    apply assumption
   1.290 +    apply (rule notI)
   1.291 +    unfolding double_zero [symmetric, of a]
   1.292 +    apply simp
   1.293 +    done
   1.294  qed
   1.295  
   1.296  lemma double_add_le_zero_iff_single_add_le_zero [simp]:
   1.297 -  "a + a \<le> 0 \<longleftrightarrow> a \<le> 0" 
   1.298 +  "a + a \<le> 0 \<longleftrightarrow> a \<le> 0"
   1.299  proof -
   1.300    have "a + a \<le> 0 \<longleftrightarrow> 0 \<le> - (a + a)" by (subst le_minus_iff, simp)
   1.301    moreover have "\<dots> \<longleftrightarrow> a \<le> 0" by simp
   1.302 @@ -270,7 +276,7 @@
   1.303  lemma le_minus_self_iff: "a \<le> - a \<longleftrightarrow> a \<le> 0"
   1.304  proof -
   1.305    from add_le_cancel_left [of "uminus a" "plus a a" zero]
   1.306 -  have "(a <= -a) = (a+a <= 0)" 
   1.307 +  have "(a <= -a) = (a+a <= 0)"
   1.308      by (simp add: add_assoc[symmetric])
   1.309    thus ?thesis by simp
   1.310  qed
   1.311 @@ -278,28 +284,28 @@
   1.312  lemma minus_le_self_iff: "- a \<le> a \<longleftrightarrow> 0 \<le> a"
   1.313  proof -
   1.314    from add_le_cancel_left [of "uminus a" zero "plus a a"]
   1.315 -  have "(-a <= a) = (0 <= a+a)" 
   1.316 +  have "(-a <= a) = (0 <= a+a)"
   1.317      by (simp add: add_assoc[symmetric])
   1.318    thus ?thesis by simp
   1.319  qed
   1.320  
   1.321  lemma zero_le_iff_zero_nprt: "0 \<le> a \<longleftrightarrow> nprt a = 0"
   1.322 -unfolding le_iff_inf by (simp add: nprt_def inf_commute)
   1.323 +  unfolding le_iff_inf by (simp add: nprt_def inf_commute)
   1.324  
   1.325  lemma le_zero_iff_zero_pprt: "a \<le> 0 \<longleftrightarrow> pprt a = 0"
   1.326 -unfolding le_iff_sup by (simp add: pprt_def sup_commute)
   1.327 +  unfolding le_iff_sup by (simp add: pprt_def sup_commute)
   1.328  
   1.329  lemma le_zero_iff_pprt_id: "0 \<le> a \<longleftrightarrow> pprt a = a"
   1.330 -unfolding le_iff_sup by (simp add: pprt_def sup_commute)
   1.331 +  unfolding le_iff_sup by (simp add: pprt_def sup_commute)
   1.332  
   1.333  lemma zero_le_iff_nprt_id: "a \<le> 0 \<longleftrightarrow> nprt a = a"
   1.334 -unfolding le_iff_inf by (simp add: nprt_def inf_commute)
   1.335 +  unfolding le_iff_inf by (simp add: nprt_def inf_commute)
   1.336  
   1.337  lemma pprt_mono [simp, no_atp]: "a \<le> b \<Longrightarrow> pprt a \<le> pprt b"
   1.338 -unfolding le_iff_sup by (simp add: pprt_def sup_aci sup_assoc [symmetric, of a])
   1.339 +  unfolding le_iff_sup by (simp add: pprt_def sup_aci sup_assoc [symmetric, of a])
   1.340  
   1.341  lemma nprt_mono [simp, no_atp]: "a \<le> b \<Longrightarrow> nprt a \<le> nprt b"
   1.342 -unfolding le_iff_inf by (simp add: nprt_def inf_aci inf_assoc [symmetric, of a])
   1.343 +  unfolding le_iff_inf by (simp add: nprt_def inf_aci inf_assoc [symmetric, of a])
   1.344  
   1.345  end
   1.346  
   1.347 @@ -320,8 +326,7 @@
   1.348    then have "0 \<le> sup a (- a)" unfolding abs_lattice .
   1.349    then have "sup (sup a (- a)) 0 = sup a (- a)" by (rule sup_absorb1)
   1.350    then show ?thesis
   1.351 -    by (simp add: add_sup_inf_distribs sup_aci
   1.352 -      pprt_def nprt_def diff_minus abs_lattice)
   1.353 +    by (simp add: add_sup_inf_distribs sup_aci pprt_def nprt_def diff_minus abs_lattice)
   1.354  qed
   1.355  
   1.356  subclass ordered_ab_group_add_abs
   1.357 @@ -329,8 +334,10 @@
   1.358    have abs_ge_zero [simp]: "\<And>a. 0 \<le> \<bar>a\<bar>"
   1.359    proof -
   1.360      fix a b
   1.361 -    have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>" by (auto simp add: abs_lattice)
   1.362 -    show "0 \<le> \<bar>a\<bar>" by (rule add_mono [OF a b, simplified])
   1.363 +    have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>"
   1.364 +      by (auto simp add: abs_lattice)
   1.365 +    show "0 \<le> \<bar>a\<bar>"
   1.366 +      by (rule add_mono [OF a b, simplified])
   1.367    qed
   1.368    have abs_leI: "\<And>a b. a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b"
   1.369      by (simp add: abs_lattice le_supI)
   1.370 @@ -340,18 +347,25 @@
   1.371      by (auto simp add: abs_lattice)
   1.372    show "\<bar>-a\<bar> = \<bar>a\<bar>"
   1.373      by (simp add: abs_lattice sup_commute)
   1.374 -  show "a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" by (fact abs_leI)
   1.375 +  {
   1.376 +    assume "a \<le> b"
   1.377 +    then show "- a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b"
   1.378 +      by (rule abs_leI)
   1.379 +  }
   1.380    show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>"
   1.381    proof -
   1.382      have g:"abs a + abs b = sup (a+b) (sup (-a-b) (sup (-a+b) (a + (-b))))" (is "_=sup ?m ?n")
   1.383        by (simp add: abs_lattice add_sup_inf_distribs sup_aci diff_minus)
   1.384 -    have a:"a+b <= sup ?m ?n" by (simp)
   1.385 -    have b:"-a-b <= ?n" by (simp) 
   1.386 -    have c:"?n <= sup ?m ?n" by (simp)
   1.387 -    from b c have d: "-a-b <= sup ?m ?n" by(rule order_trans)
   1.388 +    have a: "a + b <= sup ?m ?n" by simp
   1.389 +    have b: "- a - b <= ?n" by simp
   1.390 +    have c: "?n <= sup ?m ?n" by simp
   1.391 +    from b c have d: "-a-b <= sup ?m ?n" by (rule order_trans)
   1.392      have e:"-a-b = -(a+b)" by (simp add: diff_minus)
   1.393 -    from a d e have "abs(a+b) <= sup ?m ?n" 
   1.394 -      by (drule_tac abs_leI, auto)
   1.395 +    from a d e have "abs(a+b) <= sup ?m ?n"
   1.396 +      apply -
   1.397 +      apply (drule abs_leI)
   1.398 +      apply auto
   1.399 +      done
   1.400      with g[symmetric] show ?thesis by simp
   1.401    qed
   1.402  qed
   1.403 @@ -370,10 +384,10 @@
   1.404  lemma abs_if_lattice:
   1.405    fixes a :: "'a\<Colon>{lattice_ab_group_add_abs, linorder}"
   1.406    shows "\<bar>a\<bar> = (if a < 0 then - a else a)"
   1.407 -by auto
   1.408 +  by auto
   1.409  
   1.410  lemma estimate_by_abs:
   1.411 -  "a + b <= (c::'a::lattice_ab_group_add_abs) \<Longrightarrow> a <= c + abs b" 
   1.412 +  "a + b <= (c::'a::lattice_ab_group_add_abs) \<Longrightarrow> a <= c + abs b"
   1.413  proof -
   1.414    assume "a+b <= c"
   1.415    then have "a <= c+(-b)" by (simp add: algebra_simps)
   1.416 @@ -390,7 +404,7 @@
   1.417  
   1.418  end
   1.419  
   1.420 -lemma abs_le_mult: "abs (a * b) \<le> (abs a) * (abs (b::'a::lattice_ring))" 
   1.421 +lemma abs_le_mult: "abs (a * b) \<le> (abs a) * (abs (b::'a::lattice_ring))"
   1.422  proof -
   1.423    let ?x = "pprt a * pprt b - pprt a * nprt b - nprt a * pprt b + nprt a * nprt b"
   1.424    let ?y = "pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
   1.425 @@ -398,11 +412,11 @@
   1.426      by (simp only: abs_prts[of a] abs_prts[of b] algebra_simps)
   1.427    {
   1.428      fix u v :: 'a
   1.429 -    have bh: "\<lbrakk>u = a; v = b\<rbrakk> \<Longrightarrow> 
   1.430 -              u * v = pprt a * pprt b + pprt a * nprt b + 
   1.431 +    have bh: "\<lbrakk>u = a; v = b\<rbrakk> \<Longrightarrow>
   1.432 +              u * v = pprt a * pprt b + pprt a * nprt b +
   1.433                        nprt a * pprt b + nprt a * nprt b"
   1.434        apply (subst prts[of u], subst prts[of v])
   1.435 -      apply (simp add: algebra_simps) 
   1.436 +      apply (simp add: algebra_simps)
   1.437        done
   1.438    }
   1.439    note b = this[OF refl[of a] refl[of b]]
   1.440 @@ -432,7 +446,7 @@
   1.441    show "abs (a*b) = abs a * abs b"
   1.442    proof -
   1.443      have s: "(0 <= a*b) | (a*b <= 0)"
   1.444 -      apply (auto)    
   1.445 +      apply (auto)
   1.446        apply (rule_tac split_mult_pos_le)
   1.447        apply (rule_tac contrapos_np[of "a*b <= 0"])
   1.448        apply (simp)
   1.449 @@ -448,8 +462,8 @@
   1.450        then show ?thesis
   1.451          apply (simp_all add: mulprts abs_prts)
   1.452          apply (insert a)
   1.453 -        apply (auto simp add: 
   1.454 -          algebra_simps 
   1.455 +        apply (auto simp add:
   1.456 +          algebra_simps
   1.457            iffD1[OF zero_le_iff_zero_nprt] iffD1[OF le_zero_iff_zero_pprt]
   1.458            iffD1[OF le_zero_iff_pprt_id] iffD1[OF zero_le_iff_nprt_id])
   1.459            apply(drule (1) mult_nonneg_nonpos[of a b], simp)
   1.460 @@ -470,15 +484,14 @@
   1.461  qed
   1.462  
   1.463  lemma mult_le_prts:
   1.464 -  assumes
   1.465 -  "a1 <= (a::'a::lattice_ring)"
   1.466 -  "a <= a2"
   1.467 -  "b1 <= b"
   1.468 -  "b <= b2"
   1.469 -  shows
   1.470 -  "a * b <= pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1"
   1.471 -proof - 
   1.472 -  have "a * b = (pprt a + nprt a) * (pprt b + nprt b)" 
   1.473 +  assumes "a1 <= (a::'a::lattice_ring)"
   1.474 +    and "a <= a2"
   1.475 +    and "b1 <= b"
   1.476 +    and "b <= b2"
   1.477 +  shows "a * b <=
   1.478 +    pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1"
   1.479 +proof -
   1.480 +  have "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
   1.481      apply (subst prts[symmetric])+
   1.482      apply simp
   1.483      done
   1.484 @@ -496,7 +509,7 @@
   1.485        by simp
   1.486    qed
   1.487    moreover have "nprt a * pprt b <= nprt a2 * pprt b1"
   1.488 -  proof - 
   1.489 +  proof -
   1.490      have "nprt a * pprt b <= nprt a2 * pprt b"
   1.491        by (simp add: mult_right_mono assms)
   1.492      moreover have "nprt a2 * pprt b <= nprt a2 * pprt b1"
   1.493 @@ -514,29 +527,33 @@
   1.494        by simp
   1.495    qed
   1.496    ultimately show ?thesis
   1.497 -    by - (rule add_mono | simp)+
   1.498 +    apply -
   1.499 +    apply (rule add_mono | simp)+
   1.500 +    done
   1.501  qed
   1.502  
   1.503  lemma mult_ge_prts:
   1.504 -  assumes
   1.505 -  "a1 <= (a::'a::lattice_ring)"
   1.506 -  "a <= a2"
   1.507 -  "b1 <= b"
   1.508 -  "b <= b2"
   1.509 -  shows
   1.510 -  "a * b >= nprt a1 * pprt b2 + nprt a2 * nprt b2 + pprt a1 * pprt b1 + pprt a2 * nprt b1"
   1.511 -proof - 
   1.512 -  from assms have a1:"- a2 <= -a" by auto
   1.513 -  from assms have a2: "-a <= -a1" by auto
   1.514 -  from mult_le_prts[of "-a2" "-a" "-a1" "b1" b "b2", OF a1 a2 assms(3) assms(4), simplified nprt_neg pprt_neg] 
   1.515 -  have le: "- (a * b) <= - nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1" by simp  
   1.516 +  assumes "a1 <= (a::'a::lattice_ring)"
   1.517 +    and "a <= a2"
   1.518 +    and "b1 <= b"
   1.519 +    and "b <= b2"
   1.520 +  shows "a * b >=
   1.521 +    nprt a1 * pprt b2 + nprt a2 * nprt b2 + pprt a1 * pprt b1 + pprt a2 * nprt b1"
   1.522 +proof -
   1.523 +  from assms have a1:"- a2 <= -a"
   1.524 +    by auto
   1.525 +  from assms have a2: "-a <= -a1"
   1.526 +    by auto
   1.527 +  from mult_le_prts[of "-a2" "-a" "-a1" "b1" b "b2", OF a1 a2 assms(3) assms(4), simplified nprt_neg pprt_neg]
   1.528 +  have le: "- (a * b) <= - nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1"
   1.529 +    by simp
   1.530    then have "-(- nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1) <= a * b"
   1.531      by (simp only: minus_le_iff)
   1.532    then show ?thesis by simp
   1.533  qed
   1.534  
   1.535  instance int :: lattice_ring
   1.536 -proof  
   1.537 +proof
   1.538    fix k :: int
   1.539    show "abs k = sup k (- k)"
   1.540      by (auto simp add: sup_int_def)