src/HOL/Library/Lattice_Algebras.thy
author wenzelm
Fri, 21 Mar 2025 22:26:18 +0100
changeset 82317 231b6d8231c6
parent 80777 623d46973cbe
permissions -rw-r--r--
more uniform Proof_Display.print_results for theory and proof output --- avoid loss of information seen in src/Doc/JEdit/document/output-and-state.png (the first bad changeset is f8c412a45af8, see also 53b59fa42696);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
61546
53bb4172c7f7 tuned whitespace;
wenzelm
parents: 60698
diff changeset
     1
(*  Author:     Steven Obua, TU Muenchen *)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
     2
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
     3
section \<open>Various algebraic structures combined with a lattice\<close>
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
     4
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
     5
theory Lattice_Algebras
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
     6
  imports Complex_Main
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
     7
begin
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
     8
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
     9
class semilattice_inf_ab_group_add = ordered_ab_group_add + semilattice_inf
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    10
begin
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    11
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    12
lemma add_inf_distrib_left: "a + inf b c = inf (a + b) (a + c)" (is "?L=?R")
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    13
proof (intro order.antisym)
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    14
  show "?R \<le> ?L"
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    15
  by (metis add_commute diff_le_eq inf_greatest inf_le1 inf_le2)
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    16
qed simp
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    17
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    18
lemma add_inf_distrib_right: "inf a b + c = inf (a + c) (b + c)"
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    19
  using add_commute add_inf_distrib_left by presburger
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    20
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    21
end
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    22
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    23
class semilattice_sup_ab_group_add = ordered_ab_group_add + semilattice_sup
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    24
begin
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    25
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    26
lemma add_sup_distrib_left: "a + sup b c = sup (a + b) (a + c)" (is "?L = ?R")
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    27
proof (rule order.antisym)
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    28
  show "?L \<le> ?R"
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    29
    by (metis add_commute le_diff_eq sup.bounded_iff sup_ge1 sup_ge2)
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
    30
qed simp
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    31
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    32
lemma add_sup_distrib_right: "sup a b + c = sup (a + c) (b + c)"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    33
proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    34
  have "c + sup a b = sup (c+a) (c+b)"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    35
    by (simp add: add_sup_distrib_left)
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    36
  then show ?thesis
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56228
diff changeset
    37
    by (simp add: add.commute)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    38
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    39
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    40
end
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    41
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    42
class lattice_ab_group_add = ordered_ab_group_add + lattice
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    43
begin
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    44
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    45
subclass semilattice_inf_ab_group_add ..
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    46
subclass semilattice_sup_ab_group_add ..
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    47
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    48
lemmas add_sup_inf_distribs =
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    49
  add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    50
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    51
lemma inf_eq_neg_sup: "inf a b = - sup (- a) (- b)"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    52
proof (rule inf_unique)
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    53
  fix a b c :: 'a
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    54
  show "- sup (- a) (- b) \<le> a"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    55
    by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"])
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    56
      (simp, simp add: add_sup_distrib_left)
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    57
  show "- sup (-a) (-b) \<le> b"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    58
    by (rule add_le_imp_le_right [of _ "sup (uminus a) (uminus b)"])
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    59
      (simp, simp add: add_sup_distrib_left)
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    60
  assume "a \<le> b" "a \<le> c"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    61
  then show "a \<le> - sup (-b) (-c)"
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    62
    by (subst neg_le_iff_le [symmetric]) (simp add: le_supI)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    63
qed
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    64
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    65
lemma sup_eq_neg_inf: "sup a b = - inf (- a) (- b)"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    66
proof (rule sup_unique)
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    67
  fix a b c :: 'a
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    68
  show "a \<le> - inf (- a) (- b)"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    69
    by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"])
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    70
      (simp, simp add: add_inf_distrib_left)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    71
  show "b \<le> - inf (- a) (- b)"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    72
    by (rule add_le_imp_le_right [of _ "inf (uminus a) (uminus b)"])
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    73
      (simp, simp add: add_inf_distrib_left)
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
    74
  show "- inf (- a) (- b) \<le> c" if "a \<le> c" "b \<le> c"
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
    75
    using that by (subst neg_le_iff_le [symmetric]) (simp add: le_infI)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    76
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    77
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    78
lemma neg_inf_eq_sup: "- inf a b = sup (- a) (- b)"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    79
  by (simp add: inf_eq_neg_sup)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    80
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
    81
