src/HOL/OrderedGroup.thy
author obua
Thu, 07 Jun 2007 17:21:43 +0200
changeset 23293 77577fc2f141
parent 23181 f52b555f8141
child 23389 aaca6a8e5414
permissions -rw-r--r--
deleted comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14770
fe9504ba63d5 removed duplicate thms;
wenzelm
parents: 14754
diff changeset
     1
(*  Title:   HOL/OrderedGroup.thy
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
     2
    ID:      $Id$
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
     3
    Author:  Gertrud Bauer, Steven Obua, Lawrence C Paulson, and Markus Wenzel,
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
     4
             with contributions by Jeremy Avigad
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
     5
*)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
     6
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
     7
header {* Ordered Groups *}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
     8
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15093
diff changeset
     9
theory OrderedGroup
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
    10
imports Lattices
19798
wenzelm
parents: 19527
diff changeset
    11
uses "~~/src/Provers/Arith/abel_cancel.ML"
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15093
diff changeset
    12
begin
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    13
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    14
text {*
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    15
  The theory of partially ordered groups is taken from the books:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    16
  \begin{itemize}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    17
  \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    18
  \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    19
  \end{itemize}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    20
  Most of the used notions can also be looked up in 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    21
  \begin{itemize}
14770
fe9504ba63d5 removed duplicate thms;
wenzelm
parents: 14754
diff changeset
    22
  \item \url{http://www.mathworld.com} by Eric Weisstein et. al.
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    23
  \item \emph{Algebra I} by van der Waerden, Springer.
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    24
  \end{itemize}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    25
*}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    26
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    27
subsection {* Semigroups and Monoids *}
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    28
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    29
class semigroup_add = plus +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    30
  assumes add_assoc: "(a \<^loc>+ b) \<^loc>+ c = a \<^loc>+ (b \<^loc>+ c)"
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    31
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    32
class ab_semigroup_add = semigroup_add +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    33
  assumes add_commute: "a \<^loc>+ b = b \<^loc>+ a"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    34
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    35
lemma add_left_commute: "a + (b + c) = b + (a + (c::'a::ab_semigroup_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    36
  by (rule mk_left_commute [of "op +", OF add_assoc add_commute])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    37
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    38
theorems add_ac = add_assoc add_commute add_left_commute
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    39
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    40
class semigroup_mult = times +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    41
  assumes mult_assoc: "(a \<^loc>* b) \<^loc>* c = a \<^loc>* (b \<^loc>* c)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    42
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    43
class ab_semigroup_mult = semigroup_mult +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    44
  assumes mult_commute: "a \<^loc>* b = b \<^loc>* a"
23181
f52b555f8141 localized
haftmann
parents: 23085
diff changeset
    45
begin
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    46
23181
f52b555f8141 localized
haftmann
parents: 23085
diff changeset
    47
lemma mult_left_commute: "a \<^loc>* (b \<^loc>* c) = b \<^loc>* (a \<^loc>* c)"
f52b555f8141 localized
haftmann
parents: 23085
diff changeset
    48
  by (rule mk_left_commute [of "op \<^loc>*", OF mult_assoc mult_commute])
f52b555f8141 localized
haftmann
parents: 23085
diff changeset
    49
f52b555f8141 localized
haftmann
parents: 23085
diff changeset
    50
end
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    51
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    52
theorems mult_ac = mult_assoc mult_commute mult_left_commute
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    53
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    54
class monoid_add = zero + semigroup_add +
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    55
  assumes add_0_left [simp]: "\<^loc>0 \<^loc>+ a = a" and add_0_right [simp]: "a \<^loc>+ \<^loc>0 = a"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    56
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    57
class comm_monoid_add = zero + ab_semigroup_add +
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    58
  assumes add_0: "\<^loc>0 \<^loc>+ a = a"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    59
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    60
instance comm_monoid_add < monoid_add
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    61
by intro_classes (insert comm_monoid_add_class.zero_plus.add_0, simp_all add: add_commute, auto)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    62
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    63
class monoid_mult = one + semigroup_mult +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    64
  assumes mult_1_left [simp]: "\<^loc>1 \<^loc>* a  = a"
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    65
  assumes mult_1_right [simp]: "a \<^loc>* \<^loc>1 = a"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    66
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    67
class comm_monoid_mult = one + ab_semigroup_mult +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    68
  assumes mult_1: "\<^loc>1 \<^loc>* a = a"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    69
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    70
instance comm_monoid_mult \<subseteq> monoid_mult
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    71
  by intro_classes (insert mult_1, simp_all add: mult_commute, auto)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    72
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    73
class cancel_semigroup_add = semigroup_add +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    74
  assumes add_left_imp_eq: "a \<^loc>+ b = a \<^loc>+ c \<Longrightarrow> b = c"
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    75
  assumes add_right_imp_eq: "b \<^loc>+ a = c \<^loc>+ a \<Longrightarrow> b = c"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    76
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    77
class cancel_ab_semigroup_add = ab_semigroup_add +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    78
  assumes add_imp_eq: "a \<^loc>+ b = a \<^loc>+ c \<Longrightarrow> b = c"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    79
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    80
instance cancel_ab_semigroup_add \<subseteq> cancel_semigroup_add
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    81
proof intro_classes
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    82
  fix a b c :: 'a
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    83
  assume "a + b = a + c" 
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    84
  then show "b = c" by (rule add_imp_eq)
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    85
next
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    86
  fix a b c :: 'a
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    87
  assume "b + a = c + a"
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    88
  then have "a + b = a + c" by (simp only: add_commute)
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
    89
  then show "b = c" by (rule add_imp_eq)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    90
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
    91
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    92
lemma add_left_cancel [simp]:
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    93
  "a + b = a + c \<longleftrightarrow> b = (c \<Colon> 'a\<Colon>cancel_semigroup_add)"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    94
  by (blast dest: add_left_imp_eq)
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    95
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    96
lemma add_right_cancel [simp]:
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    97
  "b + a = c + a \<longleftrightarrow> b = (c \<Colon> 'a\<Colon>cancel_semigroup_add)"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    98
  by (blast dest: add_right_imp_eq)
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
    99
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   100
subsection {* Groups *}
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   101
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   102
class ab_group_add = minus + comm_monoid_add +
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   103
  assumes ab_left_minus: "uminus a \<^loc>+ a = \<^loc>0"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   104
  assumes ab_diff_minus: "a \<^loc>- b = a \<^loc>+ (uminus b)"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   105
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   106
class group_add = minus + monoid_add +
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   107
  assumes left_minus [simp]: "uminus a \<^loc>+ a = \<^loc>0"
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   108
  assumes diff_minus: "a \<^loc>- b = a \<^loc>+ (uminus b)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   109
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   110
instance ab_group_add < group_add
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   111
by intro_classes (simp_all add: ab_left_minus ab_diff_minus)
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   112
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   113
instance ab_group_add \<subseteq> cancel_ab_semigroup_add
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   114
proof intro_classes
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   115
  fix a b c :: 'a
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   116
  assume "a + b = a + c"
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   117
  then have "uminus a + a + b = uminus a + a + c" unfolding add_assoc by simp
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   118
  then show "b = c" by simp
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   119
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   120
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   121
lemma minus_add_cancel: "-(a::'a::group_add) + (a+b) = b"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   122
by(simp add:add_assoc[symmetric])
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   123
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   124
lemma minus_zero[simp]: "-(0::'a::group_add) = 0"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   125
proof -
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   126
  have "-(0::'a::group_add) = - 0 + (0+0)" by(simp only: add_0_right)
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   127
  also have "\<dots> = 0" by(rule minus_add_cancel)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   128
  finally show ?thesis .
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   129
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   130
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   131
lemma minus_minus[simp]: "- (-(a::'a::group_add)) = a"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   132
proof -
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   133
  have "-(-a) = -(-a) + (-a + a)" by simp
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   134
  also have "\<dots> = a" by(rule minus_add_cancel)
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   135
  finally show ?thesis .
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   136
qed
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   137
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   138
lemma right_minus[simp]: "a + - a = (0::'a::group_add)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   139
proof -
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   140
  have "a + -a = -(-a) + -a" by simp
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   141
  also have "\<dots> = 0" thm group_add.left_minus by(rule left_minus)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   142
  finally show ?thesis .
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   143
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   144
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   145
lemma right_minus_eq: "(a - b = 0) = (a = (b::'a::group_add))"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   146
proof
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   147
  assume "a - b = 0"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   148
  have "a = (a - b) + b" by (simp add:diff_minus add_assoc)
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   149
  also have "\<dots> = b" using `a - b = 0` by simp
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   150
  finally show "a = b" .
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   151
next
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   152
  assume "a = b" thus "a - b = 0" by (simp add: diff_minus)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   153
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   154
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   155
lemma equals_zero_I: assumes "a+b = 0" shows "-a = (b::'a::group_add)"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   156
proof -
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   157
  have "- a = -a + (a+b)" using assms by simp
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   158
  also have "\<dots> = b" by(simp add:add_assoc[symmetric])
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   159
  finally show ?thesis .
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   160
qed
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   161
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   162
lemma diff_self[simp]: "(a::'a::group_add) - a = 0"
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   163
by(simp add: diff_minus)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   164
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   165
lemma diff_0 [simp]: "(0::'a::group_add) - a = -a"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   166
by (simp add: diff_minus)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   167
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   168
lemma diff_0_right [simp]: "a - (0::'a::group_add) = a" 
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   169
by (simp add: diff_minus)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   170
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   171
lemma diff_minus_eq_add [simp]: "a - - b = a + (b::'a::group_add)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   172
by (simp add: diff_minus)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   173
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   174
lemma neg_equal_iff_equal [simp]: "(-a = -b) = (a = (b::'a::group_add))" 
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   175
proof 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   176
  assume "- a = - b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   177
  hence "- (- a) = - (- b)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   178
    by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   179
  thus "a=b" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   180
next
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   181
  assume "a=b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   182
  thus "-a = -b" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   183
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   184
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   185
lemma neg_equal_0_iff_equal [simp]: "(-a = 0) = (a = (0::'a::group_add))"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   186
by (subst neg_equal_iff_equal [symmetric], simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   187
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   188
lemma neg_0_equal_iff_equal [simp]: "(0 = -a) = (0 = (a::'a::group_add))"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   189
by (subst neg_equal_iff_equal [symmetric], simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   190
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   191
text{*The next two equations can make the simplifier loop!*}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   192
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   193
lemma equation_minus_iff: "(a = - b) = (b = - (a::'a::group_add))"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   194
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   195
  have "(- (-a) = - b) = (- a = b)" by (rule neg_equal_iff_equal)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   196
  thus ?thesis by (simp add: eq_commute)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   197
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   198
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   199
lemma minus_equation_iff: "(- a = b) = (- (b::'a::group_add) = a)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   200
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   201
  have "(- a = - (-b)) = (a = -b)" by (rule neg_equal_iff_equal)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   202
  thus ?thesis by (simp add: eq_commute)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   203
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   204
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   205
lemma minus_add_distrib [simp]: "- (a + b) = -a + -(b::'a::ab_group_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   206
apply (rule equals_zero_I)
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
   207
apply (simp add: add_ac)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   208
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   209
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   210
lemma minus_diff_eq [simp]: "- (a - b) = b - (a::'a::ab_group_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   211
by (simp add: diff_minus add_commute)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   212
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   213
subsection {* (Partially) Ordered Groups *} 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   214
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   215
class pordered_ab_semigroup_add = order + ab_semigroup_add +
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   216
  assumes add_left_mono: "a \<sqsubseteq> b \<Longrightarrow> c \<^loc>+ a \<sqsubseteq> c \<^loc>+ b"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   217
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   218
class pordered_cancel_ab_semigroup_add =
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   219
  pordered_ab_semigroup_add + cancel_ab_semigroup_add
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   220
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   221
class pordered_ab_semigroup_add_imp_le = pordered_cancel_ab_semigroup_add +
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   222
  assumes add_le_imp_le_left: "c \<^loc>+ a \<sqsubseteq> c \<^loc>+ b \<Longrightarrow> a \<sqsubseteq> b"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   223
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   224
class pordered_ab_group_add = ab_group_add + pordered_ab_semigroup_add
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   225
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   226
instance pordered_ab_group_add \<subseteq> pordered_ab_semigroup_add_imp_le
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   227
proof
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   228
  fix a b c :: 'a
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   229
  assume "c + a \<le> c + b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   230
  hence "(-c) + (c + a) \<le> (-c) + (c + b)" by (rule add_left_mono)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   231
  hence "((-c) + c) + a \<le> ((-c) + c) + b" by (simp only: add_assoc)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   232
  thus "a \<le> b" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   233
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   234
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   235
class ordered_cancel_ab_semigroup_add = pordered_cancel_ab_semigroup_add + linorder
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   236
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   237
instance ordered_cancel_ab_semigroup_add \<subseteq> pordered_ab_semigroup_add_imp_le
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   238
proof
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   239
  fix a b c :: 'a
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   240
  assume le: "c + a <= c + b"  
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   241
  show "a <= b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   242
  proof (rule ccontr)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   243
    assume w: "~ a \<le> b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   244
    hence "b <= a" by (simp add: linorder_not_le)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   245
    hence le2: "c+b <= c+a" by (rule add_left_mono)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   246
    have "a = b" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   247
      apply (insert le)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   248
      apply (insert le2)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   249
      apply (drule order_antisym, simp_all)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   250
      done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   251
    with w  show False 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   252
      by (simp add: linorder_not_le [symmetric])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   253
  qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   254
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   255
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   256
lemma add_right_mono: "a \<le> (b::'a::pordered_ab_semigroup_add) ==> a + c \<le> b + c"
22390
378f34b1e380 now using "class"
haftmann
parents: 21382
diff changeset
   257
  by (simp add: add_commute [of _ c] add_left_mono)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   258
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   259
text {* non-strict, in both arguments *}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   260
lemma add_mono:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   261
     "[|a \<le> b;  c \<le> d|] ==> a + c \<le> b + (d::'a::pordered_ab_semigroup_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   262
  apply (erule add_right_mono [THEN order_trans])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   263
  apply (simp add: add_commute add_left_mono)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   264
  done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   265
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   266
lemma add_strict_left_mono:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   267
     "a < b ==> c + a < c + (b::'a::pordered_cancel_ab_semigroup_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   268
 by (simp add: order_less_le add_left_mono) 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   269
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   270
lemma add_strict_right_mono:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   271
     "a < b ==> a + c < b + (c::'a::pordered_cancel_ab_semigroup_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   272
 by (simp add: add_commute [of _ c] add_strict_left_mono)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   273
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   274
text{*Strict monotonicity in both arguments*}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   275
lemma add_strict_mono: "[|a<b; c<d|] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   276
apply (erule add_strict_right_mono [THEN order_less_trans])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   277
apply (erule add_strict_left_mono)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   278
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   279
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   280
lemma add_less_le_mono:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   281
     "[| a<b; c\<le>d |] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   282
apply (erule add_strict_right_mono [THEN order_less_le_trans])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   283
apply (erule add_left_mono) 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   284
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   285
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   286
lemma add_le_less_mono:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   287
     "[| a\<le>b; c<d |] ==> a + c < b + (d::'a::pordered_cancel_ab_semigroup_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   288
apply (erule add_right_mono [THEN order_le_less_trans])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   289
apply (erule add_strict_left_mono) 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   290
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   291
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   292
lemma add_less_imp_less_left:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   293
      assumes less: "c + a < c + b"  shows "a < (b::'a::pordered_ab_semigroup_add_imp_le)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   294
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   295
  from less have le: "c + a <= c + b" by (simp add: order_le_less)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   296
  have "a <= b" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   297
    apply (insert le)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   298
    apply (drule add_le_imp_le_left)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   299
    by (insert le, drule add_le_imp_le_left, assumption)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   300
  moreover have "a \<noteq> b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   301
  proof (rule ccontr)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   302
    assume "~(a \<noteq> b)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   303
    then have "a = b" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   304
    then have "c + a = c + b" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   305
    with less show "False"by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   306
  qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   307
  ultimately show "a < b" by (simp add: order_le_less)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   308
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   309
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   310
lemma add_less_imp_less_right:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   311
      "a + c < b + c ==> a < (b::'a::pordered_ab_semigroup_add_imp_le)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   312
apply (rule add_less_imp_less_left [of c])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   313
apply (simp add: add_commute)  
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   314
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   315
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   316
lemma add_less_cancel_left [simp]:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   317
    "(c+a < c+b) = (a < (b::'a::pordered_ab_semigroup_add_imp_le))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   318
by (blast intro: add_less_imp_less_left add_strict_left_mono) 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   319
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   320
lemma add_less_cancel_right [simp]:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   321
    "(a+c < b+c) = (a < (b::'a::pordered_ab_semigroup_add_imp_le))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   322
by (blast intro: add_less_imp_less_right add_strict_right_mono)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   323
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   324
lemma add_le_cancel_left [simp]:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   325
    "(c+a \<le> c+b) = (a \<le> (b::'a::pordered_ab_semigroup_add_imp_le))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   326
by (auto, drule add_le_imp_le_left, simp_all add: add_left_mono) 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   327
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   328
lemma add_le_cancel_right [simp]:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   329
    "(a+c \<le> b+c) = (a \<le> (b::'a::pordered_ab_semigroup_add_imp_le))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   330
by (simp add: add_commute[of a c] add_commute[of b c])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   331
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   332
lemma add_le_imp_le_right:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   333
      "a + c \<le> b + c ==> a \<le> (b::'a::pordered_ab_semigroup_add_imp_le)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   334
by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   335
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   336
lemma add_increasing:
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   337
  fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}"
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   338
  shows  "[|0\<le>a; b\<le>c|] ==> b \<le> a + c"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   339
by (insert add_mono [of 0 a b c], simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   340
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   341
lemma add_increasing2:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   342
  fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}"
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   343
  shows  "[|0\<le>c; b\<le>a|] ==> b \<le> a + c"
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   344
by (simp add:add_increasing add_commute[of a])
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   345
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   346
lemma add_strict_increasing:
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   347
  fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}"
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   348
  shows "[|0<a; b\<le>c|] ==> b < a + c"
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   349
by (insert add_less_le_mono [of 0 a b c], simp)
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   350
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   351
lemma add_strict_increasing2:
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   352
  fixes c :: "'a::{pordered_ab_semigroup_add_imp_le, comm_monoid_add}"
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   353
  shows "[|0\<le>a; b<c|] ==> b < a + c"
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   354
by (insert add_le_less_mono [of 0 a b c], simp)
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   355
19527
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   356
lemma max_add_distrib_left:
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   357
  fixes z :: "'a::pordered_ab_semigroup_add_imp_le"
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   358
  shows  "(max x y) + z = max (x+z) (y+z)"
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   359
by (rule max_of_mono [THEN sym], rule add_le_cancel_right)
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   360
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   361
lemma min_add_distrib_left:
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   362
  fixes z :: "'a::pordered_ab_semigroup_add_imp_le"
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   363
  shows  "(min x y) + z = min (x+z) (y+z)"
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   364
by (rule min_of_mono [THEN sym], rule add_le_cancel_right)
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   365
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   366
lemma max_diff_distrib_left:
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   367
  fixes z :: "'a::pordered_ab_group_add"
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   368
  shows  "(max x y) - z = max (x-z) (y-z)"
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   369
by (simp add: diff_minus, rule max_add_distrib_left) 
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   370
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   371
lemma min_diff_distrib_left:
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   372
  fixes z :: "'a::pordered_ab_group_add"
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   373
  shows  "(min x y) - z = min (x-z) (y-z)"
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   374
by (simp add: diff_minus, rule min_add_distrib_left) 
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19404
diff changeset
   375
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   376
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   377
subsection {* Ordering Rules for Unary Minus *}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   378
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   379
lemma le_imp_neg_le:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   380
      assumes "a \<le> (b::'a::{pordered_ab_semigroup_add_imp_le, ab_group_add})" shows "-b \<le> -a"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   381
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   382
  have "-a+a \<le> -a+b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   383
    by (rule add_left_mono) 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   384
  hence "0 \<le> -a+b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   385
    by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   386
  hence "0 + (-b) \<le> (-a + b) + (-b)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   387
    by (rule add_right_mono) 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   388
  thus ?thesis
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   389
    by (simp add: add_assoc)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   390
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   391
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   392
lemma neg_le_iff_le [simp]: "(-b \<le> -a) = (a \<le> (b::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   393
proof 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   394
  assume "- b \<le> - a"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   395
  hence "- (- a) \<le> - (- b)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   396
    by (rule le_imp_neg_le)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   397
  thus "a\<le>b" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   398
next
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   399
  assume "a\<le>b"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   400
  thus "-b \<le> -a" by (rule le_imp_neg_le)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   401
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   402
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   403
lemma neg_le_0_iff_le [simp]: "(-a \<le> 0) = (0 \<le> (a::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   404
by (subst neg_le_iff_le [symmetric], simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   405
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   406
lemma neg_0_le_iff_le [simp]: "(0 \<le> -a) = (a \<le> (0::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   407
by (subst neg_le_iff_le [symmetric], simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   408
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   409
lemma neg_less_iff_less [simp]: "(-b < -a) = (a < (b::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   410
by (force simp add: order_less_le) 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   411
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   412
lemma neg_less_0_iff_less [simp]: "(-a < 0) = (0 < (a::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   413
by (subst neg_less_iff_less [symmetric], simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   414
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   415
lemma neg_0_less_iff_less [simp]: "(0 < -a) = (a < (0::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   416
by (subst neg_less_iff_less [symmetric], simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   417
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   418
text{*The next several equations can make the simplifier loop!*}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   419
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   420
lemma less_minus_iff: "(a < - b) = (b < - (a::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   421
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   422
  have "(- (-a) < - b) = (b < - a)" by (rule neg_less_iff_less)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   423
  thus ?thesis by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   424
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   425
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   426
lemma minus_less_iff: "(- a < b) = (- b < (a::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   427
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   428
  have "(- a < - (-b)) = (- b < a)" by (rule neg_less_iff_less)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   429
  thus ?thesis by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   430
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   431
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   432
lemma le_minus_iff: "(a \<le> - b) = (b \<le> - (a::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   433
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   434
  have mm: "!! a (b::'a). (-(-a)) < -b \<Longrightarrow> -(-b) < -a" by (simp only: minus_less_iff)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   435
  have "(- (- a) <= -b) = (b <= - a)" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   436
    apply (auto simp only: order_le_less)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   437
    apply (drule mm)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   438
    apply (simp_all)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   439
    apply (drule mm[simplified], assumption)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   440
    done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   441
  then show ?thesis by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   442
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   443
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   444
lemma minus_le_iff: "(- a \<le> b) = (- b \<le> (a::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   445
by (auto simp add: order_le_less minus_less_iff)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   446
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   447
lemma add_diff_eq: "a + (b - c) = (a + b) - (c::'a::ab_group_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   448
by (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   449
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   450
lemma diff_add_eq: "(a - b) + c = (a + c) - (b::'a::ab_group_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   451
by (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   452
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   453
lemma diff_eq_eq: "(a-b = c) = (a = c + (b::'a::ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   454
by (auto simp add: diff_minus add_assoc)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   455
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   456
lemma eq_diff_eq: "(a = c-b) = (a + (b::'a::ab_group_add) = c)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   457
by (auto simp add: diff_minus add_assoc)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   458
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   459
lemma diff_diff_eq: "(a - b) - c = a - (b + (c::'a::ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   460
by (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   461
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   462
lemma diff_diff_eq2: "a - (b - c) = (a + c) - (b::'a::ab_group_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   463
by (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   464
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   465
lemma diff_add_cancel: "a - b + b = (a::'a::ab_group_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   466
by (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   467
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   468
lemma add_diff_cancel: "a + b - b = (a::'a::ab_group_add)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   469
by (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   470
14754
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
   471
text{*Further subtraction laws*}
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   472
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   473
lemma less_iff_diff_less_0: "(a < b) = (a - b < (0::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   474
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   475
  have  "(a < b) = (a + (- b) < b + (-b))"  
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   476
    by (simp only: add_less_cancel_right)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   477
  also have "... =  (a - b < 0)" by (simp add: diff_minus)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   478
  finally show ?thesis .
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   479
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   480
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   481
lemma diff_less_eq: "(a-b < c) = (a < c + (b::'a::pordered_ab_group_add))"
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15234
diff changeset
   482
apply (subst less_iff_diff_less_0 [of a])
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   483
apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   484
apply (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   485
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   486
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   487
lemma less_diff_eq: "(a < c-b) = (a + (b::'a::pordered_ab_group_add) < c)"
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15234
diff changeset
   488
apply (subst less_iff_diff_less_0 [of "a+b"])
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15234
diff changeset
   489
apply (subst less_iff_diff_less_0 [of a])
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   490
apply (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   491
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   492
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   493
lemma diff_le_eq: "(a-b \<le> c) = (a \<le> c + (b::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   494
by (auto simp add: order_le_less diff_less_eq diff_add_cancel add_diff_cancel)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   495
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   496
lemma le_diff_eq: "(a \<le> c-b) = (a + (b::'a::pordered_ab_group_add) \<le> c)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   497
by (auto simp add: order_le_less less_diff_eq diff_add_cancel add_diff_cancel)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   498
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   499
text{*This list of rewrites simplifies (in)equalities by bringing subtractions
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   500
  to the top and then moving negative terms to the other side.
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   501
  Use with @{text add_ac}*}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   502
lemmas compare_rls =
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   503
       diff_minus [symmetric]
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   504
       add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   505
       diff_less_eq less_diff_eq diff_le_eq le_diff_eq
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   506
       diff_eq_eq eq_diff_eq
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   507
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   508
subsection {* Support for reasoning about signs *}
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   509
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   510
lemma add_pos_pos: "0 < 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   511
    (x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   512
      ==> 0 < y ==> 0 < x + y"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   513
apply (subgoal_tac "0 + 0 < x + y")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   514
apply simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   515
apply (erule add_less_le_mono)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   516
apply (erule order_less_imp_le)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   517
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   518
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   519
lemma add_pos_nonneg: "0 < 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   520
    (x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   521
      ==> 0 <= y ==> 0 < x + y"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   522
apply (subgoal_tac "0 + 0 < x + y")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   523
apply simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   524
apply (erule add_less_le_mono, assumption)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   525
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   526
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   527
lemma add_nonneg_pos: "0 <= 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   528
    (x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   529
      ==> 0 < y ==> 0 < x + y"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   530
apply (subgoal_tac "0 + 0 < x + y")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   531
apply simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   532
apply (erule add_le_less_mono, assumption)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   533
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   534
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   535
lemma add_nonneg_nonneg: "0 <= 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   536
    (x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   537
      ==> 0 <= y ==> 0 <= x + y"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   538
apply (subgoal_tac "0 + 0 <= x + y")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   539
apply simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   540
apply (erule add_mono, assumption)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   541
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   542
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   543
lemma add_neg_neg: "(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add})
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   544
    < 0 ==> y < 0 ==> x + y < 0"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   545
apply (subgoal_tac "x + y < 0 + 0")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   546
apply simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   547
apply (erule add_less_le_mono)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   548
apply (erule order_less_imp_le)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   549
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   550
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   551
lemma add_neg_nonpos: 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   552
    "(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) < 0 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   553
      ==> y <= 0 ==> x + y < 0"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   554
apply (subgoal_tac "x + y < 0 + 0")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   555
apply simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   556
apply (erule add_less_le_mono, assumption)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   557
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   558
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   559
lemma add_nonpos_neg: 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   560
    "(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) <= 0 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   561
      ==> y < 0 ==> x + y < 0"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   562
apply (subgoal_tac "x + y < 0 + 0")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   563
apply simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   564
apply (erule add_le_less_mono, assumption)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   565
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   566
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   567
lemma add_nonpos_nonpos: 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   568
    "(x::'a::{comm_monoid_add,pordered_cancel_ab_semigroup_add}) <= 0 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   569
      ==> y <= 0 ==> x + y <= 0"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   570
apply (subgoal_tac "x + y <= 0 + 0")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   571
apply simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   572
apply (erule add_mono, assumption)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   573
done
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   574
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   575
subsection{*Lemmas for the @{text cancel_numerals} simproc*}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   576
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   577
lemma eq_iff_diff_eq_0: "(a = b) = (a-b = (0::'a::ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   578
by (simp add: compare_rls)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   579
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   580
lemma le_iff_diff_le_0: "(a \<le> b) = (a-b \<le> (0::'a::pordered_ab_group_add))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   581
by (simp add: compare_rls)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   582
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   583
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   584
subsection {* Lattice Ordered (Abelian) Groups *}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   585
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   586
class lordered_ab_group_meet = pordered_ab_group_add + lower_semilattice
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   587
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   588
class lordered_ab_group_join = pordered_ab_group_add + upper_semilattice
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   589
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   590
class lordered_ab_group = pordered_ab_group_add + lattice
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   591
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   592
instance lordered_ab_group \<subseteq> lordered_ab_group_meet by default
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   593
instance lordered_ab_group \<subseteq> lordered_ab_group_join by default
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   594
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   595
lemma add_inf_distrib_left: "a + inf b c = inf (a + b) (a + (c::'a::{pordered_ab_group_add, lower_semilattice}))"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   596
apply (rule order_antisym)
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   597
apply (simp_all add: le_infI)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   598
apply (rule add_le_imp_le_left [of "-a"])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   599
apply (simp only: add_assoc[symmetric], simp)
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   600
apply rule
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   601
apply (rule add_le_imp_le_left[of "a"], simp only: add_assoc[symmetric], simp)+
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   602
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   603
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   604
lemma add_sup_distrib_left: "a + sup b c = sup (a + b) (a+ (c::'a::{pordered_ab_group_add, upper_semilattice}))" 
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   605
apply (rule order_antisym)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   606
apply (rule add_le_imp_le_left [of "-a"])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   607
apply (simp only: add_assoc[symmetric], simp)
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   608
apply rule
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   609
apply (rule add_le_imp_le_left [of "a"], simp only: add_assoc[symmetric], simp)+
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   610
apply (rule le_supI)
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   611
apply (simp_all)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   612
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   613
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   614
lemma add_inf_distrib_right: "inf a b + (c::'a::lordered_ab_group) = inf (a+c) (b+c)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   615
proof -
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   616
  have "c + inf a b = inf (c+a) (c+b)" by (simp add: add_inf_distrib_left)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   617
  thus ?thesis by (simp add: add_commute)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   618
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   619
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   620
lemma add_sup_distrib_right: "sup a b + (c::'a::lordered_ab_group) = sup (a+c) (b+c)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   621
proof -
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   622
  have "c + sup a b = sup (c+a) (c+b)" by (simp add: add_sup_distrib_left)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   623
  thus ?thesis by (simp add: add_commute)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   624
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   625
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   626
lemmas add_sup_inf_distribs = add_inf_distrib_right add_inf_distrib_left add_sup_distrib_right add_sup_distrib_left
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   627
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   628
lemma inf_eq_neg_sup: "inf a (b\<Colon>'a\<Colon>lordered_ab_group) = - sup (-a) (-b)"
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   629
proof (rule inf_unique)
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   630
  fix a b :: 'a
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   631
  show "- sup (-a) (-b) \<le> a" by (rule add_le_imp_le_right [of _ "sup (-a) (-b)"])
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   632
    (simp, simp add: add_sup_distrib_left)
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   633
next
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   634
  fix a b :: 'a
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   635
  show "- sup (-a) (-b) \<le> b" by (rule add_le_imp_le_right [of _ "sup (-a) (-b)"])
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   636
    (simp, simp add: add_sup_distrib_left)
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   637
next
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   638
  fix a b c :: 'a
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   639
  assume "a \<le> b" "a \<le> c"
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   640
  then show "a \<le> - sup (-b) (-c)" by (subst neg_le_iff_le [symmetric])
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   641
    (simp add: le_supI)
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   642
qed
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   643
  
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   644
lemma sup_eq_neg_inf: "sup a (b\<Colon>'a\<Colon>lordered_ab_group) = - inf (-a) (-b)"
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   645
proof (rule sup_unique)
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   646
  fix a b :: 'a
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   647
  show "a \<le> - inf (-a) (-b)" by (rule add_le_imp_le_right [of _ "inf (-a) (-b)"])
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   648
    (simp, simp add: add_inf_distrib_left)
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   649
next
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   650
  fix a b :: 'a
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   651
  show "b \<le> - inf (-a) (-b)" by (rule add_le_imp_le_right [of _ "inf (-a) (-b)"])
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   652
    (simp, simp add: add_inf_distrib_left)
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   653
next
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   654
  fix a b c :: 'a
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   655
  assume "a \<le> c" "b \<le> c"
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   656
  then show "- inf (-a) (-b) \<le> c" by (subst neg_le_iff_le [symmetric])
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   657
    (simp add: le_infI)
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   658
qed
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   659
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   660
lemma add_eq_inf_sup: "a + b = sup a b + inf a (b\<Colon>'a\<Colon>lordered_ab_group)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   661
proof -
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   662
  have "0 = - inf 0 (a-b) + inf (a-b) 0" by (simp add: inf_commute)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   663
  hence "0 = sup 0 (b-a) + inf (a-b) 0" by (simp add: inf_eq_neg_sup)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   664
  hence "0 = (-a + sup a b) + (inf a b + (-b))"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   665
    apply (simp add: add_sup_distrib_left add_inf_distrib_right)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   666
    by (simp add: diff_minus add_commute)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   667
  thus ?thesis
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   668
    apply (simp add: compare_rls)
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   669
    apply (subst add_left_cancel[symmetric, of "a+b" "sup a b + inf a b" "-a"])
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   670
    apply (simp only: add_assoc, simp add: add_assoc[symmetric])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   671
    done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   672
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   673
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   674
subsection {* Positive Part, Negative Part, Absolute Value *}
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   675
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   676
definition
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   677
  nprt :: "'a \<Rightarrow> ('a::lordered_ab_group)" where
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   678
  "nprt x = inf x 0"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   679
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   680
definition
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   681
  pprt :: "'a \<Rightarrow> ('a::lordered_ab_group)" where
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   682
  "pprt x = sup x 0"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   683
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   684
lemma prts: "a = pprt a + nprt a"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   685
by (simp add: pprt_def nprt_def add_eq_inf_sup[symmetric])
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   686
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   687
lemma zero_le_pprt[simp]: "0 \<le> pprt a"
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   688
by (simp add: pprt_def)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   689
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   690
lemma nprt_le_zero[simp]: "nprt a \<le> 0"
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   691
by (simp add: nprt_def)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   692
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   693
lemma le_eq_neg: "(a \<le> -b) = (a + b \<le> (0::_::lordered_ab_group))" (is "?l = ?r")
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   694
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   695
  have a: "?l \<longrightarrow> ?r"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   696
    apply (auto)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   697
    apply (rule add_le_imp_le_right[of _ "-b" _])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   698
    apply (simp add: add_assoc)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   699
    done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   700
  have b: "?r \<longrightarrow> ?l"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   701
    apply (auto)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   702
    apply (rule add_le_imp_le_right[of _ "b" _])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   703
    apply (simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   704
    done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   705
  from a b show ?thesis by blast
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   706
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   707
15580
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   708
lemma pprt_0[simp]: "pprt 0 = 0" by (simp add: pprt_def)
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   709
lemma nprt_0[simp]: "nprt 0 = 0" by (simp add: nprt_def)
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   710
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   711
lemma pprt_eq_id[simp]: "0 <= x \<Longrightarrow> pprt x = x"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   712
  by (simp add: pprt_def le_iff_sup sup_aci)
15580
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   713
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   714
lemma nprt_eq_id[simp]: "x <= 0 \<Longrightarrow> nprt x = x"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   715
  by (simp add: nprt_def le_iff_inf inf_aci)
15580
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   716
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   717
lemma pprt_eq_0[simp]: "x <= 0 \<Longrightarrow> pprt x = 0"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   718
  by (simp add: pprt_def le_iff_sup sup_aci)
15580
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   719
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   720
lemma nprt_eq_0[simp]: "0 <= x \<Longrightarrow> nprt x = 0"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   721
  by (simp add: nprt_def le_iff_inf inf_aci)
15580
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   722
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   723
lemma sup_0_imp_0: "sup a (-a) = 0 \<Longrightarrow> a = (0::'a::lordered_ab_group)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   724
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   725
  {
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   726
    fix a::'a
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   727
    assume hyp: "sup a (-a) = 0"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   728
    hence "sup a (-a) + a = a" by (simp)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   729
    hence "sup (a+a) 0 = a" by (simp add: add_sup_distrib_right) 
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   730
    hence "sup (a+a) 0 <= a" by (simp)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   731
    hence "0 <= a" by (blast intro: order_trans inf_sup_ord)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   732
  }
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   733
  note p = this
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   734
  assume hyp:"sup a (-a) = 0"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   735
  hence hyp2:"sup (-a) (-(-a)) = 0" by (simp add: sup_commute)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   736
  from p[OF hyp] p[OF hyp2] show "a = 0" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   737
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   738
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   739
lemma inf_0_imp_0: "inf a (-a) = 0 \<Longrightarrow> a = (0::'a::lordered_ab_group)"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   740
apply (simp add: inf_eq_neg_sup)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   741
apply (simp add: sup_commute)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   742
apply (erule sup_0_imp_0)
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15234
diff changeset
   743
done
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   744
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   745
lemma inf_0_eq_0[simp]: "(inf a (-a) = 0) = (a = (0::'a::lordered_ab_group))"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   746
by (auto, erule inf_0_imp_0)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   747
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   748
lemma sup_0_eq_0[simp]: "(sup a (-a) = 0) = (a = (0::'a::lordered_ab_group))"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   749
by (auto, erule sup_0_imp_0)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   750
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   751
lemma zero_le_double_add_iff_zero_le_single_add[simp]: "(0 \<le> a + a) = (0 \<le> (a::'a::lordered_ab_group))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   752
proof
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   753
  assume "0 <= a + a"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   754
  hence a:"inf (a+a) 0 = 0" by (simp add: le_iff_inf inf_commute)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   755
  have "(inf a 0)+(inf a 0) = inf (inf (a+a) 0) a" (is "?l=_") by (simp add: add_sup_inf_distribs inf_aci)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   756
  hence "?l = 0 + inf a 0" by (simp add: a, simp add: inf_commute)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   757
  hence "inf a 0 = 0" by (simp only: add_right_cancel)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   758
  then show "0 <= a" by (simp add: le_iff_inf inf_commute)    
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   759
next  
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   760
  assume a: "0 <= a"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   761
  show "0 <= a + a" by (simp add: add_mono[OF a a, simplified])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   762
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   763
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   764
lemma double_add_le_zero_iff_single_add_le_zero[simp]: "(a + a <= 0) = ((a::'a::lordered_ab_group) <= 0)" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   765
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   766
  have "(a + a <= 0) = (0 <= -(a+a))" by (subst le_minus_iff, simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   767
  moreover have "\<dots> = (a <= 0)" by (simp add: zero_le_double_add_iff_zero_le_single_add)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   768
  ultimately show ?thesis by blast
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   769
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   770
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   771
lemma double_add_less_zero_iff_single_less_zero[simp]: "(a+a<0) = ((a::'a::{pordered_ab_group_add,linorder}) < 0)" (is ?s)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   772
proof cases
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   773
  assume a: "a < 0"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   774
  thus ?s by (simp add:  add_strict_mono[OF a a, simplified])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   775
next
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   776
  assume "~(a < 0)" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   777
  hence a:"0 <= a" by (simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   778
  hence "0 <= a+a" by (simp add: add_mono[OF a a, simplified])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   779
  hence "~(a+a < 0)" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   780
  with a show ?thesis by simp 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   781
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   782
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   783
class lordered_ab_group_abs = lordered_ab_group +
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   784
  assumes abs_lattice: "abs x = sup x (uminus x)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   785
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   786
lemma abs_zero[simp]: "abs 0 = (0::'a::lordered_ab_group_abs)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   787
by (simp add: abs_lattice)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   788
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   789
lemma abs_eq_0[simp]: "(abs a = 0) = (a = (0::'a::lordered_ab_group_abs))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   790
by (simp add: abs_lattice)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   791
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   792
lemma abs_0_eq[simp]: "(0 = abs a) = (a = (0::'a::lordered_ab_group_abs))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   793
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   794
  have "(0 = abs a) = (abs a = 0)" by (simp only: eq_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   795
  thus ?thesis by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   796
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   797
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   798
lemma neg_inf_eq_sup[simp]: "- inf a (b::_::lordered_ab_group) = sup (-a) (-b)"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   799
by (simp add: inf_eq_neg_sup)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   800
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   801
lemma neg_sup_eq_inf[simp]: "- sup a (b::_::lordered_ab_group) = inf (-a) (-b)"
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   802
by (simp del: neg_inf_eq_sup add: sup_eq_neg_inf)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   803
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   804
lemma sup_eq_if: "sup a (-a) = (if a < 0 then -a else (a::'a::{lordered_ab_group, linorder}))"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   805
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   806
  note b = add_le_cancel_right[of a a "-a",symmetric,simplified]
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   807
  have c: "a + a = 0 \<Longrightarrow> -a = a" by (rule add_right_imp_eq[of _ a], simp)
22452
8a86fd2a1bf0 adjusted to new lattice theory developement in Lattices.thy / FixedPoint.thy
haftmann
parents: 22422
diff changeset
   808
  show ?thesis by (auto simp add: max_def b linorder_not_less sup_max)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   809
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   810
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   811
lemma abs_if_lattice: "\<bar>a\<bar> = (if a < 0 then -a else (a::'a::{lordered_ab_group_abs, linorder}))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   812
proof -
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   813
  show ?thesis by (simp add: abs_lattice sup_eq_if)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   814
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   815
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   816
lemma abs_ge_zero[simp]: "0 \<le> abs (a::'a::lordered_ab_group_abs)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   817
proof -
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   818
  have a:"a <= abs a" and b:"-a <= abs a" by (auto simp add: abs_lattice)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   819
  show ?thesis by (rule add_mono[OF a b, simplified])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   820
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   821
  
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   822
lemma abs_le_zero_iff [simp]: "(abs a \<le> (0::'a::lordered_ab_group_abs)) = (a = 0)" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   823
proof
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   824
  assume "abs a <= 0"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   825
  hence "abs a = 0" by (auto dest: order_antisym)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   826
  thus "a = 0" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   827
next
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   828
  assume "a = 0"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   829
  thus "abs a <= 0" by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   830
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   831
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   832
lemma zero_less_abs_iff [simp]: "(0 < abs a) = (a \<noteq> (0::'a::lordered_ab_group_abs))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   833
by (simp add: order_less_le)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   834
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   835
lemma abs_not_less_zero [simp]: "~ abs a < (0::'a::lordered_ab_group_abs)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   836
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   837
  have a:"!! x (y::_::order). x <= y \<Longrightarrow> ~(y < x)" by auto
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   838
  show ?thesis by (simp add: a)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   839
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   840
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   841
lemma abs_ge_self: "a \<le> abs (a::'a::lordered_ab_group_abs)"
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   842
by (simp add: abs_lattice)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   843
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   844
lemma abs_ge_minus_self: "-a \<le> abs (a::'a::lordered_ab_group_abs)"
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   845
by (simp add: abs_lattice)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   846
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   847
lemma abs_prts: "abs (a::_::lordered_ab_group_abs) = pprt a - nprt a"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   848
apply (simp add: pprt_def nprt_def diff_minus)
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   849
apply (simp add: add_sup_inf_distribs sup_aci abs_lattice[symmetric])
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   850
apply (subst sup_absorb2, auto)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   851
done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   852
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   853
lemma abs_minus_cancel [simp]: "abs (-a) = abs(a::'a::lordered_ab_group_abs)"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   854
by (simp add: abs_lattice sup_commute)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   855
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   856
lemma abs_idempotent [simp]: "abs (abs a) = abs (a::'a::lordered_ab_group_abs)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   857
apply (simp add: abs_lattice[of "abs a"])
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   858
apply (subst sup_absorb1)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   859
apply (rule order_trans[of _ 0])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   860
by auto
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   861
15093
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   862
lemma abs_minus_commute: 
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   863
  fixes a :: "'a::lordered_ab_group_abs"
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   864
  shows "abs (a-b) = abs(b-a)"
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   865
proof -
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   866
  have "abs (a-b) = abs (- (a-b))" by (simp only: abs_minus_cancel)
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   867
  also have "... = abs(b-a)" by simp
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   868
  finally show ?thesis .
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   869
qed
49ede01e9ee6 conversion of Integration and NSPrimes to Isar scripts
paulson
parents: 15010
diff changeset
   870
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   871
lemma zero_le_iff_zero_nprt: "(0 \<le> a) = (nprt a = 0)"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   872
by (simp add: le_iff_inf nprt_def inf_commute)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   873
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   874
lemma le_zero_iff_zero_pprt: "(a \<le> 0) = (pprt a = 0)"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   875
by (simp add: le_iff_sup pprt_def sup_commute)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   876
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   877
lemma le_zero_iff_pprt_id: "(0 \<le> a) = (pprt a = a)"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   878
by (simp add: le_iff_sup pprt_def sup_commute)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   879
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   880
lemma zero_le_iff_nprt_id: "(a \<le> 0) = (nprt a = a)"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   881
by (simp add: le_iff_inf nprt_def inf_commute)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   882
15580
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   883
lemma pprt_mono[simp]: "(a::_::lordered_ab_group) <= b \<Longrightarrow> pprt a <= pprt b"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   884
  by (simp add: le_iff_sup pprt_def sup_aci)
15580
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   885
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   886
lemma nprt_mono[simp]: "(a::_::lordered_ab_group) <= b \<Longrightarrow> nprt a <= nprt b"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   887
  by (simp add: le_iff_inf nprt_def inf_aci)
15580
900291ee0af8 Cleaning up HOL/Matrix
obua
parents: 15539
diff changeset
   888
19404
9bf2cdc9e8e8 Moved stuff from Ring_and_Field to Matrix
obua
parents: 19233
diff changeset
   889
lemma pprt_neg: "pprt (-x) = - nprt x"
9bf2cdc9e8e8 Moved stuff from Ring_and_Field to Matrix
obua
parents: 19233
diff changeset
   890
  by (simp add: pprt_def nprt_def)
9bf2cdc9e8e8 Moved stuff from Ring_and_Field to Matrix
obua
parents: 19233
diff changeset
   891
9bf2cdc9e8e8 Moved stuff from Ring_and_Field to Matrix
obua
parents: 19233
diff changeset
   892
lemma nprt_neg: "nprt (-x) = - pprt x"
9bf2cdc9e8e8 Moved stuff from Ring_and_Field to Matrix
obua
parents: 19233
diff changeset
   893
  by (simp add: pprt_def nprt_def)
9bf2cdc9e8e8 Moved stuff from Ring_and_Field to Matrix
obua
parents: 19233
diff changeset
   894
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   895
lemma iff2imp: "(A=B) \<Longrightarrow> (A \<Longrightarrow> B)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   896
by (simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   897
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   898
lemma abs_of_nonneg [simp]: "0 \<le> a \<Longrightarrow> abs a = (a::'a::lordered_ab_group_abs)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   899
by (simp add: iff2imp[OF zero_le_iff_zero_nprt] iff2imp[OF le_zero_iff_pprt_id] abs_prts)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   900
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   901
lemma abs_of_pos: "0 < (x::'a::lordered_ab_group_abs) ==> abs x = x";
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   902
by (rule abs_of_nonneg, rule order_less_imp_le);
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   903
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   904
lemma abs_of_nonpos [simp]: "a \<le> 0 \<Longrightarrow> abs a = -(a::'a::lordered_ab_group_abs)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   905
by (simp add: iff2imp[OF le_zero_iff_zero_pprt] iff2imp[OF zero_le_iff_nprt_id] abs_prts)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   906
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   907
lemma abs_of_neg: "(x::'a::lordered_ab_group_abs) <  0 ==> 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   908
  abs x = - x"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   909
by (rule abs_of_nonpos, rule order_less_imp_le)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   910
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   911
lemma abs_leI: "[|a \<le> b; -a \<le> b|] ==> abs a \<le> (b::'a::lordered_ab_group_abs)"
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   912
by (simp add: abs_lattice le_supI)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   913
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   914
lemma le_minus_self_iff: "(a \<le> -a) = (a \<le> (0::'a::lordered_ab_group))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   915
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   916
  from add_le_cancel_left[of "-a" "a+a" "0"] have "(a <= -a) = (a+a <= 0)" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   917
    by (simp add: add_assoc[symmetric])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   918
  thus ?thesis by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   919
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   920
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   921
lemma minus_le_self_iff: "(-a \<le> a) = (0 \<le> (a::'a::lordered_ab_group))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   922
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   923
  from add_le_cancel_left[of "-a" "0" "a+a"] have "(-a <= a) = (0 <= a+a)" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   924
    by (simp add: add_assoc[symmetric])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   925
  thus ?thesis by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   926
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   927
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   928
lemma abs_le_D1: "abs a \<le> b ==> a \<le> (b::'a::lordered_ab_group_abs)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   929
by (insert abs_ge_self, blast intro: order_trans)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   930
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   931
lemma abs_le_D2: "abs a \<le> b ==> -a \<le> (b::'a::lordered_ab_group_abs)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   932
by (insert abs_le_D1 [of "-a"], simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   933
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   934
lemma abs_le_iff: "(abs a \<le> b) = (a \<le> b & -a \<le> (b::'a::lordered_ab_group_abs))"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   935
by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   936
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   937
lemma abs_triangle_ineq: "abs(a+b) \<le> abs a + abs(b::'a::lordered_ab_group_abs)"
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   938
proof -
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   939
  have g:"abs a + abs b = sup (a+b) (sup (-a-b) (sup (-a+b) (a + (-b))))" (is "_=sup ?m ?n")
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   940
    by (simp add: abs_lattice add_sup_inf_distribs sup_aci diff_minus)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   941
  have a:"a+b <= sup ?m ?n" by (simp)
21312
1d39091a3208 started reorgnization of lattice theories
nipkow
parents: 21245
diff changeset
   942
  have b:"-a-b <= ?n" by (simp) 
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   943
  have c:"?n <= sup ?m ?n" by (simp)
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   944
  from b c have d: "-a-b <= sup ?m ?n" by(rule order_trans)
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   945
  have e:"-a-b = -(a+b)" by (simp add: diff_minus)
22422
ee19cdb07528 stepping towards uniform lattice theory development in HOL
haftmann
parents: 22390
diff changeset
   946
  from a d e have "abs(a+b) <= sup ?m ?n" 
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   947
    by (drule_tac abs_leI, auto)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   948
  with g[symmetric] show ?thesis by simp
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   949
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   950
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   951
lemma abs_triangle_ineq2: "abs (a::'a::lordered_ab_group_abs) - 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   952
    abs b <= abs (a - b)"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   953
  apply (simp add: compare_rls)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   954
  apply (subgoal_tac "abs a = abs (a - b + b)")
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   955
  apply (erule ssubst)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   956
  apply (rule abs_triangle_ineq)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   957
  apply (rule arg_cong);back;
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   958
  apply (simp add: compare_rls)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   959
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   960
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   961
lemma abs_triangle_ineq3: 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   962
    "abs(abs (a::'a::lordered_ab_group_abs) - abs b) <= abs (a - b)"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   963
  apply (subst abs_le_iff)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   964
  apply auto
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   965
  apply (rule abs_triangle_ineq2)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   966
  apply (subst abs_minus_commute)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   967
  apply (rule abs_triangle_ineq2)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   968
done
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   969
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   970
lemma abs_triangle_ineq4: "abs ((a::'a::lordered_ab_group_abs) - b) <= 
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   971
    abs a + abs b"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   972
proof -;
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   973
  have "abs(a - b) = abs(a + - b)"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   974
    by (subst diff_minus, rule refl)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   975
  also have "... <= abs a + abs (- b)"
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   976
    by (rule abs_triangle_ineq)
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   977
  finally show ?thesis
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   978
    by simp
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   979
qed
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16417
diff changeset
   980
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   981
lemma abs_diff_triangle_ineq:
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   982
     "\<bar>(a::'a::lordered_ab_group_abs) + b - (c+d)\<bar> \<le> \<bar>a-c\<bar> + \<bar>b-d\<bar>"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   983
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   984
  have "\<bar>a + b - (c+d)\<bar> = \<bar>(a-c) + (b-d)\<bar>" by (simp add: diff_minus add_ac)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   985
  also have "... \<le> \<bar>a-c\<bar> + \<bar>b-d\<bar>" by (rule abs_triangle_ineq)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   986
  finally show ?thesis .
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   987
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
   988
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   989
lemma abs_add_abs[simp]:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   990
fixes a:: "'a::{lordered_ab_group_abs}"
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   991
shows "abs(abs a + abs b) = abs a + abs b" (is "?L = ?R")
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   992
proof (rule order_antisym)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   993
  show "?L \<ge> ?R" by(rule abs_ge_self)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   994
next
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   995
  have "?L \<le> \<bar>\<bar>a\<bar>\<bar> + \<bar>\<bar>b\<bar>\<bar>" by(rule abs_triangle_ineq)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   996
  also have "\<dots> = ?R" by simp
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   997
  finally show "?L \<le> ?R" .
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   998
qed
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15481
diff changeset
   999
14754
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1000
text {* Needed for abelian cancellation simprocs: *}
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1001
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1002
lemma add_cancel_21: "((x::'a::ab_group_add) + (y + z) = y + u) = (x + z = u)"
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1003
apply (subst add_left_commute)
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1004
apply (subst add_left_cancel)
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1005
apply simp
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1006
done
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1007
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1008
lemma add_cancel_end: "(x + (y + z) = y) = (x = - (z::'a::ab_group_add))"
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1009
apply (subst add_cancel_21[of _ _ _ 0, simplified])
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1010
apply (simp add: add_right_cancel[symmetric, of "x" "-z" "z", simplified])
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1011
done
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1012
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1013
lemma less_eqI: "(x::'a::pordered_ab_group_add) - y = x' - y' \<Longrightarrow> (x < y) = (x' < y')"
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1014
by (simp add: less_iff_diff_less_0[of x y] less_iff_diff_less_0[of x' y'])
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1015
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1016
lemma le_eqI: "(x::'a::pordered_ab_group_add) - y = x' - y' \<Longrightarrow> (y <= x) = (y' <= x')"
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1017
apply (simp add: le_iff_diff_le_0[of y x] le_iff_diff_le_0[of  y' x'])
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1018
apply (simp add: neg_le_iff_le[symmetric, of "y-x" 0] neg_le_iff_le[symmetric, of "y'-x'" 0])
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1019
done
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1020
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1021
lemma eq_eqI: "(x::'a::ab_group_add) - y = x' - y' \<Longrightarrow> (x = y) = (x' = y')"
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1022
by (simp add: eq_iff_diff_eq_0[of x y] eq_iff_diff_eq_0[of x' y'])
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1023
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1024
lemma diff_def: "(x::'a::ab_group_add) - y == x + (-y)"
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1025
by (simp add: diff_minus)
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1026
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1027
lemma add_minus_cancel: "(a::'a::ab_group_add) + (-a + b) = b"
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1028
by (simp add: add_assoc[symmetric])
a080eeeaec14 Modification / Installation of Provers/Arith/abel_cancel.ML for OrderedGroup.thy
obua
parents: 14738
diff changeset
  1029
15178
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1030
lemma  le_add_right_mono: 
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1031
  assumes 
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1032
  "a <= b + (c::'a::pordered_ab_group_add)"
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1033
  "c <= d"    
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1034
  shows "a <= b + d"
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1035
  apply (rule_tac order_trans[where y = "b+c"])
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1036
  apply (simp_all add: prems)
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1037
  done
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1038
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1039
lemmas group_eq_simps =
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1040
  mult_ac
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1041
  add_ac
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1042
  add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1043
  diff_eq_eq eq_diff_eq
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1044
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1045
lemma estimate_by_abs:
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1046
"a + b <= (c::'a::lordered_ab_group_abs) \<Longrightarrow> a <= c + abs b" 
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1047
proof -
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1048
  assume 1: "a+b <= c"
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1049
  have 2: "a <= c+(-b)"
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1050
    apply (insert 1)
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1051
    apply (drule_tac add_right_mono[where c="-b"])
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1052
    apply (simp add: group_eq_simps)
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1053
    done
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1054
  have 3: "(-b) <= abs b" by (rule abs_ge_minus_self)
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1055
  show ?thesis by (rule le_add_right_mono[OF 2 3])
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1056
qed
5f621aa35c25 Matrix theory, linear programming
obua
parents: 15140
diff changeset
  1057
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1058
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1059
subsection {* Tools setup *}
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1060
17085
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1061
text{*Simplification of @{term "x-y < 0"}, etc.*}
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1062
lemmas diff_less_0_iff_less = less_iff_diff_less_0 [symmetric]
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1063
lemmas diff_eq_0_iff_eq = eq_iff_diff_eq_0 [symmetric]
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1064
lemmas diff_le_0_iff_le = le_iff_diff_le_0 [symmetric]
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1065
declare diff_less_0_iff_less [simp]
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1066
declare diff_eq_0_iff_eq [simp]
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1067
declare diff_le_0_iff_le [simp]
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1068
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1069
ML {*
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1070
structure ab_group_add_cancel = Abel_Cancel(
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1071
struct
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1072
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1073
(* term order for abelian groups *)
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1074
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1075
fun agrp_ord (Const (a, _)) = find_index (fn a' => a = a')
22997
d4f3b015b50b canonical prefixing of class constants
haftmann
parents: 22986
diff changeset
  1076
      [@{const_name HOL.zero}, @{const_name HOL.plus},
d4f3b015b50b canonical prefixing of class constants
haftmann
parents: 22986
diff changeset
  1077
        @{const_name HOL.uminus}, @{const_name HOL.minus}]
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1078
  | agrp_ord _ = ~1;
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1079
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1080
fun termless_agrp (a, b) = (Term.term_lpo agrp_ord (a, b) = LESS);
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1081
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1082
local
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1083
  val ac1 = mk_meta_eq @{thm add_assoc};
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1084
  val ac2 = mk_meta_eq @{thm add_commute};
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1085
  val ac3 = mk_meta_eq @{thm add_left_commute};
22997
d4f3b015b50b canonical prefixing of class constants
haftmann
parents: 22986
diff changeset
  1086
  fun solve_add_ac thy _ (_ $ (Const (@{const_name HOL.plus},_) $ _ $ _) $ _) =
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1087
        SOME ac1
22997
d4f3b015b50b canonical prefixing of class constants
haftmann
parents: 22986
diff changeset
  1088
    | solve_add_ac thy _ (_ $ x $ (Const (@{const_name HOL.plus},_) $ y $ z)) =
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1089
        if termless_agrp (y, x) then SOME ac3 else NONE
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1090
    | solve_add_ac thy _ (_ $ x $ y) =
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1091
        if termless_agrp (y, x) then SOME ac2 else NONE
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1092
    | solve_add_ac thy _ _ = NONE
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1093
in
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1094
  val add_ac_proc = Simplifier.simproc @{theory}
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1095
    "add_ac_proc" ["x + y::'a::ab_semigroup_add"] solve_add_ac;
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1096
end;
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1097
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1098
val cancel_ss = HOL_basic_ss settermless termless_agrp
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1099
  addsimprocs [add_ac_proc] addsimps
23085
fd30d75a6614 Introduced new classes monoid_add and group_add
nipkow
parents: 22997
diff changeset
  1100
  [@{thm add_0_left}, @{thm add_0_right}, @{thm diff_def},
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1101
   @{thm minus_add_distrib}, @{thm minus_minus}, @{thm minus_zero},
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1102
   @{thm right_minus}, @{thm left_minus}, @{thm add_minus_cancel},
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1103
   @{thm minus_add_cancel}];
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1104
  
22548
6ce4bddf3bcb dropped legacy ML bindings
haftmann
parents: 22482
diff changeset
  1105
val eq_reflection = @{thm eq_reflection};
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1106
  
22548
6ce4bddf3bcb dropped legacy ML bindings
haftmann
parents: 22482
diff changeset
  1107
val thy_ref = Theory.self_ref @{theory};
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1108
22548
6ce4bddf3bcb dropped legacy ML bindings
haftmann
parents: 22482
diff changeset
  1109
val T = TFree("'a", ["OrderedGroup.ab_group_add"]);
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1110
22548
6ce4bddf3bcb dropped legacy ML bindings
haftmann
parents: 22482
diff changeset
  1111
val eqI_rules = [@{thm less_eqI}, @{thm le_eqI}, @{thm eq_eqI}];
22482
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1112
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1113
val dest_eqI = 
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1114
  fst o HOLogic.dest_bin "op =" HOLogic.boolT o HOLogic.dest_Trueprop o concl_of;
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1115
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1116
end);
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1117
*}
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1118
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1119
ML_setup {*
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1120
  Addsimprocs [ab_group_add_cancel.sum_conv, ab_group_add_cancel.rel_conv];
8fc3d7237e03 dropped OrderedGroup.ML
haftmann
parents: 22452
diff changeset
  1121
*}
17085
5b57f995a179 more simprules now have names
paulson
parents: 16775
diff changeset
  1122
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents:
diff changeset
  1123
end