src/HOL/Groups.thy
author wenzelm
Thu Feb 11 23:00:22 2010 +0100 (2010-02-11)
changeset 35115 446c5063e4fd
parent 35092 cfe605c54e50
child 35216 7641e8d831d2
permissions -rw-r--r--
modernized translations;
formal markup of @{syntax_const} and @{const_syntax};
minor tuning;
haftmann@35050
     1
(*  Title:   HOL/Groups.thy
wenzelm@29269
     2
    Author:  Gertrud Bauer, Steven Obua, Lawrence C Paulson, Markus Wenzel, Jeremy Avigad
obua@14738
     3
*)
obua@14738
     4
haftmann@35050
     5
header {* Groups, also combined with orderings *}
obua@14738
     6
haftmann@35050
     7
theory Groups
haftmann@35092
     8
imports Orderings
wenzelm@19798
     9
uses "~~/src/Provers/Arith/abel_cancel.ML"
nipkow@15131
    10
begin
obua@14738
    11
obua@14738
    12
text {*
obua@14738
    13
  The theory of partially ordered groups is taken from the books:
obua@14738
    14
  \begin{itemize}
obua@14738
    15
  \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979 
obua@14738
    16
  \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
obua@14738
    17
  \end{itemize}
obua@14738
    18
  Most of the used notions can also be looked up in 
obua@14738
    19
  \begin{itemize}
wenzelm@14770
    20
  \item \url{http://www.mathworld.com} by Eric Weisstein et. al.
obua@14738
    21
  \item \emph{Algebra I} by van der Waerden, Springer.
obua@14738
    22
  \end{itemize}
obua@14738
    23
*}
obua@14738
    24
wenzelm@31902
    25
ML {*
haftmann@34973
    26
structure Algebra_Simps = Named_Thms(
wenzelm@31902
    27
  val name = "algebra_simps"
wenzelm@31902
    28
  val description = "algebra simplification rules"
wenzelm@31902
    29
)
nipkow@29667
    30
*}
nipkow@29667
    31
wenzelm@31902
    32
setup Algebra_Simps.setup
nipkow@29667
    33
nipkow@29667
    34
text{* The rewrites accumulated in @{text algebra_simps} deal with the
nipkow@29667
    35
classical algebraic structures of groups, rings and family. They simplify
nipkow@29667
    36
terms by multiplying everything out (in case of a ring) and bringing sums and
nipkow@29667
    37
products into a canonical form (by ordered rewriting). As a result it decides
nipkow@29667
    38
group and ring equalities but also helps with inequalities.
nipkow@29667
    39
nipkow@29667
    40
Of course it also works for fields, but it knows nothing about multiplicative
nipkow@29667
    41
inverses or division. This is catered for by @{text field_simps}. *}
nipkow@29667
    42
haftmann@35092
    43
nipkow@23085
    44
subsection {* Semigroups and Monoids *}
obua@14738
    45
haftmann@22390
    46
class semigroup_add = plus +
haftmann@34973
    47
  assumes add_assoc [algebra_simps]: "(a + b) + c = a + (b + c)"
haftmann@34973
    48
haftmann@34973
    49
sublocale semigroup_add < plus!: semigroup plus proof
haftmann@34973
    50
qed (fact add_assoc)
haftmann@22390
    51
haftmann@22390
    52
class ab_semigroup_add = semigroup_add +
haftmann@34973
    53
  assumes add_commute [algebra_simps]: "a + b = b + a"
haftmann@34973
    54
haftmann@34973
    55
sublocale ab_semigroup_add < plus!: abel_semigroup plus proof
haftmann@34973
    56
qed (fact add_commute)
haftmann@34973
    57
haftmann@34973
    58
context ab_semigroup_add
haftmann@25062
    59
begin
obua@14738
    60
haftmann@34973
    61
lemmas add_left_commute [algebra_simps] = plus.left_commute
haftmann@25062
    62
haftmann@25062
    63
theorems add_ac = add_assoc add_commute add_left_commute
haftmann@25062
    64
haftmann@25062
    65
end
obua@14738
    66
obua@14738
    67
theorems add_ac = add_assoc add_commute add_left_commute
obua@14738
    68
haftmann@22390
    69
class semigroup_mult = times +
haftmann@34973
    70
  assumes mult_assoc [algebra_simps]: "(a * b) * c = a * (b * c)"
haftmann@34973
    71
haftmann@34973
    72
sublocale semigroup_mult < times!: semigroup times proof
haftmann@34973
    73
qed (fact mult_assoc)
obua@14738
    74
haftmann@22390
    75
class ab_semigroup_mult = semigroup_mult +
haftmann@34973
    76
  assumes mult_commute [algebra_simps]: "a * b = b * a"
haftmann@34973
    77
haftmann@34973
    78
sublocale ab_semigroup_mult < times!: abel_semigroup times proof
haftmann@34973
    79
qed (fact mult_commute)
haftmann@34973
    80
haftmann@34973
    81
context ab_semigroup_mult
haftmann@23181
    82
begin
obua@14738
    83
haftmann@34973
    84
lemmas mult_left_commute [algebra_simps] = times.left_commute
haftmann@25062
    85
haftmann@25062
    86
theorems mult_ac = mult_assoc mult_commute mult_left_commute
haftmann@23181
    87
haftmann@23181
    88
end
obua@14738
    89
obua@14738
    90
theorems mult_ac = mult_assoc mult_commute mult_left_commute
obua@14738
    91
haftmann@26015
    92
class ab_semigroup_idem_mult = ab_semigroup_mult +
haftmann@34973
    93
  assumes mult_idem: "x * x = x"
haftmann@34973
    94
haftmann@34973
    95
sublocale ab_semigroup_idem_mult < times!: semilattice times proof
haftmann@34973
    96
qed (fact mult_idem)
haftmann@34973
    97
haftmann@34973
    98
context ab_semigroup_idem_mult
haftmann@26015
    99
begin
haftmann@26015
   100
haftmann@34973
   101
lemmas mult_left_idem = times.left_idem
haftmann@26015
   102
haftmann@26015
   103
end
haftmann@26015
   104
nipkow@23085
   105
class monoid_add = zero + semigroup_add +
haftmann@25062
   106
  assumes add_0_left [simp]: "0 + a = a"
haftmann@25062
   107
    and add_0_right [simp]: "a + 0 = a"
nipkow@23085
   108
haftmann@26071
   109
lemma zero_reorient: "0 = x \<longleftrightarrow> x = 0"
nipkow@29667
   110
by (rule eq_commute)
haftmann@26071
   111
haftmann@22390
   112
class comm_monoid_add = zero + ab_semigroup_add +
haftmann@25062
   113
  assumes add_0: "0 + a = a"
haftmann@25062
   114
begin
nipkow@23085
   115
haftmann@25062
   116
subclass monoid_add
haftmann@28823
   117
  proof qed (insert add_0, simp_all add: add_commute)
haftmann@25062
   118
haftmann@25062
   119
end
obua@14738
   120
haftmann@22390
   121
class monoid_mult = one + semigroup_mult +
haftmann@25062
   122
  assumes mult_1_left [simp]: "1 * a  = a"
haftmann@25062
   123
  assumes mult_1_right [simp]: "a * 1 = a"
obua@14738
   124
haftmann@26071
   125
lemma one_reorient: "1 = x \<longleftrightarrow> x = 1"
nipkow@29667
   126
by (rule eq_commute)
haftmann@26071
   127
haftmann@22390
   128
class comm_monoid_mult = one + ab_semigroup_mult +
haftmann@25062
   129
  assumes mult_1: "1 * a = a"
haftmann@25062
   130
begin
obua@14738
   131
haftmann@25062
   132
subclass monoid_mult
haftmann@28823
   133
  proof qed (insert mult_1, simp_all add: mult_commute)
haftmann@25062
   134
haftmann@25062
   135
end
obua@14738
   136
haftmann@22390
   137
class cancel_semigroup_add = semigroup_add +
haftmann@25062
   138
  assumes add_left_imp_eq: "a + b = a + c \<Longrightarrow> b = c"
haftmann@25062
   139
  assumes add_right_imp_eq: "b + a = c + a \<Longrightarrow> b = c"
huffman@27474
   140
begin
huffman@27474
   141
huffman@27474
   142
lemma add_left_cancel [simp]:
huffman@27474
   143
  "a + b = a + c \<longleftrightarrow> b = c"
nipkow@29667
   144
by (blast dest: add_left_imp_eq)
huffman@27474
   145
huffman@27474
   146
lemma add_right_cancel [simp]:
huffman@27474
   147
  "b + a = c + a \<longleftrightarrow> b = c"
nipkow@29667
   148
by (blast dest: add_right_imp_eq)
huffman@27474
   149
huffman@27474
   150
end
obua@14738
   151
haftmann@22390
   152
class cancel_ab_semigroup_add = ab_semigroup_add +
haftmann@25062
   153
  assumes add_imp_eq: "a + b = a + c \<Longrightarrow> b = c"
haftmann@25267
   154
begin
obua@14738
   155
haftmann@25267
   156
subclass cancel_semigroup_add
haftmann@28823
   157
proof
haftmann@22390
   158
  fix a b c :: 'a
haftmann@22390
   159
  assume "a + b = a + c" 
haftmann@22390
   160
  then show "b = c" by (rule add_imp_eq)
haftmann@22390
   161
next
obua@14738
   162
  fix a b c :: 'a
obua@14738
   163
  assume "b + a = c + a"
haftmann@22390
   164
  then have "a + b = a + c" by (simp only: add_commute)
haftmann@22390
   165
  then show "b = c" by (rule add_imp_eq)
obua@14738
   166
qed
obua@14738
   167
haftmann@25267
   168
end
haftmann@25267
   169
huffman@29904
   170
class cancel_comm_monoid_add = cancel_ab_semigroup_add + comm_monoid_add
huffman@29904
   171
huffman@29904
   172
nipkow@23085
   173
subsection {* Groups *}
nipkow@23085
   174
haftmann@25762
   175
class group_add = minus + uminus + monoid_add +
haftmann@25062
   176
  assumes left_minus [simp]: "- a + a = 0"
haftmann@25062
   177
  assumes diff_minus: "a - b = a + (- b)"
haftmann@25062
   178
begin
nipkow@23085
   179
huffman@34147
   180
lemma minus_unique:
huffman@34147
   181
  assumes "a + b = 0" shows "- a = b"
huffman@34147
   182
proof -
huffman@34147
   183
  have "- a = - a + (a + b)" using assms by simp
huffman@34147
   184
  also have "\<dots> = b" by (simp add: add_assoc [symmetric])
huffman@34147
   185
  finally show ?thesis .
huffman@34147
   186
qed
huffman@34147
   187
huffman@34147
   188
lemmas equals_zero_I = minus_unique (* legacy name *)
obua@14738
   189
haftmann@25062
   190
lemma minus_zero [simp]: "- 0 = 0"
obua@14738
   191
proof -
huffman@34147
   192
  have "0 + 0 = 0" by (rule add_0_right)
huffman@34147
   193
  thus "- 0 = 0" by (rule minus_unique)
obua@14738
   194
qed
obua@14738
   195
haftmann@25062
   196
lemma minus_minus [simp]: "- (- a) = a"
nipkow@23085
   197
proof -
huffman@34147
   198
  have "- a + a = 0" by (rule left_minus)
huffman@34147
   199
  thus "- (- a) = a" by (rule minus_unique)
nipkow@23085
   200
qed
obua@14738
   201
haftmann@25062
   202
lemma right_minus [simp]: "a + - a = 0"
obua@14738
   203
proof -
haftmann@25062
   204
  have "a + - a = - (- a) + - a" by simp
haftmann@25062
   205
  also have "\<dots> = 0" by (rule left_minus)
obua@14738
   206
  finally show ?thesis .
obua@14738
   207
qed
obua@14738
   208
huffman@34147
   209
lemma minus_add_cancel: "- a + (a + b) = b"
huffman@34147
   210
by (simp add: add_assoc [symmetric])
huffman@34147
   211
huffman@34147
   212
lemma add_minus_cancel: "a + (- a + b) = b"
huffman@34147
   213
by (simp add: add_assoc [symmetric])
huffman@34147
   214
huffman@34147
   215
lemma minus_add: "- (a + b) = - b + - a"
huffman@34147
   216
proof -
huffman@34147
   217
  have "(a + b) + (- b + - a) = 0"
huffman@34147
   218
    by (simp add: add_assoc add_minus_cancel)
huffman@34147
   219
  thus "- (a + b) = - b + - a"
huffman@34147
   220
    by (rule minus_unique)
huffman@34147
   221
qed
huffman@34147
   222
haftmann@25062
   223
lemma right_minus_eq: "a - b = 0 \<longleftrightarrow> a = b"
obua@14738
   224
proof
nipkow@23085
   225
  assume "a - b = 0"
nipkow@23085
   226
  have "a = (a - b) + b" by (simp add:diff_minus add_assoc)
nipkow@23085
   227
  also have "\<dots> = b" using `a - b = 0` by simp
nipkow@23085
   228
  finally show "a = b" .
obua@14738
   229
next
nipkow@23085
   230
  assume "a = b" thus "a - b = 0" by (simp add: diff_minus)
obua@14738
   231
qed
obua@14738
   232
haftmann@25062
   233
lemma diff_self [simp]: "a - a = 0"
nipkow@29667
   234
by (simp add: diff_minus)
obua@14738
   235
haftmann@25062
   236
lemma diff_0 [simp]: "0 - a = - a"
nipkow@29667
   237
by (simp add: diff_minus)
obua@14738
   238
haftmann@25062
   239
lemma diff_0_right [simp]: "a - 0 = a" 
nipkow@29667
   240
by (simp add: diff_minus)
obua@14738
   241
haftmann@25062
   242
lemma diff_minus_eq_add [simp]: "a - - b = a + b"
nipkow@29667
   243
by (simp add: diff_minus)
obua@14738
   244
haftmann@25062
   245
lemma neg_equal_iff_equal [simp]:
haftmann@25062
   246
  "- a = - b \<longleftrightarrow> a = b" 
obua@14738
   247
proof 
obua@14738
   248
  assume "- a = - b"
nipkow@29667
   249
  hence "- (- a) = - (- b)" by simp
haftmann@25062
   250
  thus "a = b" by simp
obua@14738
   251
next
haftmann@25062
   252
  assume "a = b"
haftmann@25062
   253
  thus "- a = - b" by simp
obua@14738
   254
qed
obua@14738
   255
haftmann@25062
   256
lemma neg_equal_0_iff_equal [simp]:
haftmann@25062
   257
  "- a = 0 \<longleftrightarrow> a = 0"
nipkow@29667
   258
by (subst neg_equal_iff_equal [symmetric], simp)
obua@14738
   259
haftmann@25062
   260
lemma neg_0_equal_iff_equal [simp]:
haftmann@25062
   261
  "0 = - a \<longleftrightarrow> 0 = a"
nipkow@29667
   262
by (subst neg_equal_iff_equal [symmetric], simp)
obua@14738
   263
obua@14738
   264
text{*The next two equations can make the simplifier loop!*}
obua@14738
   265
haftmann@25062
   266
lemma equation_minus_iff:
haftmann@25062
   267
  "a = - b \<longleftrightarrow> b = - a"
obua@14738
   268
proof -
haftmann@25062
   269
  have "- (- a) = - b \<longleftrightarrow> - a = b" by (rule neg_equal_iff_equal)
haftmann@25062
   270
  thus ?thesis by (simp add: eq_commute)
haftmann@25062
   271
qed
haftmann@25062
   272
haftmann@25062
   273
lemma minus_equation_iff:
haftmann@25062
   274
  "- a = b \<longleftrightarrow> - b = a"
haftmann@25062
   275
proof -
haftmann@25062
   276
  have "- a = - (- b) \<longleftrightarrow> a = -b" by (rule neg_equal_iff_equal)
obua@14738
   277
  thus ?thesis by (simp add: eq_commute)
obua@14738
   278
qed
obua@14738
   279
huffman@28130
   280
lemma diff_add_cancel: "a - b + b = a"
nipkow@29667
   281
by (simp add: diff_minus add_assoc)
huffman@28130
   282
huffman@28130
   283
lemma add_diff_cancel: "a + b - b = a"
nipkow@29667
   284
by (simp add: diff_minus add_assoc)
nipkow@29667
   285
nipkow@29667
   286
declare diff_minus[symmetric, algebra_simps]
huffman@28130
   287
huffman@29914
   288
lemma eq_neg_iff_add_eq_0: "a = - b \<longleftrightarrow> a + b = 0"
huffman@29914
   289
proof
huffman@29914
   290
  assume "a = - b" then show "a + b = 0" by simp
huffman@29914
   291
next
huffman@29914
   292
  assume "a + b = 0"
huffman@29914
   293
  moreover have "a + (b + - b) = (a + b) + - b"
huffman@29914
   294
    by (simp only: add_assoc)
huffman@29914
   295
  ultimately show "a = - b" by simp
huffman@29914
   296
qed
huffman@29914
   297
haftmann@25062
   298
end
haftmann@25062
   299
haftmann@25762
   300
class ab_group_add = minus + uminus + comm_monoid_add +
haftmann@25062
   301
  assumes ab_left_minus: "- a + a = 0"
haftmann@25062
   302
  assumes ab_diff_minus: "a - b = a + (- b)"
haftmann@25267
   303
begin
haftmann@25062
   304
haftmann@25267
   305
subclass group_add
haftmann@28823
   306
  proof qed (simp_all add: ab_left_minus ab_diff_minus)
haftmann@25062
   307
huffman@29904
   308
subclass cancel_comm_monoid_add
haftmann@28823
   309
proof
haftmann@25062
   310
  fix a b c :: 'a
haftmann@25062
   311
  assume "a + b = a + c"
haftmann@25062
   312
  then have "- a + a + b = - a + a + c"
haftmann@25062
   313
    unfolding add_assoc by simp
haftmann@25062
   314
  then show "b = c" by simp
haftmann@25062
   315
qed
haftmann@25062
   316
nipkow@29667
   317
lemma uminus_add_conv_diff[algebra_simps]:
haftmann@25062
   318
  "- a + b = b - a"
nipkow@29667
   319
by (simp add:diff_minus add_commute)
haftmann@25062
   320
haftmann@25062
   321
lemma minus_add_distrib [simp]:
haftmann@25062
   322
  "- (a + b) = - a + - b"
huffman@34146
   323
by (rule minus_unique) (simp add: add_ac)
haftmann@25062
   324
haftmann@25062
   325
lemma minus_diff_eq [simp]:
haftmann@25062
   326
  "- (a - b) = b - a"
nipkow@29667
   327
by (simp add: diff_minus add_commute)
haftmann@25077
   328
nipkow@29667
   329
lemma add_diff_eq[algebra_simps]: "a + (b - c) = (a + b) - c"
nipkow@29667
   330
by (simp add: diff_minus add_ac)
haftmann@25077
   331
nipkow@29667
   332
lemma diff_add_eq[algebra_simps]: "(a - b) + c = (a + c) - b"
nipkow@29667
   333
by (simp add: diff_minus add_ac)
haftmann@25077
   334
nipkow@29667
   335
lemma diff_eq_eq[algebra_simps]: "a - b = c \<longleftrightarrow> a = c + b"
nipkow@29667
   336
by (auto simp add: diff_minus add_assoc)
haftmann@25077
   337
nipkow@29667
   338
lemma eq_diff_eq[algebra_simps]: "a = c - b \<longleftrightarrow> a + b = c"
nipkow@29667
   339
by (auto simp add: diff_minus add_assoc)
haftmann@25077
   340
nipkow@29667
   341
lemma diff_diff_eq[algebra_simps]: "(a - b) - c = a - (b + c)"
nipkow@29667
   342
by (simp add: diff_minus add_ac)
haftmann@25077
   343
nipkow@29667
   344
lemma diff_diff_eq2[algebra_simps]: "a - (b - c) = (a + c) - b"
nipkow@29667
   345
by (simp add: diff_minus add_ac)
haftmann@25077
   346
haftmann@25077
   347
lemma eq_iff_diff_eq_0: "a = b \<longleftrightarrow> a - b = 0"
nipkow@29667
   348
by (simp add: algebra_simps)
haftmann@25077
   349
huffman@30629
   350
lemma diff_eq_0_iff_eq [simp, noatp]: "a - b = 0 \<longleftrightarrow> a = b"
huffman@30629
   351
by (simp add: algebra_simps)
huffman@30629
   352
haftmann@25062
   353
end
obua@14738
   354
obua@14738
   355
subsection {* (Partially) Ordered Groups *} 
obua@14738
   356
haftmann@35028
   357
class ordered_ab_semigroup_add = order + ab_semigroup_add +
haftmann@25062
   358
  assumes add_left_mono: "a \<le> b \<Longrightarrow> c + a \<le> c + b"
haftmann@25062
   359
begin
haftmann@24380
   360
haftmann@25062
   361
lemma add_right_mono:
haftmann@25062
   362
  "a \<le> b \<Longrightarrow> a + c \<le> b + c"
nipkow@29667
   363
by (simp add: add_commute [of _ c] add_left_mono)
obua@14738
   364
obua@14738
   365
text {* non-strict, in both arguments *}
obua@14738
   366
lemma add_mono:
haftmann@25062
   367
  "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c \<le> b + d"
obua@14738
   368
  apply (erule add_right_mono [THEN order_trans])
obua@14738
   369
  apply (simp add: add_commute add_left_mono)
obua@14738
   370
  done
obua@14738
   371
haftmann@25062
   372
end
haftmann@25062
   373
haftmann@35028
   374
class ordered_cancel_ab_semigroup_add =
haftmann@35028
   375
  ordered_ab_semigroup_add + cancel_ab_semigroup_add
haftmann@25062
   376
begin
haftmann@25062
   377
obua@14738
   378
lemma add_strict_left_mono:
haftmann@25062
   379
  "a < b \<Longrightarrow> c + a < c + b"
nipkow@29667
   380
by (auto simp add: less_le add_left_mono)
obua@14738
   381
obua@14738
   382
lemma add_strict_right_mono:
haftmann@25062
   383
  "a < b \<Longrightarrow> a + c < b + c"
nipkow@29667
   384
by (simp add: add_commute [of _ c] add_strict_left_mono)
obua@14738
   385
obua@14738
   386
text{*Strict monotonicity in both arguments*}
haftmann@25062
   387
lemma add_strict_mono:
haftmann@25062
   388
  "a < b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d"
haftmann@25062
   389
apply (erule add_strict_right_mono [THEN less_trans])
obua@14738
   390
apply (erule add_strict_left_mono)
obua@14738
   391
done
obua@14738
   392
obua@14738
   393
lemma add_less_le_mono:
haftmann@25062
   394
  "a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c < b + d"
haftmann@25062
   395
apply (erule add_strict_right_mono [THEN less_le_trans])
haftmann@25062
   396
apply (erule add_left_mono)
obua@14738
   397
done
obua@14738
   398
obua@14738
   399
lemma add_le_less_mono:
haftmann@25062
   400
  "a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d"
haftmann@25062
   401
apply (erule add_right_mono [THEN le_less_trans])
obua@14738
   402
apply (erule add_strict_left_mono) 
obua@14738
   403
done
obua@14738
   404
haftmann@25062
   405
end
haftmann@25062
   406
haftmann@35028
   407
class ordered_ab_semigroup_add_imp_le =
haftmann@35028
   408
  ordered_cancel_ab_semigroup_add +
haftmann@25062
   409
  assumes add_le_imp_le_left: "c + a \<le> c + b \<Longrightarrow> a \<le> b"
haftmann@25062
   410
begin
haftmann@25062
   411
obua@14738
   412
lemma add_less_imp_less_left:
nipkow@29667
   413
  assumes less: "c + a < c + b" shows "a < b"
obua@14738
   414
proof -
obua@14738
   415
  from less have le: "c + a <= c + b" by (simp add: order_le_less)
obua@14738
   416
  have "a <= b" 
obua@14738
   417
    apply (insert le)
obua@14738
   418
    apply (drule add_le_imp_le_left)
obua@14738
   419
    by (insert le, drule add_le_imp_le_left, assumption)
obua@14738
   420
  moreover have "a \<noteq> b"
obua@14738
   421
  proof (rule ccontr)
obua@14738
   422
    assume "~(a \<noteq> b)"
obua@14738
   423
    then have "a = b" by simp
obua@14738
   424
    then have "c + a = c + b" by simp
obua@14738
   425
    with less show "False"by simp
obua@14738
   426
  qed
obua@14738
   427
  ultimately show "a < b" by (simp add: order_le_less)
obua@14738
   428
qed
obua@14738
   429
obua@14738
   430
lemma add_less_imp_less_right:
haftmann@25062
   431
  "a + c < b + c \<Longrightarrow> a < b"
obua@14738
   432
apply (rule add_less_imp_less_left [of c])
obua@14738
   433
apply (simp add: add_commute)  
obua@14738
   434
done
obua@14738
   435
obua@14738
   436
lemma add_less_cancel_left [simp]:
haftmann@25062
   437
  "c + a < c + b \<longleftrightarrow> a < b"
nipkow@29667
   438
by (blast intro: add_less_imp_less_left add_strict_left_mono) 
obua@14738
   439
obua@14738
   440
lemma add_less_cancel_right [simp]:
haftmann@25062
   441
  "a + c < b + c \<longleftrightarrow> a < b"
nipkow@29667
   442
by (blast intro: add_less_imp_less_right add_strict_right_mono)
obua@14738
   443
obua@14738
   444
lemma add_le_cancel_left [simp]:
haftmann@25062
   445
  "c + a \<le> c + b \<longleftrightarrow> a \<le> b"
nipkow@29667
   446
by (auto, drule add_le_imp_le_left, simp_all add: add_left_mono) 
obua@14738
   447
obua@14738
   448
lemma add_le_cancel_right [simp]:
haftmann@25062
   449
  "a + c \<le> b + c \<longleftrightarrow> a \<le> b"
nipkow@29667
   450
by (simp add: add_commute [of a c] add_commute [of b c])
obua@14738
   451
obua@14738
   452
lemma add_le_imp_le_right:
haftmann@25062
   453
  "a + c \<le> b + c \<Longrightarrow> a \<le> b"
nipkow@29667
   454
by simp
haftmann@25062
   455
haftmann@25077
   456
lemma max_add_distrib_left:
haftmann@25077
   457
  "max x y + z = max (x + z) (y + z)"
haftmann@25077
   458
  unfolding max_def by auto
haftmann@25077
   459
haftmann@25077
   460
lemma min_add_distrib_left:
haftmann@25077
   461
  "min x y + z = min (x + z) (y + z)"
haftmann@25077
   462
  unfolding min_def by auto
haftmann@25077
   463
haftmann@25062
   464
end
haftmann@25062
   465
haftmann@25303
   466
subsection {* Support for reasoning about signs *}
haftmann@25303
   467
haftmann@35028
   468
class ordered_comm_monoid_add =
haftmann@35028
   469
  ordered_cancel_ab_semigroup_add + comm_monoid_add
haftmann@25303
   470
begin
haftmann@25303
   471
haftmann@25303
   472
lemma add_pos_nonneg:
nipkow@29667
   473
  assumes "0 < a" and "0 \<le> b" shows "0 < a + b"
haftmann@25303
   474
proof -
haftmann@25303
   475
  have "0 + 0 < a + b" 
haftmann@25303
   476
    using assms by (rule add_less_le_mono)
haftmann@25303
   477
  then show ?thesis by simp
haftmann@25303
   478
qed
haftmann@25303
   479
haftmann@25303
   480
lemma add_pos_pos:
nipkow@29667
   481
  assumes "0 < a" and "0 < b" shows "0 < a + b"
nipkow@29667
   482
by (rule add_pos_nonneg) (insert assms, auto)
haftmann@25303
   483
haftmann@25303
   484
lemma add_nonneg_pos:
nipkow@29667
   485
  assumes "0 \<le> a" and "0 < b" shows "0 < a + b"
haftmann@25303
   486
proof -
haftmann@25303
   487
  have "0 + 0 < a + b" 
haftmann@25303
   488
    using assms by (rule add_le_less_mono)
haftmann@25303
   489
  then show ?thesis by simp
haftmann@25303
   490
qed
haftmann@25303
   491
haftmann@25303
   492
lemma add_nonneg_nonneg:
nipkow@29667
   493
  assumes "0 \<le> a" and "0 \<le> b" shows "0 \<le> a + b"
haftmann@25303
   494
proof -
haftmann@25303
   495
  have "0 + 0 \<le> a + b" 
haftmann@25303
   496
    using assms by (rule add_mono)
haftmann@25303
   497
  then show ?thesis by simp
haftmann@25303
   498
qed
haftmann@25303
   499
huffman@30691
   500
lemma add_neg_nonpos:
nipkow@29667
   501
  assumes "a < 0" and "b \<le> 0" shows "a + b < 0"
haftmann@25303
   502
proof -
haftmann@25303
   503
  have "a + b < 0 + 0"
haftmann@25303
   504
    using assms by (rule add_less_le_mono)
haftmann@25303
   505
  then show ?thesis by simp
haftmann@25303
   506
qed
haftmann@25303
   507
haftmann@25303
   508
lemma add_neg_neg: 
nipkow@29667
   509
  assumes "a < 0" and "b < 0" shows "a + b < 0"
nipkow@29667
   510
by (rule add_neg_nonpos) (insert assms, auto)
haftmann@25303
   511
haftmann@25303
   512
lemma add_nonpos_neg:
nipkow@29667
   513
  assumes "a \<le> 0" and "b < 0" shows "a + b < 0"
haftmann@25303
   514
proof -
haftmann@25303
   515
  have "a + b < 0 + 0"
haftmann@25303
   516
    using assms by (rule add_le_less_mono)
haftmann@25303
   517
  then show ?thesis by simp
haftmann@25303
   518
qed
haftmann@25303
   519
haftmann@25303
   520
lemma add_nonpos_nonpos:
nipkow@29667
   521
  assumes "a \<le> 0" and "b \<le> 0" shows "a + b \<le> 0"
haftmann@25303
   522
proof -
haftmann@25303
   523
  have "a + b \<le> 0 + 0"
haftmann@25303
   524
    using assms by (rule add_mono)
haftmann@25303
   525
  then show ?thesis by simp
haftmann@25303
   526
qed
haftmann@25303
   527
huffman@30691
   528
lemmas add_sign_intros =
huffman@30691
   529
  add_pos_nonneg add_pos_pos add_nonneg_pos add_nonneg_nonneg
huffman@30691
   530
  add_neg_nonpos add_neg_neg add_nonpos_neg add_nonpos_nonpos
huffman@30691
   531
huffman@29886
   532
lemma add_nonneg_eq_0_iff:
huffman@29886
   533
  assumes x: "0 \<le> x" and y: "0 \<le> y"
huffman@29886
   534
  shows "x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0"
huffman@29886
   535
proof (intro iffI conjI)
huffman@29886
   536
  have "x = x + 0" by simp
huffman@29886
   537
  also have "x + 0 \<le> x + y" using y by (rule add_left_mono)
huffman@29886
   538
  also assume "x + y = 0"
huffman@29886
   539
  also have "0 \<le> x" using x .
huffman@29886
   540
  finally show "x = 0" .
huffman@29886
   541
next
huffman@29886
   542
  have "y = 0 + y" by simp
huffman@29886
   543
  also have "0 + y \<le> x + y" using x by (rule add_right_mono)
huffman@29886
   544
  also assume "x + y = 0"
huffman@29886
   545
  also have "0 \<le> y" using y .
huffman@29886
   546
  finally show "y = 0" .
huffman@29886
   547
next
huffman@29886
   548
  assume "x = 0 \<and> y = 0"
huffman@29886
   549
  then show "x + y = 0" by simp
huffman@29886
   550
qed
huffman@29886
   551
haftmann@25303
   552
end
haftmann@25303
   553
haftmann@35028
   554
class ordered_ab_group_add =
haftmann@35028
   555
  ab_group_add + ordered_ab_semigroup_add
haftmann@25062
   556
begin
haftmann@25062
   557
haftmann@35028
   558
subclass ordered_cancel_ab_semigroup_add ..
haftmann@25062
   559
haftmann@35028
   560
subclass ordered_ab_semigroup_add_imp_le
haftmann@28823
   561
proof
haftmann@25062
   562
  fix a b c :: 'a
haftmann@25062
   563
  assume "c + a \<le> c + b"
haftmann@25062
   564
  hence "(-c) + (c + a) \<le> (-c) + (c + b)" by (rule add_left_mono)
haftmann@25062
   565
  hence "((-c) + c) + a \<le> ((-c) + c) + b" by (simp only: add_assoc)
haftmann@25062
   566
  thus "a \<le> b" by simp
haftmann@25062
   567
qed
haftmann@25062
   568
haftmann@35028
   569
subclass ordered_comm_monoid_add ..
haftmann@25303
   570
haftmann@25077
   571
lemma max_diff_distrib_left:
haftmann@25077
   572
  shows "max x y - z = max (x - z) (y - z)"
nipkow@29667
   573
by (simp add: diff_minus, rule max_add_distrib_left) 
haftmann@25077
   574
haftmann@25077
   575
lemma min_diff_distrib_left:
haftmann@25077
   576
  shows "min x y - z = min (x - z) (y - z)"
nipkow@29667
   577
by (simp add: diff_minus, rule min_add_distrib_left) 
haftmann@25077
   578
haftmann@25077
   579
lemma le_imp_neg_le:
nipkow@29667
   580
  assumes "a \<le> b" shows "-b \<le> -a"
haftmann@25077
   581
proof -
nipkow@29667
   582
  have "-a+a \<le> -a+b" using `a \<le> b` by (rule add_left_mono) 
nipkow@29667
   583
  hence "0 \<le> -a+b" by simp
nipkow@29667
   584
  hence "0 + (-b) \<le> (-a + b) + (-b)" by (rule add_right_mono) 
nipkow@29667
   585
  thus ?thesis by (simp add: add_assoc)
haftmann@25077
   586
qed
haftmann@25077
   587
haftmann@25077
   588
lemma neg_le_iff_le [simp]: "- b \<le> - a \<longleftrightarrow> a \<le> b"
haftmann@25077
   589
proof 
haftmann@25077
   590
  assume "- b \<le> - a"
nipkow@29667
   591
  hence "- (- a) \<le> - (- b)" by (rule le_imp_neg_le)
haftmann@25077
   592
  thus "a\<le>b" by simp
haftmann@25077
   593
next
haftmann@25077
   594
  assume "a\<le>b"
haftmann@25077
   595
  thus "-b \<le> -a" by (rule le_imp_neg_le)
haftmann@25077
   596
qed
haftmann@25077
   597
haftmann@25077
   598
lemma neg_le_0_iff_le [simp]: "- a \<le> 0 \<longleftrightarrow> 0 \<le> a"
nipkow@29667
   599
by (subst neg_le_iff_le [symmetric], simp)
haftmann@25077
   600
haftmann@25077
   601
lemma neg_0_le_iff_le [simp]: "0 \<le> - a \<longleftrightarrow> a \<le> 0"
nipkow@29667
   602
by (subst neg_le_iff_le [symmetric], simp)
haftmann@25077
   603
haftmann@25077
   604
lemma neg_less_iff_less [simp]: "- b < - a \<longleftrightarrow> a < b"
nipkow@29667
   605
by (force simp add: less_le) 
haftmann@25077
   606
haftmann@25077
   607
lemma neg_less_0_iff_less [simp]: "- a < 0 \<longleftrightarrow> 0 < a"
nipkow@29667
   608
by (subst neg_less_iff_less [symmetric], simp)
haftmann@25077
   609
haftmann@25077
   610
lemma neg_0_less_iff_less [simp]: "0 < - a \<longleftrightarrow> a < 0"
nipkow@29667
   611
by (subst neg_less_iff_less [symmetric], simp)
haftmann@25077
   612
haftmann@25077
   613
text{*The next several equations can make the simplifier loop!*}
haftmann@25077
   614
haftmann@25077
   615
lemma less_minus_iff: "a < - b \<longleftrightarrow> b < - a"
haftmann@25077
   616
proof -
haftmann@25077
   617
  have "(- (-a) < - b) = (b < - a)" by (rule neg_less_iff_less)
haftmann@25077
   618
  thus ?thesis by simp
haftmann@25077
   619
qed
haftmann@25077
   620
haftmann@25077
   621
lemma minus_less_iff: "- a < b \<longleftrightarrow> - b < a"
haftmann@25077
   622
proof -
haftmann@25077
   623
  have "(- a < - (-b)) = (- b < a)" by (rule neg_less_iff_less)
haftmann@25077
   624
  thus ?thesis by simp
haftmann@25077
   625
qed
haftmann@25077
   626
haftmann@25077
   627
lemma le_minus_iff: "a \<le> - b \<longleftrightarrow> b \<le> - a"
haftmann@25077
   628
proof -
haftmann@25077
   629
  have mm: "!! a (b::'a). (-(-a)) < -b \<Longrightarrow> -(-b) < -a" by (simp only: minus_less_iff)
haftmann@25077
   630
  have "(- (- a) <= -b) = (b <= - a)" 
haftmann@25077
   631
    apply (auto simp only: le_less)
haftmann@25077
   632
    apply (drule mm)
haftmann@25077
   633
    apply (simp_all)
haftmann@25077
   634
    apply (drule mm[simplified], assumption)
haftmann@25077
   635
    done
haftmann@25077
   636
  then show ?thesis by simp
haftmann@25077
   637
qed
haftmann@25077
   638
haftmann@25077
   639
lemma minus_le_iff: "- a \<le> b \<longleftrightarrow> - b \<le> a"
nipkow@29667
   640
by (auto simp add: le_less minus_less_iff)
haftmann@25077
   641
haftmann@25077
   642
lemma less_iff_diff_less_0: "a < b \<longleftrightarrow> a - b < 0"
haftmann@25077
   643
proof -
haftmann@25077
   644
  have  "(a < b) = (a + (- b) < b + (-b))"  
haftmann@25077
   645
    by (simp only: add_less_cancel_right)
haftmann@25077
   646
  also have "... =  (a - b < 0)" by (simp add: diff_minus)
haftmann@25077
   647
  finally show ?thesis .
haftmann@25077
   648
qed
haftmann@25077
   649
nipkow@29667
   650
lemma diff_less_eq[algebra_simps]: "a - b < c \<longleftrightarrow> a < c + b"
haftmann@25077
   651
apply (subst less_iff_diff_less_0 [of a])
haftmann@25077
   652
apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst])
haftmann@25077
   653