lemma diff_inf_eq_sup: "a - inf b c = a + sup (- b) (- c)"
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
    82
  using neg_inf_eq_sup [of b c, symmetric] by simp
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
    83
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    84
lemma neg_sup_eq_inf: "- sup a b = inf (- a) (- b)"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    85
  by (simp add: sup_eq_neg_inf)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    86
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
    87
lemma diff_sup_eq_inf: "a - sup b c = a + inf (- b) (- c)"
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
    88
  using neg_sup_eq_inf [of b c, symmetric] by simp
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
    89
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    90
lemma add_eq_inf_sup: "a + b = sup a b + inf a b"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
    91
proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    92
  have "0 = - inf 0 (a - b) + inf (a - b) 0"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    93
    by (simp add: inf_commute)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    94
  then have "0 = sup 0 (b - a) + inf (a - b) 0"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
    95
    by (simp add: inf_eq_neg_sup)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    96
  then have "0 = (- a + sup a b) + (inf a b + (- b))"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
    97
    by (simp only: add_sup_distrib_left add_inf_distrib_right) simp
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    98
  then show ?thesis
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
    99
    by (simp add: algebra_simps)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   100
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   101
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   102
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   103
subsection \<open>Positive Part, Negative Part, Absolute Value\<close>
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   104
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   105
definition nprt :: "'a \<Rightarrow> 'a"
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   106
  where "nprt x = inf x 0"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   107
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   108
definition pprt :: "'a \<Rightarrow> 'a"
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   109
  where "pprt x = sup x 0"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   110
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   111
lemma pprt_neg: "pprt (- x) = - nprt x"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   112
proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   113
  have "sup (- x) 0 = sup (- x) (- 0)"
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   114
    by (simp only: minus_zero)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   115
  also have "\<dots> = - inf x 0"
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   116
    by (simp only: neg_inf_eq_sup)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   117
  finally have "sup (- x) 0 = - inf x 0" .
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   118
  then show ?thesis
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   119
    by (simp only: pprt_def nprt_def)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   120
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   121
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   122
lemma nprt_neg: "nprt (- x) = - pprt x"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   123
proof -
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   124
  from pprt_neg have "pprt (- (- x)) = - nprt (- x)" .
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   125
  then have "pprt x = - nprt (- x)" by simp
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   126
  then show ?thesis by simp
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   127
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   128
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   129
lemma prts: "a = pprt a + nprt a"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 65151
diff changeset
   130
  by (simp add: pprt_def nprt_def flip: add_eq_inf_sup)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   131
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   132
lemma zero_le_pprt[simp]: "0 \<le> pprt a"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   133
  by (simp add: pprt_def)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   134
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   135
lemma nprt_le_zero[simp]: "nprt a \<le> 0"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   136
  by (simp add: nprt_def)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   137
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   138
lemma le_eq_neg: "a \<le> - b \<longleftrightarrow> a + b \<le> 0"
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   139
  (is "?lhs = ?rhs")
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   140
proof
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   141
  assume ?lhs
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   142
  show ?rhs
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   143
    by (rule add_le_imp_le_right[of _ "uminus b" _]) (simp add: add.assoc \<open>?lhs\<close>)
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   144
next
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   145
  assume ?rhs
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   146
  show ?lhs
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   147
    by (rule add_le_imp_le_right[of _ "b" _]) (simp add: \<open>?rhs\<close>)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   148
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   149
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   150
lemma pprt_0[simp]: "pprt 0 = 0" by (simp add: pprt_def)
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   151
lemma nprt_0[simp]: "nprt 0 = 0" by (simp add: nprt_def)
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   152
35828
46cfc4b8112e now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents: 35040
diff changeset
   153
lemma pprt_eq_id [simp, no_atp]: "0 \<le> x \<Longrightarrow> pprt x = x"
46986
8198cbff1771 tuned proofs;
wenzelm
parents: 41528
diff changeset
   154
  by (simp add: pprt_def sup_absorb1)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   155
35828
46cfc4b8112e now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents: 35040
diff changeset
   156
lemma nprt_eq_id [simp, no_atp]: "x \<le> 0 \<Longrightarrow> nprt x = x"
46986
8198cbff1771 tuned proofs;
wenzelm
parents: 41528
diff changeset
   157
  by (simp add: nprt_def inf_absorb1)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   158
