src/HOL/Library/Lattice_Algebras.thy
author haftmann
Wed Jul 18 20:51:21 2018 +0200 (11 months ago)
changeset 68658 16cc1161ad7f
parent 68406 6beb45f6cf67
permissions -rw-r--r--
tuned equation
     1 (*  Author:     Steven Obua, TU Muenchen *)
     2 
     3 section \<open>Various algebraic structures combined with a lattice\<close>
     4 
     5 theory Lattice_Algebras
     6   imports Complex_Main
     7 begin
     8 
     9 class semilattice_inf_ab_group_add = ordered_ab_group_add + semilattice_inf
    10 begin
    11 
    12 lemma add_inf_distrib_left: "a + inf b c = inf (a + b) (a + c)"
    13   apply (rule antisym)
    14    apply (simp_all add: le_infI)
    15   apply (rule add_le_imp_le_left [of "uminus a"])
    16   apply (simp only: add.assoc [symmetric], simp add: diff_le_eq add.commute)
    17   done
    18 
    19 lemma add_inf_distrib_right: "inf a b + c = inf (a + c) (b + c)"
    20 proof -
    21   have "c + inf a b = inf (c + a) (c + b)"
    22     by (simp add: add_inf_distrib_left)
    23   then show ?thesis
    24     by (simp add: add.commute)
    25 qed
    26 
    27 end
    28 
    29 class semilattice_sup_ab_group_add = ordered_ab_group_add + semilattice_sup
    30 begin
    31 
    32 lemma add_sup_distrib_left: "a + sup b c = sup (a + b) (a + c)"
    33   apply (rule antisym)
    34    apply (rule add_le_imp_le_left [of "uminus a"])
    35    apply (simp only: add.assoc [symmetric], simp)
    36    apply (simp add: le_diff_eq add.commute)
    37   apply (rule le_supI)
    38    apply (rule add_le_imp_le_left [of "a"], simp only: add.assoc[symmetric], simp)+
    39   done
    40 
    41 lemma add_sup_distrib_right: "sup a b + c = sup (a + c) (b + c)"
    42 proof -
    43   have "c + sup a b = sup (c+a) (c+b)"
    44     by (simp add: add_sup_distrib_left)
    45   then show ?thesis
    46     by (simp add: add.commute)
    47 qed
    48 
    49 end
    50 
    51 class lattice_ab_group_add = ordered_ab_group_add + lattice
    52 begin
    53 
    54 subclass semilattice_inf_ab_group_add ..
    55 subclass semilattice_sup_ab_group_add ..
    56 
    57 lemmas add_sup_inf_distribs =
    58   add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left
    59 
    60 lemma inf_eq_neg_sup: "inf a b = - sup (- a) (- b)"
    61 proof (rule inf_unique)
    62   fix a b c :: 'a
    63   show "- sup (- a) (- b) \<le> a"
    64     by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"])
    65       (simp, simp add: add_sup_distrib_left)
    66   show "- sup (-a) (-b) \<le> b"
    67     by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"])
    68       (simp, simp add: add_sup_distrib_left)
    69   assume "a \<le> b" "a \<le> c"
    70   then show "a \<le> - sup (-b) (-c)"
    71     by (subst neg_le_iff_le [symmetric]) (simp add: le_supI)
    72 qed
    73 
    74 lemma sup_eq_neg_inf: "sup a b = - inf (- a) (- b)"
    75 proof (rule sup_unique)
    76   fix a b c :: 'a
    77   show "a \<le> - inf (- a) (- b)"
    78     by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"])
    79       (simp, simp add: add_inf_distrib_left)
    80   show "b \<le> - inf (- a) (- b)"
    81     by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"])
    82       (simp, simp add: add_inf_distrib_left)
    83   show "- inf (- a) (- b) \<le> c" if "a \<le> c" "b \<le> c"
    84     using that by (subst neg_le_iff_le [symmetric]) (simp add: le_infI)
    85 qed
    86 
    87 lemma neg_inf_eq_sup: "- inf a b = sup (- a) (- b)"
    88   by (simp add: inf_eq_neg_sup)
    89 
    90 lemma diff_inf_eq_sup: "a - inf b c = a + sup (- b) (- c)"
    91   using neg_inf_eq_sup [of b c, symmetric] by simp
    92 
    93 lemma neg_sup_eq_inf: "- sup a b = inf (- a) (- b)"
    94   by (simp add: sup_eq_neg_inf)
    95 
    96 lemma diff_sup_eq_inf: "a - sup b c = a + inf (- b) (- c)"
    97   using neg_sup_eq_inf [of b c, symmetric] by simp
    98 
    99 lemma add_eq_inf_sup: "a + b = sup a b + inf a b"
   100 proof -
   101   have "0 = - inf 0 (a - b) + inf (a - b) 0"
   102     by (simp add: inf_commute)
   103   then have "0 = sup 0 (b - a) + inf (a - b) 0"
   104     by (simp add: inf_eq_neg_sup)
   105   then have "0 = (- a + sup a b) + (inf a b + (- b))"
   106     by (simp only: add_sup_distrib_left add_inf_distrib_right) simp
   107   then show ?thesis
   108     by (simp add: algebra_simps)
   109 qed
   110 
   111 
   112 subsection \<open>Positive Part, Negative Part, Absolute Value\<close>
   113 
   114 definition nprt :: "'a \<Rightarrow> 'a"
   115   where "nprt x = inf x 0"
   116 
   117 definition pprt :: "'a \<Rightarrow> 'a"
   118   where "pprt x = sup x 0"
   119 
   120 lemma pprt_neg: "pprt (- x) = - nprt x"
   121 proof -
   122   have "sup (- x) 0 = sup (- x) (- 0)"
   123     by (simp only: minus_zero)
   124   also have "\<dots> = - inf x 0"
   125     by (simp only: neg_inf_eq_sup)
   126   finally have "sup (- x) 0 = - inf x 0" .
   127   then show ?thesis
   128     by (simp only: pprt_def nprt_def)
   129 qed
   130 
   131 lemma nprt_neg: "nprt (- x) = - pprt x"
   132 proof -
   133   from pprt_neg have "pprt (- (- x)) = - nprt (- x)" .
   134   then have "pprt x = - nprt (- x)" by simp
   135   then show ?thesis by simp
   136 qed
   137 
   138 lemma prts: "a = pprt a + nprt a"
   139   by (simp add: pprt_def nprt_def flip: add_eq_inf_sup)
   140 
   141 lemma zero_le_pprt[simp]: "0 \<le> pprt a"
   142   by (simp add: pprt_def)
   143 
   144 lemma nprt_le_zero[simp]: "nprt a \<le> 0"
   145   by (simp add: nprt_def)
   146 
   147 lemma le_eq_neg: "a \<le> - b \<longleftrightarrow> a + b \<le> 0"
   148   (is "?lhs = ?rhs")
   149 proof
   150   assume ?lhs
   151   show ?rhs
   152     by (rule add_le_imp_le_right[of _ "uminus b" _]) (simp add: add.assoc \<open>?lhs\<close>)
   153 next
   154   assume ?rhs
   155   show ?lhs
   156     by (rule add_le_imp_le_right[of _ "b" _]) (simp add: \<open>?rhs\<close>)
   157 qed
   158 
   159 lemma pprt_0[simp]: "pprt 0 = 0" by (simp add: pprt_def)
   160 lemma nprt_0[simp]: "nprt 0 = 0" by (simp add: nprt_def)
   161 
   162 lemma pprt_eq_id [simp, no_atp]: "0 \<le> x \<Longrightarrow> pprt x = x"
   163   by (simp add: pprt_def sup_absorb1)
   164 
   165 lemma nprt_eq_id [simp, no_atp]: "x \<le> 0 \<Longrightarrow> nprt x = x"
   166   by (simp add: nprt_def inf_absorb1)
   167 
   168 lemma pprt_eq_0 [simp, no_atp]: "x \<le> 0 \<Longrightarrow> pprt x = 0"
   169   by (simp add: pprt_def sup_absorb2)
   170 
   171 lemma nprt_eq_0 [simp, no_atp]: "0 \<le> x \<Longrightarrow> nprt x = 0"
   172   by (simp add: nprt_def inf_absorb2)
   173 
   174 lemma sup_0_imp_0:
   175   assumes "sup a (- a) = 0"
   176   shows "a = 0"
   177 proof -
   178   have pos: "0 \<le> a" if "sup a (- a) = 0" for a :: 'a
   179   proof -
   180     from that have "sup a (- a) + a = a"
   181       by simp
   182     then have "sup (a + a) 0 = a"
   183       by (simp add: add_sup_distrib_right)
   184     then have "sup (a + a) 0 \<le> a"
   185       by simp
   186     then show ?thesis
   187       by (blast intro: order_trans inf_sup_ord)
   188   qed
   189   from assms have **: "sup (-a) (-(-a)) = 0"
   190     by (simp add: sup_commute)
   191   from pos[OF assms] pos[OF **] show "a = 0"
   192     by simp
   193 qed
   194 
   195 lemma inf_0_imp_0: "inf a (- a) = 0 \<Longrightarrow> a = 0"
   196   apply (simp add: inf_eq_neg_sup)
   197   apply (simp add: sup_commute)
   198   apply (erule sup_0_imp_0)
   199   done
   200 
   201 lemma inf_0_eq_0 [simp, no_atp]: "inf a (- a) = 0 \<longleftrightarrow> a = 0"
   202   apply (rule iffI)
   203    apply (erule inf_0_imp_0)
   204   apply simp
   205   done
   206 
   207 lemma sup_0_eq_0 [simp, no_atp]: "sup a (- a) = 0 \<longleftrightarrow> a = 0"
   208   apply (rule iffI)
   209    apply (erule sup_0_imp_0)
   210   apply simp
   211   done
   212 
   213 lemma zero_le_double_add_iff_zero_le_single_add [simp]: "0 \<le> a + a \<longleftrightarrow> 0 \<le> a"
   214   (is "?lhs \<longleftrightarrow> ?rhs")
   215 proof
   216   show ?rhs if ?lhs
   217   proof -
   218     from that have a: "inf (a + a) 0 = 0"
   219       by (simp add: inf_commute inf_absorb1)
   220     have "inf a 0 + inf a 0 = inf (inf (a + a) 0) a"  (is "?l = _")
   221       by (simp add: add_sup_inf_distribs inf_aci)
   222     then have "?l = 0 + inf a 0"
   223       by (simp add: a, simp add: inf_commute)
   224     then have "inf a 0 = 0"
   225       by (simp only: add_right_cancel)
   226     then show ?thesis
   227       unfolding le_iff_inf by (simp add: inf_commute)
   228   qed
   229   show ?lhs if ?rhs
   230     by (simp add: add_mono[OF that that, simplified])
   231 qed
   232 
   233 lemma double_zero [simp]: "a + a = 0 \<longleftrightarrow> a = 0"
   234   using add_nonneg_eq_0_iff eq_iff by auto
   235 
   236 lemma zero_less_double_add_iff_zero_less_single_add [simp]: "0 < a + a \<longleftrightarrow> 0 < a"
   237   by (meson le_less_trans less_add_same_cancel2 less_le_not_le
   238       zero_le_double_add_iff_zero_le_single_add)
   239 
   240 lemma double_add_le_zero_iff_single_add_le_zero [simp]: "a + a \<le> 0 \<longleftrightarrow> a \<le> 0"
   241 proof -
   242   have "a + a \<le> 0 \<longleftrightarrow> 0 \<le> - (a + a)"
   243     by (subst le_minus_iff) simp
   244   moreover have "\<dots> \<longleftrightarrow> a \<le> 0"
   245     by (simp only: minus_add_distrib zero_le_double_add_iff_zero_le_single_add) simp
   246   ultimately show ?thesis
   247     by blast
   248 qed
   249 
   250 lemma double_add_less_zero_iff_single_less_zero [simp]: "a + a < 0 \<longleftrightarrow> a < 0"
   251 proof -
   252   have "a + a < 0 \<longleftrightarrow> 0 < - (a + a)"
   253     by (subst less_minus_iff) simp
   254   moreover have "\<dots> \<longleftrightarrow> a < 0"
   255     by (simp only: minus_add_distrib zero_less_double_add_iff_zero_less_single_add) simp
   256   ultimately show ?thesis
   257     by blast
   258 qed
   259 
   260 declare neg_inf_eq_sup [simp]
   261   and neg_sup_eq_inf [simp]
   262   and diff_inf_eq_sup [simp]
   263   and diff_sup_eq_inf [simp]
   264 
   265 lemma le_minus_self_iff: "a \<le> - a \<longleftrightarrow> a \<le> 0"
   266 proof -
   267   from add_le_cancel_left [of "uminus a" "plus a a" zero]
   268   have "a \<le> - a \<longleftrightarrow> a + a \<le> 0"
   269     by (simp flip: add.assoc)
   270   then show ?thesis
   271     by simp
   272 qed
   273 
   274 lemma minus_le_self_iff: "- a \<le> a \<longleftrightarrow> 0 \<le> a"
   275 proof -
   276   have "- a \<le> a \<longleftrightarrow> 0 \<le> a + a"
   277     using add_le_cancel_left [of "uminus a" zero "plus a a"]
   278     by (simp flip: add.assoc)
   279   then show ?thesis
   280     by simp
   281 qed
   282 
   283 lemma zero_le_iff_zero_nprt: "0 \<le> a \<longleftrightarrow> nprt a = 0"
   284   unfolding le_iff_inf by (simp add: nprt_def inf_commute)
   285 
   286 lemma le_zero_iff_zero_pprt: "a \<le> 0 \<longleftrightarrow> pprt a = 0"
   287   unfolding le_iff_sup by (simp add: pprt_def sup_commute)
   288 
   289 lemma le_zero_iff_pprt_id: "0 \<le> a \<longleftrightarrow> pprt a = a"
   290   unfolding le_iff_sup by (simp add: pprt_def sup_commute)
   291 
   292 lemma zero_le_iff_nprt_id: "a \<le> 0 \<longleftrightarrow> nprt a = a"
   293   unfolding le_iff_inf by (simp add: nprt_def inf_commute)
   294 
   295 lemma pprt_mono [simp, no_atp]: "a \<le> b \<Longrightarrow> pprt a \<le> pprt b"
   296   unfolding le_iff_sup by (simp add: pprt_def sup_aci sup_assoc [symmetric, of a])
   297 
   298 lemma nprt_mono [simp, no_atp]: "a \<le> b \<Longrightarrow> nprt a \<le> nprt b"
   299   unfolding le_iff_inf by (simp add: nprt_def inf_aci inf_assoc [symmetric, of a])
   300 
   301 end
   302 
   303 lemmas add_sup_inf_distribs =
   304   add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left
   305 
   306 
   307 class lattice_ab_group_add_abs = lattice_ab_group_add + abs +
   308   assumes abs_lattice: "\<bar>a\<bar> = sup a (- a)"
   309 begin
   310 
   311 lemma abs_prts: "\<bar>a\<bar> = pprt a - nprt a"
   312 proof -
   313   have "0 \<le> \<bar>a\<bar>"
   314   proof -
   315     have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>"
   316       by (auto simp add: abs_lattice)
   317     show ?thesis
   318       by (rule add_mono [OF a b, simplified])
   319   qed
   320   then have "0 \<le> sup a (- a)"
   321     unfolding abs_lattice .
   322   then have "sup (sup a (- a)) 0 = sup a (- a)"
   323     by (rule sup_absorb1)
   324   then show ?thesis
   325     by (simp add: add_sup_inf_distribs ac_simps pprt_def nprt_def abs_lattice)
   326 qed
   327 
   328 subclass ordered_ab_group_add_abs
   329 proof
   330   have abs_ge_zero [simp]: "0 \<le> \<bar>a\<bar>" for a
   331   proof -
   332     have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>"
   333       by (auto simp add: abs_lattice)
   334     show "0 \<le> \<bar>a\<bar>"
   335       by (rule add_mono [OF a b, simplified])
   336   qed
   337   have abs_leI: "a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" for a b
   338     by (simp add: abs_lattice le_supI)
   339   fix a b
   340   show "0 \<le> \<bar>a\<bar>"
   341     by simp
   342   show "a \<le> \<bar>a\<bar>"
   343     by (auto simp add: abs_lattice)
   344   show "\<bar>-a\<bar> = \<bar>a\<bar>"
   345     by (simp add: abs_lattice sup_commute)
   346   show "- a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" if "a \<le> b"
   347     using that by (rule abs_leI)
   348   show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>"
   349   proof -
   350     have g: "\<bar>a\<bar> + \<bar>b\<bar> = sup (a + b) (sup (- a - b) (sup (- a + b) (a + (- b))))"
   351       (is "_ = sup ?m ?n")
   352       by (simp add: abs_lattice add_sup_inf_distribs ac_simps)
   353     have a: "a + b \<le> sup ?m ?n"
   354       by simp
   355     have b: "- a - b \<le> ?n"
   356       by simp
   357     have c: "?n \<le> sup ?m ?n"
   358       by simp
   359     from b c have d: "- a - b \<le> sup ?m ?n"
   360       by (rule order_trans)
   361     have e: "- a - b = - (a + b)"
   362       by simp
   363     from a d e have "\<bar>a + b\<bar> \<le> sup ?m ?n"
   364       apply -
   365       apply (drule abs_leI)
   366        apply (simp_all only: algebra_simps minus_add)
   367       apply (metis add_uminus_conv_diff d sup_commute uminus_add_conv_diff)
   368       done
   369     with g[symmetric] show ?thesis by simp
   370   qed
   371 qed
   372 
   373 end
   374 
   375 lemma sup_eq_if:
   376   fixes a :: "'a::{lattice_ab_group_add,linorder}"
   377   shows "sup a (- a) = (if a < 0 then - a else a)"
   378   using add_le_cancel_right [of a a "- a", symmetric, simplified]
   379     and add_le_cancel_right [of "-a" a a, symmetric, simplified]
   380   by (auto simp: sup_max max.absorb1 max.absorb2)
   381 
   382 lemma abs_if_lattice:
   383   fixes a :: "'a::{lattice_ab_group_add_abs,linorder}"
   384   shows "\<bar>a\<bar> = (if a < 0 then - a else a)"
   385   by auto
   386 
   387 lemma estimate_by_abs:
   388   fixes a b c :: "'a::lattice_ab_group_add_abs"
   389   assumes "a + b \<le> c"
   390   shows "a \<le> c + \<bar>b\<bar>"
   391 proof -
   392   from assms have "a \<le> c + (- b)"
   393     by (simp add: algebra_simps)
   394   have "- b \<le> \<bar>b\<bar>"
   395     by (rule abs_ge_minus_self)
   396   then have "c + (- b) \<le> c + \<bar>b\<bar>"
   397     by (rule add_left_mono)
   398   with \<open>a \<le> c + (- b)\<close> show ?thesis
   399     by (rule order_trans)
   400 qed
   401 
   402 class lattice_ring = ordered_ring + lattice_ab_group_add_abs
   403 begin
   404 
   405 subclass semilattice_inf_ab_group_add ..
   406 subclass semilattice_sup_ab_group_add ..
   407 
   408 end
   409 
   410 lemma abs_le_mult:
   411   fixes a b :: "'a::lattice_ring"
   412   shows "\<bar>a * b\<bar> \<le> \<bar>a\<bar> * \<bar>b\<bar>"
   413 proof -
   414   let ?x = "pprt a * pprt b - pprt a * nprt b - nprt a * pprt b + nprt a * nprt b"
   415   let ?y = "pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
   416   have a: "\<bar>a\<bar> * \<bar>b\<bar> = ?x"
   417     by (simp only: abs_prts[of a] abs_prts[of b] algebra_simps)
   418   have bh: "u = a \<Longrightarrow> v = b \<Longrightarrow>
   419             u * v = pprt a * pprt b + pprt a * nprt b +
   420                     nprt a * pprt b + nprt a * nprt b" for u v :: 'a
   421     apply (subst prts[of u], subst prts[of v])
   422     apply (simp add: algebra_simps)
   423     done
   424   note b = this[OF refl[of a] refl[of b]]
   425   have xy: "- ?x \<le> ?y"
   426     apply simp
   427     apply (metis (full_types) add_increasing add_uminus_conv_diff
   428       lattice_ab_group_add_class.minus_le_self_iff minus_add_distrib mult_nonneg_nonneg
   429       mult_nonpos_nonpos nprt_le_zero zero_le_pprt)
   430     done
   431   have yx: "?y \<le> ?x"
   432     apply simp
   433     apply (metis (full_types) add_nonpos_nonpos add_uminus_conv_diff
   434       lattice_ab_group_add_class.le_minus_self_iff minus_add_distrib mult_nonneg_nonpos
   435       mult_nonpos_nonneg nprt_le_zero zero_le_pprt)
   436     done
   437   have i1: "a * b \<le> \<bar>a\<bar> * \<bar>b\<bar>"
   438     by (simp only: a b yx)
   439   have i2: "- (\<bar>a\<bar> * \<bar>b\<bar>) \<le> a * b"
   440     by (simp only: a b xy)
   441   show ?thesis
   442     apply (rule abs_leI)
   443     apply (simp add: i1)
   444     apply (simp add: i2[simplified minus_le_iff])
   445     done
   446 qed
   447 
   448 instance lattice_ring \<subseteq> ordered_ring_abs
   449 proof
   450   fix a b :: "'a::lattice_ring"
   451   assume a: "(0 \<le> a \<or> a \<le> 0) \<and> (0 \<le> b \<or> b \<le> 0)"
   452   show "\<bar>a * b\<bar> = \<bar>a\<bar> * \<bar>b\<bar>"
   453   proof -
   454     have s: "(0 \<le> a * b) \<or> (a * b \<le> 0)"
   455       apply auto
   456       apply (rule_tac split_mult_pos_le)
   457       apply (rule_tac contrapos_np[of "a * b \<le> 0"])
   458       apply simp
   459       apply (rule_tac split_mult_neg_le)
   460       using a
   461       apply blast
   462       done
   463     have mulprts: "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
   464       by (simp flip: prts)
   465     show ?thesis
   466     proof (cases "0 \<le> a * b")
   467       case True
   468       then show ?thesis
   469         apply (simp_all add: mulprts abs_prts)
   470         using a
   471         apply (auto simp add:
   472           algebra_simps
   473           iffD1[OF zero_le_iff_zero_nprt] iffD1[OF le_zero_iff_zero_pprt]
   474           iffD1[OF le_zero_iff_pprt_id] iffD1[OF zero_le_iff_nprt_id])
   475         apply(drule (1) mult_nonneg_nonpos[of a b], simp)
   476         apply(drule (1) mult_nonneg_nonpos2[of b a], simp)
   477         done
   478     next
   479       case False
   480       with s have "a * b \<le> 0"
   481         by simp
   482       then show ?thesis
   483         apply (simp_all add: mulprts abs_prts)
   484         apply (insert a)
   485         apply (auto simp add: algebra_simps)
   486         apply(drule (1) mult_nonneg_nonneg[of a b],simp)
   487         apply(drule (1) mult_nonpos_nonpos[of a b],simp)
   488         done
   489     qed
   490   qed
   491 qed
   492 
   493 lemma mult_le_prts:
   494   fixes a b :: "'a::lattice_ring"
   495   assumes "a1 \<le> a"
   496     and "a \<le> a2"
   497     and "b1 \<le> b"
   498     and "b \<le> b2"
   499   shows "a * b \<le>
   500     pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1"
   501 proof -
   502   have "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
   503     by (subst prts[symmetric])+ simp
   504   then have "a * b = pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
   505     by (simp add: algebra_simps)
   506   moreover have "pprt a * pprt b \<le> pprt a2 * pprt b2"
   507     by (simp_all add: assms mult_mono)
   508   moreover have "pprt a * nprt b \<le> pprt a1 * nprt b2"
   509   proof -
   510     have "pprt a * nprt b \<le> pprt a * nprt b2"
   511       by (simp add: mult_left_mono assms)
   512     moreover have "pprt a * nprt b2 \<le> pprt a1 * nprt b2"
   513       by (simp add: mult_right_mono_neg assms)
   514     ultimately show ?thesis
   515       by simp
   516   qed
   517   moreover have "nprt a * pprt b \<le> nprt a2 * pprt b1"
   518   proof -
   519     have "nprt a * pprt b \<le> nprt a2 * pprt b"
   520       by (simp add: mult_right_mono assms)
   521     moreover have "nprt a2 * pprt b \<le> nprt a2 * pprt b1"
   522       by (simp add: mult_left_mono_neg assms)
   523     ultimately show ?thesis
   524       by simp
   525   qed
   526   moreover have "nprt a * nprt b \<le> nprt a1 * nprt b1"
   527   proof -
   528     have "nprt a * nprt b \<le> nprt a * nprt b1"
   529       by (simp add: mult_left_mono_neg assms)
   530     moreover have "nprt a * nprt b1 \<le> nprt a1 * nprt b1"
   531       by (simp add: mult_right_mono_neg assms)
   532     ultimately show ?thesis
   533       by simp
   534   qed
   535   ultimately show ?thesis
   536     by - (rule add_mono | simp)+
   537 qed
   538 
   539 lemma mult_ge_prts:
   540   fixes a b :: "'a::lattice_ring"
   541   assumes "a1 \<le> a"
   542     and "a \<le> a2"
   543     and "b1 \<le> b"
   544     and "b \<le> b2"
   545   shows "a * b \<ge>
   546     nprt a1 * pprt b2 + nprt a2 * nprt b2 + pprt a1 * pprt b1 + pprt a2 * nprt b1"
   547 proof -
   548   from assms have a1: "- a2 \<le> -a"
   549     by auto
   550   from assms have a2: "- a \<le> -a1"
   551     by auto
   552   from mult_le_prts[of "- a2" "- a" "- a1" "b1" b "b2",
   553     OF a1 a2 assms(3) assms(4), simplified nprt_neg pprt_neg]
   554   have le: "- (a * b) \<le>
   555     - nprt a1 * pprt b2 + - nprt a2 * nprt b2 +
   556     - pprt a1 * pprt b1 + - pprt a2 * nprt b1"
   557     by simp
   558   then have "- (- nprt a1 * pprt b2 + - nprt a2 * nprt b2 +
   559       - pprt a1 * pprt b1 + - pprt a2 * nprt b1) \<le> a * b"
   560     by (simp only: minus_le_iff)
   561   then show ?thesis
   562     by (simp add: algebra_simps)
   563 qed
   564 
   565 instance int :: lattice_ring
   566 proof
   567   show "\<bar>k\<bar> = sup k (- k)" for k :: int
   568     by (auto simp add: sup_int_def)
   569 qed
   570 
   571 instance real :: lattice_ring
   572 proof
   573   show "\<bar>a\<bar> = sup a (- a)" for a :: real
   574     by (auto simp add: sup_real_def)
   575 qed
   576 
   577 end