apply (simp add: diff_minus add_ac)
haftmann@25077
   654
done
haftmann@25077
   655
nipkow@29667
   656
lemma less_diff_eq[algebra_simps]: "a < c - b \<longleftrightarrow> a + b < c"
haftmann@25077
   657
apply (subst less_iff_diff_less_0 [of "plus a b"])
haftmann@25077
   658
apply (subst less_iff_diff_less_0 [of a])
haftmann@25077
   659
apply (simp add: diff_minus add_ac)
haftmann@25077
   660
done
haftmann@25077
   661
nipkow@29667
   662
lemma diff_le_eq[algebra_simps]: "a - b \<le> c \<longleftrightarrow> a \<le> c + b"
nipkow@29667
   663
by (auto simp add: le_less diff_less_eq diff_add_cancel add_diff_cancel)
haftmann@25077
   664
nipkow@29667
   665
lemma le_diff_eq[algebra_simps]: "a \<le> c - b \<longleftrightarrow> a + b \<le> c"
nipkow@29667
   666
by (auto simp add: le_less less_diff_eq diff_add_cancel add_diff_cancel)
haftmann@25077
   667
haftmann@25077
   668
lemma le_iff_diff_le_0: "a \<le> b \<longleftrightarrow> a - b \<le> 0"
nipkow@29667
   669