35828
46cfc4b8112e now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents: 35040
diff changeset
   159
lemma pprt_eq_0 [simp, no_atp]: "x \<le> 0 \<Longrightarrow> pprt x = 0"
46986
8198cbff1771 tuned proofs;
wenzelm
parents: 41528
diff changeset
   160
  by (simp add: pprt_def sup_absorb2)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   161
35828
46cfc4b8112e now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents: 35040
diff changeset
   162
lemma nprt_eq_0 [simp, no_atp]: "0 \<le> x \<Longrightarrow> nprt x = 0"
46986
8198cbff1771 tuned proofs;
wenzelm
parents: 41528
diff changeset
   163
  by (simp add: nprt_def inf_absorb2)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   164
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   165
lemma sup_0_imp_0:
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   166
  assumes "sup a (- a) = 0"
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   167
  shows "a = 0"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   168
proof -
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   169
  have pos: "0 \<le> a" if "sup a (- a) = 0" for a :: 'a
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   170
  proof -
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   171
    from that have "sup a (- a) + a = a"
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   172
      by simp
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   173
    then have "sup (a + a) 0 = a"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   174
      by (simp add: add_sup_distrib_right)
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   175
    then have "sup (a + a) 0 \<le> a"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   176
      by simp
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   177
    then show ?thesis
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   178
      by (blast intro: order_trans inf_sup_ord)
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   179
  qed
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   180
  from assms have **: "sup (-a) (-(-a)) = 0"
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   181
    by (simp add: sup_commute)
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   182
  from pos[OF assms] pos[OF **] show "a = 0"
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   183
    by simp
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   184
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   185
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   186
lemma inf_0_imp_0: "inf a (- a) = 0 \<Longrightarrow> a = 0"
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   187
  by (metis local.neg_0_equal_iff_equal neg_inf_eq_sup sup_0_imp_0)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   188
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   189
lemma inf_0_eq_0 [simp]: "inf a (- a) = 0 \<longleftrightarrow> a = 0"
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   190
  by (metis inf_0_imp_0 inf.idem minus_zero)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   191
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   192
lemma sup_0_eq_0 [simp]: "sup a (- a) = 0 \<longleftrightarrow> a = 0"
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   193
  by (metis minus_zero sup.idem sup_0_imp_0)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   194
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   195
lemma zero_le_double_add_iff_zero_le_single_add [simp]: "0 \<le> a + a \<longleftrightarrow> 0 \<le> a"
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   196
  (is "?lhs \<longleftrightarrow> ?rhs")
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   197
proof
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   198
  show ?rhs if ?lhs
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   199
  proof -
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   200
    from that have a: "inf (a + a) 0 = 0"
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   201
      by (simp add: inf_commute inf_absorb1)
61546
53bb4172c7f7 tuned whitespace;
wenzelm
parents: 60698
diff changeset
   202
    have "inf a 0 + inf a 0 = inf (inf (a + a) 0) a"  (is "?l = _")
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   203
      by (simp add: add_sup_inf_distribs inf_aci)
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   204
    then have "?l = 0 + inf a 0"
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   205
      by (simp add: a, simp add: inf_commute)
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   206
    then have "inf a 0 = 0"
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   207
      by (simp only: add_right_cancel)
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   208
    then show ?thesis
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   209
      unfolding le_iff_inf by (simp add: inf_commute)
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   210
  qed
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   211
  show ?lhs if ?rhs
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   212
    by (simp add: add_mono[OF that that, simplified])
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   213
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   214
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   215
lemma double_zero [simp]: "a + a = 0 \<longleftrightarrow> a = 0"
73411
1f1366966296 avoid name clash
haftmann
parents: 68406
diff changeset
   216
  using add_nonneg_eq_0_iff order.eq_iff by auto
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   217
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   218
lemma zero_less_double_add_iff_zero_less_single_add [simp]: "0 < a + a \<longleftrightarrow> 0 < a"
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   219
  by (meson le_less_trans less_add_same_cancel2 less_le_not_le
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   220
      zero_le_double_add_iff_zero_le_single_add)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   221
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   222
lemma double_add_le_zero_iff_single_add_le_zero [simp]: "a + a \<le> 0 \<longleftrightarrow> a \<le> 0"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   223
proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   224
  have "a + a \<le> 0 \<longleftrightarrow> 0 \<le> - (a + a)"
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   225
    by (subst le_minus_iff) simp
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
   226
  moreover have "\<dots> \<longleftrightarrow> a \<le> 0"
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
   227
    by (simp only: minus_add_distrib zero_le_double_add_iff_zero_le_single_add) simp
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   228
  ultimately show ?thesis
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   229
    by blast
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   230
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   231
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   232
lemma double_add_less_zero_iff_single_less_zero [simp]: "a + a < 0 \<longleftrightarrow> a < 0"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   233
proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   234
  have "a + a < 0 \<longleftrightarrow> 0 < - (a + a)"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   235
    by (subst less_minus_iff) simp
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
   236
  moreover have "\<dots> \<longleftrightarrow> a < 0"
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
   237
    by (simp only: minus_add_distrib zero_less_double_add_iff_zero_less_single_add) simp
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   238
  ultimately show ?thesis
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   239
    by blast
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   240
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   241
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   242
declare neg_inf_eq_sup [simp]
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   243
  and neg_sup_eq_inf [simp]
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   244
  and diff_inf_eq_sup [simp]
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   245
  and diff_sup_eq_inf [simp]
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   246
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   247
lemma le_minus_self_iff: "a \<le> - a \<longleftrightarrow> a \<le> 0"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   248
proof -
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   249
  from add_le_cancel_left [of "uminus a" "plus a a" zero]
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   250
  have "a \<le> - a \<longleftrightarrow> a + a \<le> 0"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 65151
diff changeset
   251
    by (simp flip: add.assoc)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   252
  then show ?thesis
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   253
    by simp
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   254
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   255
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   256
lemma minus_le_self_iff: "- a \<le> a \<longleftrightarrow> 0 \<le> a"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   257
proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   258
  have "- a \<le> a \<longleftrightarrow> 0 \<le> a + a"
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   259
    using add_le_cancel_left [of "uminus a" zero "plus a a"]
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 65151
diff changeset
   260
    by (simp flip: add.assoc)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   261
  then show ?thesis
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   262
    by simp
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   263
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   264
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   265
lemma zero_le_iff_zero_nprt: "0 \<le> a \<longleftrightarrow> nprt a = 0"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   266
  unfolding le_iff_inf by (simp add: nprt_def inf_commute)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   267
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   268
lemma le_zero_iff_zero_pprt: "a \<le> 0 \<longleftrightarrow> pprt a = 0"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   269
  unfolding le_iff_sup by (simp add: pprt_def sup_commute)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   270
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   271
lemma le_zero_iff_pprt_id: "0 \<le> a \<longleftrightarrow> pprt a = a"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   272
  unfolding le_iff_sup by (simp add: pprt_def sup_commute)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   273
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   274
lemma zero_le_iff_nprt_id: "a \<le> 0 \<longleftrightarrow> nprt a = a"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   275
  unfolding le_iff_inf by (simp add: nprt_def inf_commute)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   276
35828
46cfc4b8112e now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents: 35040
diff changeset
   277
lemma pprt_mono [simp, no_atp]: "a \<le> b \<Longrightarrow> pprt a \<le> pprt b"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   278
  unfolding le_iff_sup by (simp add: pprt_def sup_aci sup_assoc [symmetric, of a])
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   279
35828
46cfc4b8112e now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents: 35040
diff changeset
   280
lemma nprt_mono [simp, no_atp]: "a \<le> b \<Longrightarrow> nprt a \<le> nprt b"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   281
  unfolding le_iff_inf by (simp add: nprt_def inf_aci inf_assoc [symmetric, of a])
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   282
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   283
end
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   284
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   285
lemmas add_sup_inf_distribs =
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   286
  add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   287
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   288
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   289
class lattice_ab_group_add_abs = lattice_ab_group_add + abs +
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   290
  assumes abs_lattice: "\<bar>a\<bar> = sup a (- a)"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   291