by (simp add: algebra_simps)
haftmann@25077
   670
nipkow@29667
   671
text{*Legacy - use @{text algebra_simps} *}
nipkow@29833
   672
lemmas group_simps[noatp] = algebra_simps
haftmann@25230
   673
haftmann@25077
   674
end
haftmann@25077
   675
nipkow@29667
   676
text{*Legacy - use @{text algebra_simps} *}
nipkow@29833
   677
lemmas group_simps[noatp] = algebra_simps
haftmann@25230
   678
haftmann@35028
   679
class linordered_ab_semigroup_add =
haftmann@35028
   680
  linorder + ordered_ab_semigroup_add
haftmann@25062
   681
haftmann@35028
   682
class linordered_cancel_ab_semigroup_add =
haftmann@35028
   683
  linorder + ordered_cancel_ab_semigroup_add
haftmann@25267
   684
begin
haftmann@25062
   685
haftmann@35028
   686
subclass linordered_ab_semigroup_add ..
haftmann@25062
   687
haftmann@35028
   688
subclass ordered_ab_semigroup_add_imp_le
haftmann@28823
   689
proof
haftmann@25062
   690
  fix a b c :: 'a
haftmann@25062
   691
  assume le: "c + a <= c + b"  
haftmann@25062
   692
  show "a <= b"