begin
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   292
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   293
lemma abs_prts: "\<bar>a\<bar> = pprt a - nprt a"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   294
proof -
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   295
  have "0 \<le> \<bar>a\<bar>"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   296
  proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   297
    have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   298
      by (auto simp add: abs_lattice)
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   299
    show ?thesis
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   300
      by (rule add_mono [OF a b, simplified])
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   301
  qed
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   302
  then have "0 \<le> sup a (- a)"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   303
    unfolding abs_lattice .
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   304
  then have "sup (sup a (- a)) 0 = sup a (- a)"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   305
    by (rule sup_absorb1)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   306
  then show ?thesis
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
   307
    by (simp add: add_sup_inf_distribs ac_simps pprt_def nprt_def abs_lattice)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   308
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   309
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   310
subclass ordered_ab_group_add_abs
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   311
proof
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   312
  have abs_ge_zero [simp]: "0 \<le> \<bar>a\<bar>" for a
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   313
  proof -
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   314
    have a: "a \<le> \<bar>a\<bar>" and b: "- a \<le> \<bar>a\<bar>"
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   315
      by (auto simp add: abs_lattice)
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   316
    show "0 \<le> \<bar>a\<bar>"
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   317
      by (rule add_mono [OF a b, simplified])
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   318
  qed
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   319
  have abs_leI: "a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" for a b
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   320
    by (simp add: abs_lattice le_supI)
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   321
  fix a b
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   322
  show "0 \<le> \<bar>a\<bar>"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   323
    by simp
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   324
  show "a \<le> \<bar>a\<bar>"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   325
    by (auto simp add: abs_lattice)
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   326
  show "\<bar>-a\<bar> = \<bar>a\<bar>"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   327
    by (simp add: abs_lattice sup_commute)
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   328
  show "- a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" if "a \<le> b"
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   329
    using that by (rule abs_leI)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   330
  show "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   331
  proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   332
    have g: "\<bar>a\<bar> + \<bar>b\<bar> = sup (a + b) (sup (- a - b) (sup (- a + b) (a + (- b))))"
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   333
      (is "_ = sup ?m ?n")
57862
8f074e6e22fc tuned proofs;
wenzelm
parents: 57512
diff changeset
   334
      by (simp add: abs_lattice add_sup_inf_distribs ac_simps)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   335
    have a: "a + b \<le> sup ?m ?n"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   336
      by simp
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   337
    have b: "- a - b \<le> ?n"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   338
      by simp
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   339
    have c: "?n \<le> sup ?m ?n"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   340
      by simp
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   341
    from b c have d: "- a - b \<le> sup ?m ?n"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   342
      by (rule order_trans)
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   343
    have e: "- a - b = - (a + b)"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   344
      by simp
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   345
    from a d e have "\<bar>a + b\<bar> \<le> sup ?m ?n"
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   346
      by (metis abs_leI)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   347
    with g[symmetric] show ?thesis by simp
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   348
  qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   349
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   350
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   351
end
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   352
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   353
lemma sup_eq_if:
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   354
  fixes a :: "'a::{lattice_ab_group_add,linorder}"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   355
  shows "sup a (- a) = (if a < 0 then - a else a)"
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   356
  using add_le_cancel_right [of a a "- a", symmetric, simplified]
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   357
    and add_le_cancel_right [of "-a" a a, symmetric, simplified]
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   358
  by (auto simp: sup_max max.absorb1 max.absorb2)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   359
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   360
lemma abs_if_lattice:
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   361
  fixes a :: "'a::{lattice_ab_group_add_abs,linorder}"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   362
  shows "\<bar>a\<bar> = (if a < 0 then - a else a)"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   363
  by auto
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   364
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   365
lemma estimate_by_abs:
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   366
  fixes a b c :: "'a::lattice_ab_group_add_abs"
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   367
  assumes "a + b \<le> c"
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   368
  shows "a \<le> c + \<bar>b\<bar>"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   369
proof -
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   370
  from assms have "a \<le> c + (- b)"
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   371
    by (simp add: algebra_simps)
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   372
  have "- b \<le> \<bar>b\<bar>"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   373
    by (rule abs_ge_minus_self)
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   374
  then have "c + (- b) \<le> c + \<bar>b\<bar>"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   375
    by (rule add_left_mono)
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 58881
diff changeset
   376
  with \<open>a \<le> c + (- b)\<close> show ?thesis
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   377
    by (rule order_trans)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   378
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   379
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   380
class lattice_ring = ordered_ring + lattice_ab_group_add_abs
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   381
begin
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   382
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   383
subclass semilattice_inf_ab_group_add ..
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   384
subclass semilattice_sup_ab_group_add ..
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   385
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   386
end
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   387
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   388
lemma abs_le_mult:
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   389
  fixes a b :: "'a::lattice_ring"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   390
  shows "\<bar>a * b\<bar> \<le> \<bar>a\<bar> * \<bar>b\<bar>"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   391