haftmann@25062
   693
  proof (rule ccontr)
haftmann@25062
   694
    assume w: "~ a \<le> b"
haftmann@25062
   695
    hence "b <= a" by (simp add: linorder_not_le)
haftmann@25062
   696
    hence le2: "c + b <= c + a" by (rule add_left_mono)
haftmann@25062
   697
    have "a = b" 
haftmann@25062
   698
      apply (insert le)
haftmann@25062
   699
      apply (insert le2)
haftmann@25062
   700
      apply (drule antisym, simp_all)
haftmann@25062
   701
      done
haftmann@25062
   702
    with w show False 
haftmann@25062
   703
      by (simp add: linorder_not_le [symmetric])
haftmann@25062
   704
  qed
haftmann@25062
   705
qed
haftmann@25062
   706
haftmann@25267
   707
end
haftmann@25267
   708
haftmann@35028
   709
class linordered_ab_group_add = linorder + ordered_ab_group_add
haftmann@25267
   710
begin
haftmann@25230
   711
haftmann@35028
   712
subclass linordered_cancel_ab_semigroup_add ..
haftmann@25230
   713
haftmann@35036
   714
lemma neg_less_eq_nonneg [simp]:
haftmann@25303
   715
  "- a \<le> a \<longleftrightarrow> 0 \<le> a"