proof -
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   392
  let ?x = "pprt a * pprt b - pprt a * nprt b - nprt a * pprt b + nprt a * nprt b"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   393
  let ?y = "pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   394
  have a: "\<bar>a\<bar> * \<bar>b\<bar> = ?x"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   395
    by (simp only: abs_prts[of a] abs_prts[of b] algebra_simps)
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   396
  have bh: "u = a \<Longrightarrow> v = b \<Longrightarrow>
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   397
            u * v = pprt a * pprt b + pprt a * nprt b +
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   398
                    nprt a * pprt b + nprt a * nprt b" for u v :: 'a
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   399
    by (metis add.commute combine_common_factor distrib_left prts)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   400
  note b = this[OF refl[of a] refl[of b]]
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   401
  have xy: "- ?x \<le> ?y"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
   402
    apply simp
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   403
    by (meson add_increasing2 diff_le_eq neg_le_0_iff_le nprt_le_zero order.trans split_mult_pos_le zero_le_pprt)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   404
  have yx: "?y \<le> ?x"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53240
diff changeset
   405
    apply simp
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   406
    by (metis add_decreasing2 diff_0 diff_mono diff_zero mult_nonpos_nonneg mult_right_mono_neg mult_zero_left nprt_le_zero zero_le_pprt)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   407
  show ?thesis
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   408
  proof (rule abs_leI)
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   409
    show "a * b \<le> \<bar>a\<bar> * \<bar>b\<bar>"
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   410
      by (simp only: a b yx)
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   411
    show "- (a * b) \<le> \<bar>a\<bar> * \<bar>b\<bar>"
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   412
      by (metis a bh minus_le_iff xy)
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   413
  qed
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   414
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   415
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   416
instance lattice_ring \<subseteq> ordered_ring_abs
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   417
proof
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   418
  fix a b :: "'a::lattice_ring"
41528
276078f01ada eliminated global prems;
wenzelm
parents: 37884
diff changeset
   419
  assume a: "(0 \<le> a \<or> a \<le> 0) \<and> (0 \<le> b \<or> b \<le> 0)"
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   420
  show "\<bar>a * b\<bar> = \<bar>a\<bar> * \<bar>b\<bar>"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   421
  proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   422
    have s: "(0 \<le> a * b) \<or> (a * b \<le> 0)"
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   423
      by (metis a split_mult_neg_le split_mult_pos_le)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   424
    have mulprts: "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
68406
6beb45f6cf67 utilize 'flip'
nipkow
parents: 65151
diff changeset
   425
      by (simp flip: prts)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   426
    show ?thesis
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   427
    proof (cases "0 \<le> a * b")
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   428
      case True
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   429
      then show ?thesis
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   430
        using a split_mult_neg_le by fastforce
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   431
    next
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   432
      case False
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   433
      with s have "a * b \<le> 0"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   434
        by simp
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   435
      then show ?thesis
80777
623d46973cbe More tidying of old proofs
paulson <lp15@cam.ac.uk>
parents: 73411
diff changeset
   436
        using a split_mult_pos_le by fastforce
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   437
    qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   438
  qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   439
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   440
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   441
lemma mult_le_prts:
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   442
  fixes a b :: "'a::lattice_ring"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   443
  assumes "a1 \<le> a"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   444
    and "a \<le> a2"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   445
    and "b1 \<le> b"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   446
    and "b \<le> b2"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   447
  shows "a * b \<le>
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   448
    pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1"
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   449
proof -
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   450
  have "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   451
    by (subst prts[symmetric])+ simp
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   452
  then have "a * b = pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   453
    by (simp add: algebra_simps)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   454
  moreover have "pprt a * pprt b \<le> pprt a2 * pprt b2"
41528
276078f01ada eliminated global prems;
wenzelm
parents: 37884
diff changeset
   455
    by (simp_all add: assms mult_mono)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   456
  moreover have "pprt a * nprt b \<le> pprt a1 * nprt b2"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   457
  proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   458
    have "pprt a * nprt b \<le> pprt a * nprt b2"