haftmann@25303
   716
proof
haftmann@25303
   717
  assume A: "- a \<le> a" show "0 \<le> a"
haftmann@25303
   718
  proof (rule classical)
haftmann@25303
   719
    assume "\<not> 0 \<le> a"
haftmann@25303
   720
    then have "a < 0" by auto
haftmann@25303
   721
    with A have "- a < 0" by (rule le_less_trans)
haftmann@25303
   722
    then show ?thesis by auto
haftmann@25303
   723
  qed
haftmann@25303
   724
next
haftmann@25303
   725
  assume A: "0 \<le> a" show "- a \<le> a"
haftmann@25303
   726
  proof (rule order_trans)
haftmann@25303
   727
    show "- a \<le> 0" using A by (simp add: minus_le_iff)
haftmann@25303
   728
  next
haftmann@25303
   729
    show "0 \<le> a" using A .
haftmann@25303
   730
  qed
haftmann@25303
   731
qed
haftmann@35036
   732
haftmann@35036
   733
lemma neg_less_nonneg [simp]:
haftmann@35036
   734
  "- a < a \<longleftrightarrow> 0 < a"
haftmann@35036
   735
proof
haftmann@35036
   736
  assume A: "- a < a" show "0 < a"
haftmann@35036
   737
  proof (rule classical)
haftmann@35036
   738
    assume "\<not> 0 < a"
haftmann@35036
   739
    then have "a \<le> 0" by auto
haftmann@35036
   740
    with A have "- a < 0" by (rule less_le_trans)
haftmann@35036
   741
    then show ?thesis by auto
haftmann@35036
   742
  qed
haftmann@35036
   743
next
haftmann@35036
   744
  assume A: "0 < a" show "- a < a"
haftmann@35036
   745
  proof (rule less_trans)
haftmann@35036
   746
    show "- a < 0" using A by (simp add: minus_le_iff)
haftmann@35036
   747
  next
haftmann@35036
   748
    show "0 < a" using A .
haftmann@35036
   749
  qed
haftmann@35036
   750
qed
haftmann@35036
   751
haftmann@35036
   752
lemma less_eq_neg_nonpos [simp]:
haftmann@25303
   753
  "a \<le> - a \<longleftrightarrow> a \<le> 0"
haftmann@25303
   754
proof
haftmann@25303
   755
  assume A: "a \<le> - a" show "a \<le> 0"
haftmann@25303
   756
  proof (rule classical)
haftmann@25303
   757
    assume "\<not> a \<le> 0"
haftmann@25303
   758
    then have "0 < a" by auto
haftmann@25303
   759
    then have "0 < - a" using A by (rule less_le_trans)
haftmann@25303
   760
    then show ?thesis by auto
haftmann@25303
   761
  qed
haftmann@25303
   762
next
haftmann@25303
   763
  assume A: "a \<le> 0" show "a \<le> - a"
haftmann@25303
   764
  proof (rule order_trans)
haftmann@25303
   765
    show "0 \<le> - a" using A by (simp add: minus_le_iff)
haftmann@25303
   766
  next
haftmann@25303
   767
    show "a \<le> 0" using A .
haftmann@25303
   768
  qed
haftmann@25303
   769
qed
haftmann@25303
   770
haftmann@35036
   771
lemma equal_neg_zero [simp]:
haftmann@25303
   772
  "a = - a \<longleftrightarrow> a = 0"
haftmann@25303
   773
proof
haftmann@25303
   774
  assume "a = 0" then show "a = - a" by simp
haftmann@25303
   775
next
haftmann@25303
   776
  assume A: "a = - a" show "a = 0"
haftmann@25303
   777
  proof (cases "0 \<le> a")
haftmann@25303
   778
    case True with A have "0 \<le> - a" by auto
haftmann@25303
   779
    with le_minus_iff have "a \<le> 0" by simp
haftmann@25303
   780
    with True show ?thesis by (auto intro: order_trans)
haftmann@25303
   781
  next
haftmann@25303
   782
    case False then have B: "a \<le> 0" by auto
haftmann@25303
   783
    with A have "- a \<le> 0" by auto
haftmann@25303
   784
    with B show ?thesis by (auto intro: order_trans)
haftmann@25303
   785
  qed
haftmann@25303
   786
qed
haftmann@25303
   787
haftmann@35036
   788
lemma neg_equal_zero [simp]:
haftmann@25303
   789
  "- a = a \<longleftrightarrow> a = 0"
haftmann@35036
   790
  by (auto dest: sym)
haftmann@35036
   791
haftmann@35036
   792
lemma double_zero [simp]:
haftmann@35036
   793
  "a + a = 0 \<longleftrightarrow> a = 0"
haftmann@35036
   794
proof
haftmann@35036
   795
  assume assm: "a + a = 0"
haftmann@35036
   796
  then have a: "- a = a" by (rule minus_unique)
haftmann@35036
   797
  then show "a = 0" by (simp add: neg_equal_zero)
haftmann@35036
   798
qed simp
haftmann@35036
   799
haftmann@35036
   800
lemma double_zero_sym [simp]:
haftmann@35036
   801
  "0 = a + a \<longleftrightarrow> a = 0"
haftmann@35036
   802
  by (rule, drule sym) simp_all
haftmann@35036
   803
haftmann@35036
   804
lemma zero_less_double_add_iff_zero_less_single_add [simp]:
haftmann@35036
   805
  "0 < a + a \<longleftrightarrow> 0 < a"
haftmann@35036
   806
proof
haftmann@35036
   807
  assume "0 < a + a"
haftmann@35036
   808
  then have "0 - a < a" by (simp only: diff_less_eq)
haftmann@35036
   809
  then have "- a < a" by simp
haftmann@35036
   810
  then show "0 < a" by (simp add: neg_less_nonneg)
haftmann@35036
   811
next
haftmann@35036
   812
  assume "0 < a"
haftmann@35036
   813
  with this have "0 + 0 < a + a"
haftmann@35036
   814
    by (rule add_strict_mono)
haftmann@35036
   815
  then show "0 < a + a" by simp
haftmann@35036
   816
qed
haftmann@35036
   817
haftmann@35036
   818
lemma zero_le_double_add_iff_zero_le_single_add [simp]:
haftmann@35036
   819
  "0 \<le> a + a \<longleftrightarrow> 0 \<le> a"
haftmann@35036
   820
  by (auto simp add: le_less)
haftmann@35036
   821
haftmann@35036
   822
lemma double_add_less_zero_iff_single_add_less_zero [simp]:
haftmann@35036
   823
  "a + a < 0 \<longleftrightarrow> a < 0"
haftmann@35036
   824
proof -
haftmann@35036
   825
  have "\<not> a + a < 0 \<longleftrightarrow> \<not> a < 0"
haftmann@35036
   826
    by (simp add: not_less)
haftmann@35036
   827
  then show ?thesis by simp
haftmann@35036
   828
qed
haftmann@35036
   829
haftmann@35036
   830
lemma double_add_le_zero_iff_single_add_le_zero [simp]:
haftmann@35036
   831
  "a + a \<le> 0 \<longleftrightarrow> a \<le> 0" 
haftmann@35036
   832
proof -
haftmann@35036
   833
  have "\<not> a + a \<le> 0 \<longleftrightarrow> \<not> a \<le> 0"
haftmann@35036
   834
    by (simp add: not_le)
haftmann@35036
   835
  then show ?thesis by simp
haftmann@35036
   836
qed
haftmann@35036
   837
haftmann@35036
   838
lemma le_minus_self_iff:
haftmann@35036
   839
  "a \<le> - a \<longleftrightarrow> a \<le> 0"
haftmann@35036
   840
proof -
haftmann@35036
   841
  from add_le_cancel_left [of "- a" "a + a" 0]
haftmann@35036
   842
  have "a \<le> - a \<longleftrightarrow> a + a \<le> 0" 
haftmann@35036
   843
    by (simp add: add_assoc [symmetric])
haftmann@35036
   844
  thus ?thesis by simp
haftmann@35036
   845
qed
haftmann@35036
   846
haftmann@35036
   847
lemma minus_le_self_iff:
haftmann@35036
   848
  "- a \<le> a \<longleftrightarrow> 0 \<le> a"
haftmann@35036
   849
proof -
haftmann@35036
   850
  from add_le_cancel_left [of "- a" 0 "a + a"]
haftmann@35036
   851
  have "- a \<le> a \<longleftrightarrow> 0 \<le> a + a" 
haftmann@35036
   852
    by (simp add: add_assoc [symmetric])
haftmann@35036
   853
  thus ?thesis by simp
haftmann@35036
   854
qed
haftmann@35036
   855
haftmann@35036
   856
lemma minus_max_eq_min:
haftmann@35036
   857
  "- max x y = min (-x) (-y)"
haftmann@35036
   858
  by (auto simp add: max_def min_def)
haftmann@35036
   859
haftmann@35036
   860
lemma minus_min_eq_max:
haftmann@35036
   861
  "- min x y = max (-x) (-y)"
haftmann@35036
   862
  by (auto simp add: max_def min_def)
haftmann@25303
   863
haftmann@25267
   864
end
haftmann@25267
   865
haftmann@25077
   866
-- {* FIXME localize the following *}
obua@14738
   867
paulson@15234
   868
lemma add_increasing:
haftmann@35028
   869
  fixes c :: "'a::{ordered_ab_semigroup_add_imp_le, comm_monoid_add}"
paulson@15234
   870
  shows  "[|0\<le>a; b\<le>c|] ==> b \<le> a + c"
obua@14738
   871
by (insert add_mono [of 0 a b c], simp)
obua@14738
   872
nipkow@15539
   873
lemma add_increasing2:
haftmann@35028
   874
  fixes c :: "'a::{ordered_ab_semigroup_add_imp_le, comm_monoid_add}"
nipkow@15539
   875
  shows  "[|0\<le>c; b\<le>a|] ==> b \<le> a + c"
nipkow@15539
   876
by (simp add:add_increasing add_commute[of a])
nipkow@15539
   877
paulson@15234
   878
lemma add_strict_increasing:
haftmann@35028
   879
  fixes c :: "'a::{ordered_ab_semigroup_add_imp_le, comm_monoid_add}"
paulson@15234
   880
  shows "[|0<a; b\<le>c|] ==> b < a + c"
paulson@15234
   881
by (insert add_less_le_mono [of 0 a b c], simp)
paulson@15234
   882
paulson@15234
   883
lemma add_strict_increasing2:
haftmann@35028
   884
  fixes c :: "'a::{ordered_ab_semigroup_add_imp_le, comm_monoid_add}"
paulson@15234
   885
  shows "[|0\<le>a; b<c|] ==> b < a + c"
paulson@15234
   886
by (insert add_le_less_mono [of 0 a b c], simp)
paulson@15234
   887
haftmann@35092
   888
class abs =
haftmann@35092
   889
  fixes abs :: "'a \<Rightarrow> 'a"
haftmann@35092
   890
begin
haftmann@35092
   891
haftmann@35092
   892
notation (xsymbols)
haftmann@35092
   893
  abs  ("\<bar>_\<bar>")
haftmann@35092
   894
haftmann@35092
   895
notation (HTML output)
haftmann@35092
   896
  abs  ("\<bar>_\<bar>")
haftmann@35092
   897
haftmann@35092
   898
end
haftmann@35092
   899
haftmann@35092
   900
class sgn =
haftmann@35092
   901
  fixes sgn :: "'a \<Rightarrow> 'a"
haftmann@35092
   902
haftmann@35092
   903
class abs_if = minus + uminus + ord + zero + abs +
haftmann@35092
   904
  assumes abs_if: "\<bar>a\<bar> = (if a < 0 then - a else a)"
haftmann@35092
   905
haftmann@35092
   906
class sgn_if = minus + uminus + zero + one + ord + sgn +
haftmann@35092
   907
  assumes sgn_if: "sgn x = (if x = 0 then 0 else if 0 < x then 1 else - 1)"
haftmann@35092
   908
begin
haftmann@35092
   909
haftmann@35092
   910
lemma sgn0 [simp]: "sgn 0 = 0"
haftmann@35092
   911
  by (simp add:sgn_if)
haftmann@35092
   912
haftmann@35092
   913
end
obua@14738
   914
haftmann@35028
   915
class ordered_ab_group_add_abs = ordered_ab_group_add + abs +
haftmann@25303
   916
  assumes abs_ge_zero [simp]: "\<bar>a\<bar> \<ge> 0"
haftmann@25303
   917
    and abs_ge_self: "a \<le> \<bar>a\<bar>"
haftmann@25303
   918
    and abs_leI: "a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b"
haftmann@25303
   919
    and abs_minus_cancel [simp]: "\<bar>-a\<bar> = \<bar>a\<bar>"
haftmann@25303
   920
    and abs_triangle_ineq: "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>"
haftmann@25303
   921
begin
haftmann@25303
   922
haftmann@25307
   923
lemma abs_minus_le_zero: "- \<bar>a\<bar> \<le> 0"
haftmann@25307
   924
  unfolding neg_le_0_iff_le by simp
haftmann@25307
   925
haftmann@25307
   926
lemma abs_of_nonneg [simp]:
nipkow@29667
   927
  assumes nonneg: "0 \<le> a" shows "\<bar>a\<bar> = a"
haftmann@25307
   928
proof (rule antisym)
haftmann@25307
   929
  from nonneg le_imp_neg_le have "- a \<le> 0" by simp
haftmann@25307
   930
  from this nonneg have "- a \<le> a" by (rule order_trans)
haftmann@25307
   931
  then show "\<bar>a\<bar> \<le> a" by (auto intro: abs_leI)
haftmann@25307
   932
qed (rule abs_ge_self)
haftmann@25307
   933
haftmann@25307
   934
lemma abs_idempotent [simp]: "\<bar>\<bar>a\<bar>\<bar> = \<bar>a\<bar>"
nipkow@29667
   935