41528
276078f01ada eliminated global prems;
wenzelm
parents: 37884
diff changeset
   459
      by (simp add: mult_left_mono assms)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   460
    moreover have "pprt a * nprt b2 \<le> pprt a1 * nprt b2"
41528
276078f01ada eliminated global prems;
wenzelm
parents: 37884
diff changeset
   461
      by (simp add: mult_right_mono_neg assms)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   462
    ultimately show ?thesis
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   463
      by simp
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   464
  qed
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   465
  moreover have "nprt a * pprt b \<le> nprt a2 * pprt b1"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   466
  proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   467
    have "nprt a * pprt b \<le> nprt a2 * pprt b"
41528
276078f01ada eliminated global prems;
wenzelm
parents: 37884
diff changeset
   468
      by (simp add: mult_right_mono assms)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   469
    moreover have "nprt a2 * pprt b \<le> nprt a2 * pprt b1"
41528
276078f01ada eliminated global prems;
wenzelm
parents: 37884
diff changeset
   470
      by (simp add: mult_left_mono_neg assms)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   471
    ultimately show ?thesis
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   472
      by simp
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   473
  qed
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   474
  moreover have "nprt a * nprt b \<le> nprt a1 * nprt b1"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   475
  proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   476
    have "nprt a * nprt b \<le> nprt a * nprt b1"
41528
276078f01ada eliminated global prems;
wenzelm
parents: 37884
diff changeset
   477
      by (simp add: mult_left_mono_neg assms)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   478
    moreover have "nprt a * nprt b1 \<le> nprt a1 * nprt b1"
41528
276078f01ada eliminated global prems;
wenzelm
parents: 37884
diff changeset
   479
      by (simp add: mult_right_mono_neg assms)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   480
    ultimately show ?thesis
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   481
      by simp
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   482
  qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   483
  ultimately show ?thesis
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   484
    by - (rule add_mono | simp)+
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   485
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   486
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   487
lemma mult_ge_prts:
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   488
  fixes a b :: "'a::lattice_ring"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   489
  assumes "a1 \<le> a"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   490
    and "a \<le> a2"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   491
    and "b1 \<le> b"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   492
    and "b \<le> b2"
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   493
  shows "a * b \<ge>
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   494
    nprt a1 * pprt b2 + nprt a2 * nprt b2 + pprt a1 * pprt b1 + pprt a2 * nprt b1"
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   495
proof -
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   496
  from assms have a1: "- a2 \<le> -a"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   497
    by auto
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   498
  from assms have a2: "- a \<le> -a1"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   499
    by auto
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   500
  from mult_le_prts[of "- a2" "- a" "- a1" "b1" b "b2",
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   501
    OF a1 a2 assms(3) assms(4), simplified nprt_neg pprt_neg]
60698
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   502
  have le: "- (a * b) \<le>
29e8bdc41f90 tuned proofs;
wenzelm
parents: 60500
diff changeset
   503
    - nprt a1 * pprt b2 + - nprt a2 * nprt b2 +
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   504
    - pprt a1 * pprt b1 + - pprt a2 * nprt b1"
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   505
    by simp
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   506
  then have "- (- nprt a1 * pprt b2 + - nprt a2 * nprt b2 +
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   507
      - pprt a1 * pprt b1 + - pprt a2 * nprt b1) \<le> a * b"
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   508
    by (simp only: minus_le_iff)
56228
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   509
  then show ?thesis
0f6dc7512023 tuned proofs;
wenzelm
parents: 54863
diff changeset
   510
    by (simp add: algebra_simps)
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   511
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   512
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   513
instance int :: lattice_ring
53240
07593a0a27f4 tuned proofs;
wenzelm
parents: 46986
diff changeset
   514
proof
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   515
  show "\<bar>k\<bar> = sup k (- k)" for k :: int
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   516
    by (auto simp add: sup_int_def)
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   517
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   518
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   519
instance real :: lattice_ring
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   520
proof
65151
a7394aa4d21c tuned proofs;
wenzelm
parents: 61546
diff changeset
   521
  show "\<bar>a\<bar> = sup a (- a)" for a :: real
35040
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   522
    by (auto simp add: sup_real_def)
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   523
qed
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   524
e42e7f133d94 separate library theory for type classes combining lattices with various algebraic structures; c.f. cs. 7efe662e41b4
haftmann
parents:
diff changeset
   525
end