by (rule antisym)
nipkow@29667
   936
   (auto intro!: abs_ge_self abs_leI order_trans [of "uminus (abs a)" zero "abs a"])
haftmann@25307
   937
haftmann@25307
   938
lemma abs_eq_0 [simp]: "\<bar>a\<bar> = 0 \<longleftrightarrow> a = 0"
haftmann@25307
   939
proof -
haftmann@25307
   940
  have "\<bar>a\<bar> = 0 \<Longrightarrow> a = 0"
haftmann@25307
   941
  proof (rule antisym)
haftmann@25307
   942
    assume zero: "\<bar>a\<bar> = 0"
haftmann@25307
   943
    with abs_ge_self show "a \<le> 0" by auto
haftmann@25307
   944
    from zero have "\<bar>-a\<bar> = 0" by simp
haftmann@25307
   945
    with abs_ge_self [of "uminus a"] have "- a \<le> 0" by auto
haftmann@25307
   946
    with neg_le_0_iff_le show "0 \<le> a" by auto
haftmann@25307
   947
  qed
haftmann@25307
   948
  then show ?thesis by auto
haftmann@25307
   949
qed
haftmann@25307
   950
haftmann@25303
   951
lemma abs_zero [simp]: "\<bar>0\<bar> = 0"
nipkow@29667
   952
by simp
avigad@16775
   953
haftmann@25303
   954
lemma abs_0_eq [simp, noatp]: "0 = \<bar>a\<bar> \<longleftrightarrow> a = 0"
haftmann@25303
   955
proof -
haftmann@25303
   956
  have "0 = \<bar>a\<bar> \<longleftrightarrow> \<bar>a\<bar> = 0" by (simp only: eq_ac)
haftmann@25303
   957
  thus ?thesis by simp
haftmann@25303
   958
qed
haftmann@25303
   959
haftmann@25303
   960
lemma abs_le_zero_iff [simp]: "\<bar>a\<bar> \<le> 0 \<longleftrightarrow> a = 0" 
haftmann@25303
   961
proof
haftmann@25303
   962
  assume "\<bar>a\<bar> \<le> 0"
haftmann@25303
   963
  then have "\<bar>a\<bar> = 0" by (rule antisym) simp
haftmann@25303
   964
  thus "a = 0" by simp
haftmann@25303
   965
next
haftmann@25303
   966
  assume "a = 0"
haftmann@25303
   967
  thus "\<bar>a\<bar> \<le> 0" by simp
haftmann@25303
   968
qed
haftmann@25303
   969
haftmann@25303
   970
lemma zero_less_abs_iff [simp]: "0 < \<bar>a\<bar> \<longleftrightarrow> a \<noteq> 0"
nipkow@29667
   971
by (simp add: less_le)
haftmann@25303
   972
haftmann@25303
   973
lemma abs_not_less_zero [simp]: "\<not> \<bar>a\<bar> < 0"
haftmann@25303
   974
proof -
haftmann@25303
   975
  have a: "\<And>x y. x \<le> y \<Longrightarrow> \<not> y < x" by auto
haftmann@25303
   976
  show ?thesis by (simp add: a)
haftmann@25303
   977
qed
avigad@16775
   978
haftmann@25303
   979
lemma abs_ge_minus_self: "- a \<le> \<bar>a\<bar>"
haftmann@25303
   980
proof -
haftmann@25303
   981
  have "- a \<le> \<bar>-a\<bar>" by (rule abs_ge_self)
haftmann@25303
   982
  then show ?thesis by simp
haftmann@25303
   983
qed
haftmann@25303
   984
haftmann@25303
   985
lemma abs_minus_commute: 
haftmann@25303
   986
  "\<bar>a - b\<bar> = \<bar>b - a\<bar>"
haftmann@25303
   987
proof -
haftmann@25303
   988
  have "\<bar>a - b\<bar> = \<bar>- (a - b)\<bar>" by (simp only: abs_minus_cancel)
haftmann@25303
   989
  also have "... = \<bar>b - a\<bar>" by simp
haftmann@25303
   990
  finally show ?thesis .
haftmann@25303
   991
qed
haftmann@25303
   992
haftmann@25303
   993
lemma abs_of_pos: "0 < a \<Longrightarrow> \<bar>a\<bar> = a"
nipkow@29667
   994
by (rule abs_of_nonneg, rule less_imp_le)
avigad@16775
   995
haftmann@25303
   996
lemma abs_of_nonpos [simp]:
nipkow@29667
   997
  assumes "a \<le> 0" shows "\<bar>a\<bar> = - a"
haftmann@25303
   998
proof -
haftmann@25303
   999
  let ?b = "- a"
haftmann@25303
  1000
  have "- ?b \<le> 0 \<Longrightarrow> \<bar>- ?b\<bar> = - (- ?b)"
haftmann@25303
  1001
  unfolding abs_minus_cancel [of "?b"]
haftmann@25303
  1002
  unfolding neg_le_0_iff_le [of "?b"]
haftmann@25303
  1003
  unfolding minus_minus by (erule abs_of_nonneg)
haftmann@25303
  1004
  then show ?thesis using assms by auto
haftmann@25303
  1005
qed
haftmann@25303
  1006
  
haftmann@25303
  1007
lemma abs_of_neg: "a < 0 \<Longrightarrow> \<bar>a\<bar> = - a"
nipkow@29667
  1008
by (rule abs_of_nonpos, rule less_imp_le)
haftmann@25303
  1009
haftmann@25303
  1010
lemma abs_le_D1: "\<bar>a\<bar> \<le> b \<Longrightarrow> a \<le> b"
nipkow@29667
  1011
by (insert abs_ge_self, blast intro: order_trans)
haftmann@25303
  1012
haftmann@25303
  1013
lemma abs_le_D2: "\<bar>a\<bar> \<le> b \<Longrightarrow> - a \<le> b"
nipkow@29667
  1014
by (insert abs_le_D1 [of "uminus a"], simp)
haftmann@25303
  1015
haftmann@25303
  1016
lemma abs_le_iff: "\<bar>a\<bar> \<le> b \<longleftrightarrow> a \<le> b \<and> - a \<le> b"
nipkow@29667
  1017
by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2)
haftmann@25303
  1018
haftmann@25303
  1019
lemma abs_triangle_ineq2: "\<bar>a\<bar> - \<bar>b\<bar> \<le> \<bar>a - b\<bar>"
nipkow@29667
  1020
  apply (simp add: algebra_simps)
nipkow@29667
  1021
  apply (subgoal_tac "abs a = abs (plus b (minus a b))")
haftmann@25303
  1022
  apply (erule ssubst)
haftmann@25303
  1023
  apply (rule abs_triangle_ineq)
nipkow@29667
  1024
  apply (rule arg_cong[of _ _ abs])
nipkow@29667
  1025
  apply (simp add: algebra_simps)
avigad@16775
  1026
done
avigad@16775
  1027
haftmann@25303
  1028
lemma abs_triangle_ineq3: "\<bar>\<bar>a\<bar> - \<bar>b\<bar>\<bar> \<le> \<bar>a - b\<bar>"
haftmann@25303
  1029
  apply (subst abs_le_iff)
haftmann@25303
  1030
  apply auto
haftmann@25303
  1031
  apply (rule abs_triangle_ineq2)
haftmann@25303
  1032
  apply (subst abs_minus_commute)
haftmann@25303
  1033
  apply (rule abs_triangle_ineq2)
avigad@16775
  1034
done
avigad@16775
  1035
haftmann@25303
  1036
lemma abs_triangle_ineq4: "\<bar>a - b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>"
haftmann@25303
  1037
proof -
nipkow@29667
  1038
  have "abs(a - b) = abs(a + - b)" by (subst diff_minus, rule refl)
nipkow@29667
  1039
  also have "... <= abs a + abs (- b)" by (rule abs_triangle_ineq)
nipkow@29667
  1040
  finally show ?thesis by simp
haftmann@25303
  1041
qed
avigad@16775
  1042
haftmann@25303
  1043
lemma abs_diff_triangle_ineq: "\<bar>a + b - (c + d)\<bar> \<le> \<bar>a - c\<bar> + \<bar>b - d\<bar>"
haftmann@25303
  1044
proof -
haftmann@25303
  1045
  have "\<bar>a + b - (c+d)\<bar> = \<bar>(a-c) + (b-d)\<bar>" by (simp add: diff_minus add_ac)
haftmann@25303
  1046
  also have "... \<le> \<bar>a-c\<bar> + \<bar>b-d\<bar>" by (rule abs_triangle_ineq)
haftmann@25303
  1047
  finally show ?thesis .
haftmann@25303
  1048
qed
avigad@16775
  1049
haftmann@25303
  1050
lemma abs_add_abs [simp]:
haftmann@25303
  1051
  "\<bar>\<bar>a\<bar> + \<bar>b\<bar>\<bar> = \<bar>a\<bar> + \<bar>b\<bar>" (is "?L = ?R")
haftmann@25303
  1052
proof (rule antisym)
haftmann@25303
  1053
  show "?L \<ge> ?R" by(rule abs_ge_self)
haftmann@25303
  1054
next
haftmann@25303
  1055
  have "?L \<le> \<bar>\<bar>a\<bar>\<bar> + \<bar>\<bar>b\<bar>\<bar>" by(rule abs_triangle_ineq)
haftmann@25303
  1056
  also have "\<dots> = ?R" by simp
haftmann@25303
  1057
  finally show "?L \<le> ?R" .
haftmann@25303
  1058
qed
haftmann@25303
  1059
haftmann@25303
  1060
end
obua@14738
  1061
obua@14754
  1062
text {* Needed for abelian cancellation simprocs: *}
obua@14754
  1063
obua@14754
  1064
lemma add_cancel_21: "((x::'a::ab_group_add) + (y + z) = y + u) = (x + z = u)"
obua@14754
  1065
apply (subst add_left_commute)
obua@14754
  1066
apply (subst add_left_cancel)
obua@14754
  1067
apply simp
obua@14754
  1068
done
obua@14754
  1069
obua@14754
  1070
lemma add_cancel_end: "(x + (y + z) = y) = (x = - (z::'a::ab_group_add))"
obua@14754
  1071
apply (subst add_cancel_21[of _ _ _ 0, simplified])
obua@14754
  1072
apply (simp add: add_right_cancel[symmetric, of "x" "-z" "z", simplified])
obua@14754
  1073
done
obua@14754
  1074
haftmann@35028
  1075
lemma less_eqI: "(x::'a::ordered_ab_group_add) - y = x' - y' \<Longrightarrow> (x < y) = (x' < y')"
obua@14754
  1076
by (simp add: less_iff_diff_less_0[of x y] less_iff_diff_less_0[of x' y'])
obua@14754
  1077
haftmann@35028
  1078
lemma le_eqI: "(x::'a::ordered_ab_group_add) - y = x' - y' \<Longrightarrow> (y <= x) = (y' <= x')"
obua@14754
  1079
apply (simp add: le_iff_diff_le_0[of y x] le_iff_diff_le_0[of  y' x'])
obua@14754
  1080
apply (simp add: neg_le_iff_le[symmetric, of "y-x" 0] neg_le_iff_le[symmetric, of "y'-x'" 0])
obua@14754
  1081
done
obua@14754
  1082
obua@14754
  1083
lemma eq_eqI: "(x::'a::ab_group_add) - y = x' - y' \<Longrightarrow> (x = y) = (x' = y')"
huffman@30629
  1084
by (simp only: eq_iff_diff_eq_0[of x y] eq_iff_diff_eq_0[of x' y'])
obua@14754
  1085
obua@14754
  1086
lemma diff_def: "(x::'a::ab_group_add) - y == x + (-y)"
obua@14754
  1087
by (simp add: diff_minus)
obua@14754
  1088
haftmann@25090
  1089
lemma le_add_right_mono: 
obua@15178
  1090
  assumes 
haftmann@35028
  1091
  "a <= b + (c::'a::ordered_ab_group_add)"
obua@15178
  1092
  "c <= d"    
obua@15178
  1093
  shows "a <= b + d"
obua@15178
  1094
  apply (rule_tac order_trans[where y = "b+c"])
obua@15178
  1095
  apply (simp_all add: prems)
obua@15178
  1096
  done
obua@15178
  1097
obua@15178
  1098
haftmann@25090
  1099
subsection {* Tools setup *}
haftmann@25090
  1100
haftmann@35028
  1101
lemma add_mono_thms_linordered_semiring [noatp]:
haftmann@35028
  1102
  fixes i j k :: "'a\<Colon>ordered_ab_semigroup_add"
haftmann@25077
  1103
  shows "i \<le> j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l"
haftmann@25077
  1104
    and "i = j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l"
haftmann@25077
  1105
    and "i \<le> j \<and> k = l \<Longrightarrow> i + k \<le> j + l"
haftmann@25077
  1106
    and "i = j \<and> k = l \<Longrightarrow> i + k = j + l"
haftmann@25077
  1107
by (rule add_mono, clarify+)+
haftmann@25077
  1108
haftmann@35028
  1109
lemma add_mono_thms_linordered_field [noatp]:
haftmann@35028
  1110
  fixes i j k :: "'a\<Colon>ordered_cancel_ab_semigroup_add"
haftmann@25077
  1111
  shows "i < j \<and> k = l \<Longrightarrow> i + k < j + l"
haftmann@25077
  1112
    and "i = j \<and> k < l \<Longrightarrow> i + k < j + l"
haftmann@25077
  1113
    and "i < j \<and> k \<le> l \<Longrightarrow> i + k < j + l"
haftmann@25077
  1114
    and "i \<le> j \<and> k < l \<Longrightarrow> i + k < j + l"
haftmann@25077
  1115
    and "i < j \<and> k < l \<Longrightarrow> i + k < j + l"
haftmann@25077
  1116
by (auto intro: add_strict_right_mono add_strict_left_mono
haftmann@25077
  1117
  add_less_le_mono add_le_less_mono add_strict_mono)
haftmann@25077
  1118
paulson@17085
  1119
text{*Simplification of @{term "x-y < 0"}, etc.*}
nipkow@29833
  1120
lemmas diff_less_0_iff_less [simp, noatp] = less_iff_diff_less_0 [symmetric]
nipkow@29833
  1121
lemmas diff_le_0_iff_le [simp, noatp] = le_iff_diff_le_0 [symmetric]
paulson@17085
  1122
haftmann@22482
  1123
ML {*
wenzelm@27250
  1124
structure ab_group_add_cancel = Abel_Cancel
wenzelm@27250
  1125
(
haftmann@22482
  1126
haftmann@22482
  1127
(* term order for abelian groups *)
haftmann@22482
  1128
haftmann@22482
  1129
fun agrp_ord (Const (a, _)) = find_index (fn a' => a = a')
haftmann@34973
  1130
      [@{const_name Algebras.zero}, @{const_name Algebras.plus},
haftmann@34973
  1131
        @{const_name Algebras.uminus}, @{const_name Algebras.minus}]
haftmann@22482
  1132
  | agrp_ord _ = ~1;
haftmann@22482
  1133
wenzelm@29269
  1134
fun termless_agrp (a, b) = (TermOrd.term_lpo agrp_ord (a, b) = LESS);
haftmann@22482
  1135
haftmann@22482
  1136
local
haftmann@22482
  1137
  val ac1 = mk_meta_eq @{thm add_assoc};
haftmann@22482
  1138
  val ac2 = mk_meta_eq @{thm add_commute};
haftmann@22482
  1139
  val ac3 = mk_meta_eq @{thm add_left_commute};
haftmann@34973
  1140
  fun solve_add_ac thy _ (_ $ (Const (@{const_name Algebras.plus},_) $ _ $ _) $ _) =
haftmann@22482
  1141
        SOME ac1
haftmann@34973
  1142
    | solve_add_ac thy _ (_ $ x $ (Const (@{const_name Algebras.plus},_) $ y $ z)) =
haftmann@22482
  1143
        if termless_agrp (y, x) then SOME ac3 else NONE
haftmann@22482
  1144
    | solve_add_ac thy _ (_ $ x $ y) =
haftmann@22482
  1145
        if termless_agrp (y, x) then SOME ac2 else NONE
haftmann@22482
  1146
    | solve_add_ac thy _ _ = NONE
haftmann@22482
  1147
in
wenzelm@32010
  1148
  val add_ac_proc = Simplifier.simproc @{theory}
haftmann@22482
  1149
    "add_ac_proc" ["x + y::'a::ab_semigroup_add"] solve_add_ac;
haftmann@22482
  1150
end;
haftmann@22482
  1151
wenzelm@27250
  1152
val eq_reflection = @{thm eq_reflection};
wenzelm@27250
  1153
  
wenzelm@27250
  1154
val T = @{typ "'a::ab_group_add"};
wenzelm@27250
  1155
haftmann@22482
  1156
val cancel_ss = HOL_basic_ss settermless termless_agrp
haftmann@22482
  1157
  addsimprocs [add_ac_proc] addsimps
nipkow@23085
  1158
  [@{thm add_0_left}, @{thm add_0_right}, @{thm diff_def},
haftmann@22482
  1159
   @{thm minus_add_distrib}, @{thm minus_minus}, @{thm minus_zero},
haftmann@22482
  1160
   @{thm right_minus}, @{thm left_minus}, @{thm add_minus_cancel},
haftmann@22482
  1161
   @{thm minus_add_cancel}];
wenzelm@27250
  1162
wenzelm@27250
  1163
val sum_pats = [@{cterm "x + y::'a::ab_group_add"}, @{cterm "x - y::'a::ab_group_add"}];
haftmann@22482
  1164
  
haftmann@22548
  1165
val eqI_rules = [@{thm less_eqI}, @{thm le_eqI}, @{thm eq_eqI}];
haftmann@22482
  1166
haftmann@22482
  1167
val dest_eqI = 
haftmann@22482
  1168
  fst o HOLogic.dest_bin "op =" HOLogic.boolT o HOLogic.dest_Trueprop o concl_of;
haftmann@22482
  1169
wenzelm@27250
  1170
);
haftmann@22482
  1171
*}
haftmann@22482
  1172
wenzelm@26480
  1173
ML {*
haftmann@22482
  1174
  Addsimprocs [ab_group_add_cancel.sum_conv, ab_group_add_cancel.rel_conv];
haftmann@22482
  1175
*}
paulson@17085
  1176
haftmann@33364
  1177
code_modulename SML
haftmann@35050
  1178
  Groups Arith
haftmann@33364
  1179
haftmann@33364
  1180
code_modulename OCaml
haftmann@35050
  1181
  Groups Arith
haftmann@33364
  1182
haftmann@33364
  1183
code_modulename Haskell
haftmann@35050
  1184
  Groups Arith
haftmann@33364
  1185
obua@14738
  1186
end