| author | wenzelm |
| Sun, 31 Jul 2016 17:25:38 +0200 | |
| changeset 63569 | 7e0b0db5e9ac |
| parent 63456 | 3365c8ec67bd |
| child 63588 | d0e2bad67bd4 |
| permissions | -rw-r--r-- |
|
35050
9f841f20dca6
renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
haftmann
parents:
35036
diff
changeset
|
1 |
(* Title: HOL/Groups.thy |
|
29269
5c25a2012975
moved term order operations to structure TermOrd (cf. Pure/term_ord.ML);
wenzelm
parents:
28823
diff
changeset
|
2 |
Author: Gertrud Bauer, Steven Obua, Lawrence C Paulson, Markus Wenzel, Jeremy Avigad |
| 14738 | 3 |
*) |
4 |
||
| 60758 | 5 |
section \<open>Groups, also combined with orderings\<close> |
| 14738 | 6 |
|
|
35050
9f841f20dca6
renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
haftmann
parents:
35036
diff
changeset
|
7 |
theory Groups |
|
35092
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
8 |
imports Orderings |
| 15131 | 9 |
begin |
| 14738 | 10 |
|
| 60758 | 11 |
subsection \<open>Dynamic facts\<close> |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
12 |
|
| 57950 | 13 |
named_theorems ac_simps "associativity and commutativity simplification rules" |
| 36343 | 14 |
|
15 |
||
| 63325 | 16 |
text \<open> |
17 |
The rewrites accumulated in \<open>algebra_simps\<close> deal with the |
|
18 |
classical algebraic structures of groups, rings and family. They simplify |
|
19 |
terms by multiplying everything out (in case of a ring) and bringing sums and |
|
20 |
products into a canonical form (by ordered rewriting). As a result it decides |
|
21 |
group and ring equalities but also helps with inequalities. |
|
|
36348
89c54f51f55a
dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents:
36343
diff
changeset
|
22 |
|
| 63325 | 23 |
Of course it also works for fields, but it knows nothing about multiplicative |
24 |
inverses or division. This is catered for by \<open>field_simps\<close>. |
|
25 |
\<close> |
|
|
36348
89c54f51f55a
dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents:
36343
diff
changeset
|
26 |
|
| 57950 | 27 |
named_theorems algebra_simps "algebra simplification rules" |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
28 |
|
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
29 |
|
| 63325 | 30 |
text \<open> |
31 |
Lemmas \<open>field_simps\<close> multiply with denominators in (in)equations |
|
32 |
if they can be proved to be non-zero (for equations) or positive/negative |
|
33 |
(for inequations). Can be too aggressive and is therefore separate from the |
|
34 |
more benign \<open>algebra_simps\<close>. |
|
35 |
\<close> |
|
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
36 |
|
| 57950 | 37 |
named_theorems field_simps "algebra simplification rules for fields" |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
38 |
|
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
39 |
|
| 60758 | 40 |
subsection \<open>Abstract structures\<close> |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
41 |
|
| 60758 | 42 |
text \<open> |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
43 |
These locales provide basic structures for interpretation into |
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
44 |
bigger structures; extensions require careful thinking, otherwise |
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
45 |
undesired effects may occur due to interpretation. |
| 60758 | 46 |
\<close> |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
47 |
|
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
48 |
locale semigroup = |
| 63325 | 49 |
fixes f :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^bold>*" 70) |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63145
diff
changeset
|
50 |
assumes assoc [ac_simps]: "a \<^bold>* b \<^bold>* c = a \<^bold>* (b \<^bold>* c)" |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
51 |
|
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
52 |
locale abel_semigroup = semigroup + |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63145
diff
changeset
|
53 |
assumes commute [ac_simps]: "a \<^bold>* b = b \<^bold>* a" |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
54 |
begin |
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
55 |
|
| 63325 | 56 |
lemma left_commute [ac_simps]: "b \<^bold>* (a \<^bold>* c) = a \<^bold>* (b \<^bold>* c)" |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
57 |
proof - |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63145
diff
changeset
|
58 |
have "(b \<^bold>* a) \<^bold>* c = (a \<^bold>* b) \<^bold>* c" |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
59 |
by (simp only: commute) |
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
60 |
then show ?thesis |
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
61 |
by (simp only: assoc) |
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
62 |
qed |
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
63 |
|
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
64 |
end |
|
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
65 |
|
| 35720 | 66 |
locale monoid = semigroup + |
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63145
diff
changeset
|
67 |
fixes z :: 'a ("\<^bold>1")
|
|
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63145
diff
changeset
|
68 |
assumes left_neutral [simp]: "\<^bold>1 \<^bold>* a = a" |
|
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63145
diff
changeset
|
69 |
assumes right_neutral [simp]: "a \<^bold>* \<^bold>1 = a" |
| 35720 | 70 |
|
71 |
locale comm_monoid = abel_semigroup + |
|
|
63290
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63145
diff
changeset
|
72 |
fixes z :: 'a ("\<^bold>1")
|
|
9ac558ab0906
boldify syntax in abstract algebraic structures, to avoid clashes with concrete syntax in corresponding type classes
haftmann
parents:
63145
diff
changeset
|
73 |
assumes comm_neutral: "a \<^bold>* \<^bold>1 = a" |
| 54868 | 74 |
begin |
| 35720 | 75 |
|
| 54868 | 76 |
sublocale monoid |
| 61169 | 77 |
by standard (simp_all add: commute comm_neutral) |
| 35720 | 78 |
|
| 54868 | 79 |
end |
80 |
||
| 63364 | 81 |
locale group = semigroup + |
82 |
fixes z :: 'a ("\<^bold>1")
|
|
83 |
fixes inverse :: "'a \<Rightarrow> 'a" |
|
84 |
assumes group_left_neutral: "\<^bold>1 \<^bold>* a = a" |
|
85 |
assumes left_inverse [simp]: "inverse a \<^bold>* a = \<^bold>1" |
|
86 |
begin |
|
87 |
||
88 |
lemma left_cancel: "a \<^bold>* b = a \<^bold>* c \<longleftrightarrow> b = c" |
|
89 |
proof |
|
90 |
assume "a \<^bold>* b = a \<^bold>* c" |
|
91 |
then have "inverse a \<^bold>* (a \<^bold>* b) = inverse a \<^bold>* (a \<^bold>* c)" by simp |
|
92 |
then have "(inverse a \<^bold>* a) \<^bold>* b = (inverse a \<^bold>* a) \<^bold>* c" |
|
93 |
by (simp only: assoc) |
|
94 |
then show "b = c" by (simp add: group_left_neutral) |
|
95 |
qed simp |
|
96 |
||
97 |
sublocale monoid |
|
98 |
proof |
|
99 |
fix a |
|
100 |
have "inverse a \<^bold>* a = \<^bold>1" by simp |
|
101 |
then have "inverse a \<^bold>* (a \<^bold>* \<^bold>1) = inverse a \<^bold>* a" |
|
102 |
by (simp add: group_left_neutral assoc [symmetric]) |
|
103 |
with left_cancel show "a \<^bold>* \<^bold>1 = a" |
|
104 |
by (simp only: left_cancel) |
|
105 |
qed (fact group_left_neutral) |
|
106 |
||
107 |
lemma inverse_unique: |
|
108 |
assumes "a \<^bold>* b = \<^bold>1" |
|
109 |
shows "inverse a = b" |
|
110 |
proof - |
|
111 |
from assms have "inverse a \<^bold>* (a \<^bold>* b) = inverse a" |
|
112 |
by simp |
|
113 |
then show ?thesis |
|
114 |
by (simp add: assoc [symmetric]) |
|
115 |
qed |
|
116 |
||
117 |
lemma inverse_neutral [simp]: |
|
118 |
"inverse \<^bold>1 = \<^bold>1" |
|
119 |
by (rule inverse_unique) simp |
|
120 |
||
121 |
lemma inverse_inverse [simp]: |
|
122 |
"inverse (inverse a) = a" |
|
123 |
by (rule inverse_unique) simp |
|
124 |
||
125 |
lemma right_inverse [simp]: |
|
126 |
"a \<^bold>* inverse a = \<^bold>1" |
|
127 |
proof - |
|
128 |
have "a \<^bold>* inverse a = inverse (inverse a) \<^bold>* inverse a" |
|
129 |
by simp |
|
130 |
also have "\<dots> = \<^bold>1" |
|
131 |
by (rule left_inverse) |
|
132 |
then show ?thesis by simp |
|
133 |
qed |
|
134 |
||
135 |
lemma inverse_distrib_swap: |
|
136 |
"inverse (a \<^bold>* b) = inverse b \<^bold>* inverse a" |
|
137 |
proof (rule inverse_unique) |
|
138 |
have "a \<^bold>* b \<^bold>* (inverse b \<^bold>* inverse a) = |
|
139 |
a \<^bold>* (b \<^bold>* inverse b) \<^bold>* inverse a" |
|
140 |
by (simp only: assoc) |
|
141 |
also have "\<dots> = \<^bold>1" |
|
142 |
by simp |
|
143 |
finally show "a \<^bold>* b \<^bold>* (inverse b \<^bold>* inverse a) = \<^bold>1" . |
|
144 |
qed |
|
145 |
||
146 |
lemma right_cancel: |
|
147 |
"b \<^bold>* a = c \<^bold>* a \<longleftrightarrow> b = c" |
|
148 |
proof |
|
149 |
assume "b \<^bold>* a = c \<^bold>* a" |
|
150 |
then have "b \<^bold>* a \<^bold>* inverse a= c \<^bold>* a \<^bold>* inverse a" |
|
151 |
by simp |
|
152 |
then show "b = c" |
|
153 |
by (simp add: assoc) |
|
154 |
qed simp |
|
155 |
||
156 |
end |
|
157 |
||
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
158 |
|
| 60758 | 159 |
subsection \<open>Generic operations\<close> |
|
35267
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
160 |
|
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
161 |
class zero = |
|
35267
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
162 |
fixes zero :: 'a ("0")
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
163 |
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
164 |
class one = |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
165 |
fixes one :: 'a ("1")
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
166 |
|
|
36176
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
35828
diff
changeset
|
167 |
hide_const (open) zero one |
|
35267
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
168 |
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
169 |
lemma Let_0 [simp]: "Let 0 f = f 0" |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
170 |
unfolding Let_def .. |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
171 |
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
172 |
lemma Let_1 [simp]: "Let 1 f = f 1" |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
173 |
unfolding Let_def .. |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
174 |
|
| 60758 | 175 |
setup \<open> |
|
35267
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
176 |
Reorient_Proc.add |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
177 |
(fn Const(@{const_name Groups.zero}, _) => true
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
178 |
| Const(@{const_name Groups.one}, _) => true
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
179 |
| _ => false) |
| 60758 | 180 |
\<close> |
|
35267
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
181 |
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
182 |
simproc_setup reorient_zero ("0 = x") = Reorient_Proc.proc
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
183 |
simproc_setup reorient_one ("1 = x") = Reorient_Proc.proc
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
184 |
|
| 60758 | 185 |
typed_print_translation \<open> |
|
42247
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
wenzelm
parents:
42245
diff
changeset
|
186 |
let |
|
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
wenzelm
parents:
42245
diff
changeset
|
187 |
fun tr' c = (c, fn ctxt => fn T => fn ts => |
|
52210
0226035df99d
more explicit Printer.type_emphasis, depending on show_type_emphasis;
wenzelm
parents:
52143
diff
changeset
|
188 |
if null ts andalso Printer.type_emphasis ctxt T then |
| 42248 | 189 |
Syntax.const @{syntax_const "_constrain"} $ Syntax.const c $
|
|
52210
0226035df99d
more explicit Printer.type_emphasis, depending on show_type_emphasis;
wenzelm
parents:
52143
diff
changeset
|
190 |
Syntax_Phases.term_of_typ ctxt T |
|
0226035df99d
more explicit Printer.type_emphasis, depending on show_type_emphasis;
wenzelm
parents:
52143
diff
changeset
|
191 |
else raise Match); |
|
42247
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
wenzelm
parents:
42245
diff
changeset
|
192 |
in map tr' [@{const_syntax Groups.one}, @{const_syntax Groups.zero}] end;
|
| 61799 | 193 |
\<close> \<comment> \<open>show types that are presumably too general\<close> |
|
35267
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
194 |
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
195 |
class plus = |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
196 |
fixes plus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "+" 65) |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
197 |
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
198 |
class minus = |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
199 |
fixes minus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "-" 65) |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
200 |
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
201 |
class uminus = |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
202 |
fixes uminus :: "'a \<Rightarrow> 'a" ("- _" [81] 80)
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
203 |
|
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
204 |
class times = |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
205 |
fixes times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "*" 70) |
|
8dfd816713c6
moved remaning class operations from Algebras.thy to Groups.thy
haftmann
parents:
35216
diff
changeset
|
206 |
|
|
35092
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
207 |
|
| 60758 | 208 |
subsection \<open>Semigroups and Monoids\<close> |
| 14738 | 209 |
|
| 22390 | 210 |
class semigroup_add = plus + |
|
36348
89c54f51f55a
dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents:
36343
diff
changeset
|
211 |
assumes add_assoc [algebra_simps, field_simps]: "(a + b) + c = a + (b + c)" |
| 54868 | 212 |
begin |
|
34973
ae634fad947e
dropped mk_left_commute; use interpretation of locale abel_semigroup instead
haftmann
parents:
34147
diff
changeset
|
213 |
|
| 61605 | 214 |
sublocale add: semigroup plus |
| 61169 | 215 |
by standard (fact add_assoc) |
| 22390 | 216 |
|
| 54868 | 217 |
end |
218 |
||
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
219 |
hide_fact add_assoc |
|
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
220 |
|
| 22390 | 221 |
class ab_semigroup_add = semigroup_add + |
|
36348
89c54f51f55a
dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents:
36343
diff
changeset
|
222 |
assumes add_commute [algebra_simps, field_simps]: "a + b = b + a" |
| 54868 | 223 |
begin |
|
34973
ae634fad947e
dropped mk_left_commute; use interpretation of locale abel_semigroup instead
haftmann
parents:
34147
diff
changeset
|
224 |
|
| 61605 | 225 |
sublocale add: abel_semigroup plus |
| 61169 | 226 |
by standard (fact add_commute) |
|
34973
ae634fad947e
dropped mk_left_commute; use interpretation of locale abel_semigroup instead
haftmann
parents:
34147
diff
changeset
|
227 |
|
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
228 |
declare add.left_commute [algebra_simps, field_simps] |
| 25062 | 229 |
|
| 61337 | 230 |
lemmas add_ac = add.assoc add.commute add.left_commute |
|
57571
d38a98f496dd
reinstated popular add_ac and mult_ac to avoid needless incompatibilities in user space
nipkow
parents:
57514
diff
changeset
|
231 |
|
| 25062 | 232 |
end |
| 14738 | 233 |
|
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
234 |
hide_fact add_commute |
|
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
235 |
|
| 61337 | 236 |
lemmas add_ac = add.assoc add.commute add.left_commute |
|
57571
d38a98f496dd
reinstated popular add_ac and mult_ac to avoid needless incompatibilities in user space
nipkow
parents:
57514
diff
changeset
|
237 |
|
| 22390 | 238 |
class semigroup_mult = times + |
|
36348
89c54f51f55a
dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents:
36343
diff
changeset
|
239 |
assumes mult_assoc [algebra_simps, field_simps]: "(a * b) * c = a * (b * c)" |
| 54868 | 240 |
begin |
|
34973
ae634fad947e
dropped mk_left_commute; use interpretation of locale abel_semigroup instead
haftmann
parents:
34147
diff
changeset
|
241 |
|
| 61605 | 242 |
sublocale mult: semigroup times |
| 61169 | 243 |
by standard (fact mult_assoc) |
| 14738 | 244 |
|
| 54868 | 245 |
end |
246 |
||
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
247 |
hide_fact mult_assoc |
|
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
248 |
|
| 22390 | 249 |
class ab_semigroup_mult = semigroup_mult + |
|
36348
89c54f51f55a
dropped group_simps, ring_simps, field_eq_simps; classes division_ring_inverse_zero, field_inverse_zero, linordered_field_inverse_zero
haftmann
parents:
36343
diff
changeset
|
250 |
assumes mult_commute [algebra_simps, field_simps]: "a * b = b * a" |
| 54868 | 251 |
begin |
|
34973
ae634fad947e
dropped mk_left_commute; use interpretation of locale abel_semigroup instead
haftmann
parents:
34147
diff
changeset
|
252 |
|
| 61605 | 253 |
sublocale mult: abel_semigroup times |
| 61169 | 254 |
by standard (fact mult_commute) |
|
34973
ae634fad947e
dropped mk_left_commute; use interpretation of locale abel_semigroup instead
haftmann
parents:
34147
diff
changeset
|
255 |
|
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
256 |
declare mult.left_commute [algebra_simps, field_simps] |
| 25062 | 257 |
|
| 61337 | 258 |
lemmas mult_ac = mult.assoc mult.commute mult.left_commute |
|
57571
d38a98f496dd
reinstated popular add_ac and mult_ac to avoid needless incompatibilities in user space
nipkow
parents:
57514
diff
changeset
|
259 |
|
| 23181 | 260 |
end |
| 14738 | 261 |
|
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
262 |
hide_fact mult_commute |
|
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
263 |
|
| 61337 | 264 |
lemmas mult_ac = mult.assoc mult.commute mult.left_commute |
|
57571
d38a98f496dd
reinstated popular add_ac and mult_ac to avoid needless incompatibilities in user space
nipkow
parents:
57514
diff
changeset
|
265 |
|
| 23085 | 266 |
class monoid_add = zero + semigroup_add + |
| 35720 | 267 |
assumes add_0_left: "0 + a = a" |
268 |
and add_0_right: "a + 0 = a" |
|
| 54868 | 269 |
begin |
| 35720 | 270 |
|
| 61605 | 271 |
sublocale add: monoid plus 0 |
| 61169 | 272 |
by standard (fact add_0_left add_0_right)+ |
| 23085 | 273 |
|
| 54868 | 274 |
end |
275 |
||
| 26071 | 276 |
lemma zero_reorient: "0 = x \<longleftrightarrow> x = 0" |
| 54868 | 277 |
by (fact eq_commute) |
| 26071 | 278 |
|
| 22390 | 279 |
class comm_monoid_add = zero + ab_semigroup_add + |
| 25062 | 280 |
assumes add_0: "0 + a = a" |
| 54868 | 281 |
begin |
| 23085 | 282 |
|
|
59559
35da1bbf234e
more canonical order of subscriptions avoids superfluous facts
haftmann
parents:
59557
diff
changeset
|
283 |
subclass monoid_add |
| 61169 | 284 |
by standard (simp_all add: add_0 add.commute [of _ 0]) |
| 25062 | 285 |
|
| 61605 | 286 |
sublocale add: comm_monoid plus 0 |
| 61169 | 287 |
by standard (simp add: ac_simps) |
| 14738 | 288 |
|
| 54868 | 289 |
end |
290 |
||
| 22390 | 291 |
class monoid_mult = one + semigroup_mult + |
| 35720 | 292 |
assumes mult_1_left: "1 * a = a" |
293 |
and mult_1_right: "a * 1 = a" |
|
| 54868 | 294 |
begin |
| 35720 | 295 |
|
| 61605 | 296 |
sublocale mult: monoid times 1 |
| 61169 | 297 |
by standard (fact mult_1_left mult_1_right)+ |
| 14738 | 298 |
|
| 54868 | 299 |
end |
300 |
||
| 26071 | 301 |
lemma one_reorient: "1 = x \<longleftrightarrow> x = 1" |
| 54868 | 302 |
by (fact eq_commute) |
| 26071 | 303 |
|
| 22390 | 304 |
class comm_monoid_mult = one + ab_semigroup_mult + |
| 25062 | 305 |
assumes mult_1: "1 * a = a" |
| 54868 | 306 |
begin |
| 14738 | 307 |
|
|
59559
35da1bbf234e
more canonical order of subscriptions avoids superfluous facts
haftmann
parents:
59557
diff
changeset
|
308 |
subclass monoid_mult |
| 61169 | 309 |
by standard (simp_all add: mult_1 mult.commute [of _ 1]) |
| 25062 | 310 |
|
| 61605 | 311 |
sublocale mult: comm_monoid times 1 |
| 61169 | 312 |
by standard (simp add: ac_simps) |
| 14738 | 313 |
|
| 54868 | 314 |
end |
315 |
||
| 22390 | 316 |
class cancel_semigroup_add = semigroup_add + |
| 25062 | 317 |
assumes add_left_imp_eq: "a + b = a + c \<Longrightarrow> b = c" |
318 |
assumes add_right_imp_eq: "b + a = c + a \<Longrightarrow> b = c" |
|
|
27474
a89d755b029d
move proofs of add_left_cancel and add_right_cancel into the correct locale
huffman
parents:
27250
diff
changeset
|
319 |
begin |
|
a89d755b029d
move proofs of add_left_cancel and add_right_cancel into the correct locale
huffman
parents:
27250
diff
changeset
|
320 |
|
| 63325 | 321 |
lemma add_left_cancel [simp]: "a + b = a + c \<longleftrightarrow> b = c" |
322 |
by (blast dest: add_left_imp_eq) |
|
|
27474
a89d755b029d
move proofs of add_left_cancel and add_right_cancel into the correct locale
huffman
parents:
27250
diff
changeset
|
323 |
|
| 63325 | 324 |
lemma add_right_cancel [simp]: "b + a = c + a \<longleftrightarrow> b = c" |
325 |
by (blast dest: add_right_imp_eq) |
|
|
27474
a89d755b029d
move proofs of add_left_cancel and add_right_cancel into the correct locale
huffman
parents:
27250
diff
changeset
|
326 |
|
|
a89d755b029d
move proofs of add_left_cancel and add_right_cancel into the correct locale
huffman
parents:
27250
diff
changeset
|
327 |
end |
| 14738 | 328 |
|
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
329 |
class cancel_ab_semigroup_add = ab_semigroup_add + minus + |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
330 |
assumes add_diff_cancel_left' [simp]: "(a + b) - a = b" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
331 |
assumes diff_diff_add [algebra_simps, field_simps]: "a - b - c = a - (b + c)" |
| 25267 | 332 |
begin |
| 14738 | 333 |
|
| 63325 | 334 |
lemma add_diff_cancel_right' [simp]: "(a + b) - b = a" |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
335 |
using add_diff_cancel_left' [of b a] by (simp add: ac_simps) |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
336 |
|
| 25267 | 337 |
subclass cancel_semigroup_add |
| 28823 | 338 |
proof |
| 22390 | 339 |
fix a b c :: 'a |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
340 |
assume "a + b = a + c" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
341 |
then have "a + b - a = a + c - a" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
342 |
by simp |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
343 |
then show "b = c" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
344 |
by simp |
| 22390 | 345 |
next |
| 14738 | 346 |
fix a b c :: 'a |
347 |
assume "b + a = c + a" |
|
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
348 |
then have "b + a - a = c + a - a" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
349 |
by simp |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
350 |
then show "b = c" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
351 |
by simp |
| 14738 | 352 |
qed |
353 |
||
| 63325 | 354 |
lemma add_diff_cancel_left [simp]: "(c + a) - (c + b) = a - b" |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
355 |
unfolding diff_diff_add [symmetric] by simp |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
356 |
|
| 63325 | 357 |
lemma add_diff_cancel_right [simp]: "(a + c) - (b + c) = a - b" |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
358 |
using add_diff_cancel_left [symmetric] by (simp add: ac_simps) |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
359 |
|
| 63325 | 360 |
lemma diff_right_commute: "a - c - b = a - b - c" |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
361 |
by (simp add: diff_diff_add add.commute) |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
362 |
|
| 25267 | 363 |
end |
364 |
||
| 29904 | 365 |
class cancel_comm_monoid_add = cancel_ab_semigroup_add + comm_monoid_add |
| 59322 | 366 |
begin |
367 |
||
| 63325 | 368 |
lemma diff_zero [simp]: "a - 0 = a" |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
369 |
using add_diff_cancel_right' [of a 0] by simp |
| 59322 | 370 |
|
| 63325 | 371 |
lemma diff_cancel [simp]: "a - a = 0" |
| 59322 | 372 |
proof - |
| 63325 | 373 |
have "(a + 0) - (a + 0) = 0" |
374 |
by (simp only: add_diff_cancel_left diff_zero) |
|
| 59322 | 375 |
then show ?thesis by simp |
376 |
qed |
|
377 |
||
378 |
lemma add_implies_diff: |
|
379 |
assumes "c + b = a" |
|
380 |
shows "c = a - b" |
|
381 |
proof - |
|
| 63325 | 382 |
from assms have "(b + c) - (b + 0) = a - b" |
383 |
by (simp add: add.commute) |
|
| 59322 | 384 |
then show "c = a - b" by simp |
385 |
qed |
|
386 |
||
| 63325 | 387 |
lemma add_cancel_right_right [simp]: "a = a + b \<longleftrightarrow> b = 0" |
388 |
(is "?P \<longleftrightarrow> ?Q") |
|
| 62608 | 389 |
proof |
| 63325 | 390 |
assume ?Q |
391 |
then show ?P by simp |
|
| 62608 | 392 |
next |
| 63325 | 393 |
assume ?P |
394 |
then have "a - a = a + b - a" by simp |
|
| 62608 | 395 |
then show ?Q by simp |
396 |
qed |
|
397 |
||
| 63325 | 398 |
lemma add_cancel_right_left [simp]: "a = b + a \<longleftrightarrow> b = 0" |
| 62608 | 399 |
using add_cancel_right_right [of a b] by (simp add: ac_simps) |
400 |
||
| 63325 | 401 |
lemma add_cancel_left_right [simp]: "a + b = a \<longleftrightarrow> b = 0" |
| 62608 | 402 |
by (auto dest: sym) |
403 |
||
| 63325 | 404 |
lemma add_cancel_left_left [simp]: "b + a = a \<longleftrightarrow> b = 0" |
| 62608 | 405 |
by (auto dest: sym) |
406 |
||
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
407 |
end |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
408 |
|
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
409 |
class comm_monoid_diff = cancel_comm_monoid_add + |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
410 |
assumes zero_diff [simp]: "0 - a = 0" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
411 |
begin |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
412 |
|
| 63325 | 413 |
lemma diff_add_zero [simp]: "a - (a + b) = 0" |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
414 |
proof - |
| 63325 | 415 |
have "a - (a + b) = (a + 0) - (a + b)" |
416 |
by simp |
|
417 |
also have "\<dots> = 0" |
|
418 |
by (simp only: add_diff_cancel_left zero_diff) |
|
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
419 |
finally show ?thesis . |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
420 |
qed |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
421 |
|
| 59322 | 422 |
end |
423 |
||
| 29904 | 424 |
|
| 60758 | 425 |
subsection \<open>Groups\<close> |
| 23085 | 426 |
|
| 25762 | 427 |
class group_add = minus + uminus + monoid_add + |
| 63364 | 428 |
assumes left_minus: "- a + a = 0" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
429 |
assumes add_uminus_conv_diff [simp]: "a + (- b) = a - b" |
| 25062 | 430 |
begin |
| 23085 | 431 |
|
| 63325 | 432 |
lemma diff_conv_add_uminus: "a - b = a + (- b)" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
433 |
by simp |
|
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
434 |
|
| 63364 | 435 |
sublocale add: group plus 0 uminus |
436 |
by standard (simp_all add: left_minus) |
|
437 |
||
|
34147
319616f4eecf
generalize lemma add_minus_cancel, add lemma minus_add, simplify some proofs
huffman
parents:
34146
diff
changeset
|
438 |
lemma minus_unique: |
| 63325 | 439 |
assumes "a + b = 0" |
440 |
shows "- a = b" |
|
| 63364 | 441 |
using assms by (fact add.inverse_unique) |
|
34147
319616f4eecf
generalize lemma add_minus_cancel, add lemma minus_add, simplify some proofs
huffman
parents:
34146
diff
changeset
|
442 |
|
| 63364 | 443 |
lemma minus_zero: "- 0 = 0" |
444 |
by (fact add.inverse_neutral) |
|
| 14738 | 445 |
|
| 63364 | 446 |
lemma minus_minus: "- (- a) = a" |
447 |
by (fact add.inverse_inverse) |
|
| 14738 | 448 |
|
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
449 |
lemma right_minus: "a + - a = 0" |
| 63364 | 450 |
by (fact add.right_inverse) |
| 14738 | 451 |
|
| 63325 | 452 |
lemma diff_self [simp]: "a - a = 0" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
453 |
using right_minus [of a] by simp |
|
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
454 |
|
|
40368
47c186c8577d
added class relation group_add < cancel_semigroup_add
haftmann
parents:
39134
diff
changeset
|
455 |
subclass cancel_semigroup_add |
| 63364 | 456 |
by standard (simp_all add: add.left_cancel add.right_cancel) |
|
40368
47c186c8577d
added class relation group_add < cancel_semigroup_add
haftmann
parents:
39134
diff
changeset
|
457 |
|
| 63325 | 458 |
lemma minus_add_cancel [simp]: "- a + (a + b) = b" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
459 |
by (simp add: add.assoc [symmetric]) |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
460 |
|
| 63325 | 461 |
lemma add_minus_cancel [simp]: "a + (- a + b) = b" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
462 |
by (simp add: add.assoc [symmetric]) |
|
34147
319616f4eecf
generalize lemma add_minus_cancel, add lemma minus_add, simplify some proofs
huffman
parents:
34146
diff
changeset
|
463 |
|
| 63325 | 464 |
lemma diff_add_cancel [simp]: "a - b + b = a" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
465 |
by (simp only: diff_conv_add_uminus add.assoc) simp |
|
34147
319616f4eecf
generalize lemma add_minus_cancel, add lemma minus_add, simplify some proofs
huffman
parents:
34146
diff
changeset
|
466 |
|
| 63325 | 467 |
lemma add_diff_cancel [simp]: "a + b - b = a" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
468 |
by (simp only: diff_conv_add_uminus add.assoc) simp |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
469 |
|
| 63325 | 470 |
lemma minus_add: "- (a + b) = - b + - a" |
| 63364 | 471 |
by (fact add.inverse_distrib_swap) |
|
34147
319616f4eecf
generalize lemma add_minus_cancel, add lemma minus_add, simplify some proofs
huffman
parents:
34146
diff
changeset
|
472 |
|
| 63325 | 473 |
lemma right_minus_eq [simp]: "a - b = 0 \<longleftrightarrow> a = b" |
| 14738 | 474 |
proof |
| 23085 | 475 |
assume "a - b = 0" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
476 |
have "a = (a - b) + b" by (simp add: add.assoc) |
| 60758 | 477 |
also have "\<dots> = b" using \<open>a - b = 0\<close> by simp |
| 23085 | 478 |
finally show "a = b" . |
| 14738 | 479 |
next |
| 63325 | 480 |
assume "a = b" |
481 |
then show "a - b = 0" by simp |
|
| 14738 | 482 |
qed |
483 |
||
| 63325 | 484 |
lemma eq_iff_diff_eq_0: "a = b \<longleftrightarrow> a - b = 0" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
485 |
by (fact right_minus_eq [symmetric]) |
| 14738 | 486 |
|
| 63325 | 487 |
lemma diff_0 [simp]: "0 - a = - a" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
488 |
by (simp only: diff_conv_add_uminus add_0_left) |
| 14738 | 489 |
|
| 63325 | 490 |
lemma diff_0_right [simp]: "a - 0 = a" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
491 |
by (simp only: diff_conv_add_uminus minus_zero add_0_right) |
| 14738 | 492 |
|
| 63325 | 493 |
lemma diff_minus_eq_add [simp]: "a - - b = a + b" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
494 |
by (simp only: diff_conv_add_uminus minus_minus) |
| 14738 | 495 |
|
| 63325 | 496 |
lemma neg_equal_iff_equal [simp]: "- a = - b \<longleftrightarrow> a = b" |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
497 |
proof |
| 14738 | 498 |
assume "- a = - b" |
| 63325 | 499 |
then have "- (- a) = - (- b)" by simp |
500 |
then show "a = b" by simp |
|
| 14738 | 501 |
next |
| 25062 | 502 |
assume "a = b" |
| 63325 | 503 |
then show "- a = - b" by simp |
| 14738 | 504 |
qed |
505 |
||
| 63325 | 506 |
lemma neg_equal_0_iff_equal [simp]: "- a = 0 \<longleftrightarrow> a = 0" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
507 |
by (subst neg_equal_iff_equal [symmetric]) simp |
| 14738 | 508 |
|
| 63325 | 509 |
lemma neg_0_equal_iff_equal [simp]: "0 = - a \<longleftrightarrow> 0 = a" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
510 |
by (subst neg_equal_iff_equal [symmetric]) simp |
| 14738 | 511 |
|
| 63325 | 512 |
text \<open>The next two equations can make the simplifier loop!\<close> |
| 14738 | 513 |
|
| 63325 | 514 |
lemma equation_minus_iff: "a = - b \<longleftrightarrow> b = - a" |
| 14738 | 515 |
proof - |
| 63325 | 516 |
have "- (- a) = - b \<longleftrightarrow> - a = b" |
517 |
by (rule neg_equal_iff_equal) |
|
518 |
then show ?thesis |
|
519 |
by (simp add: eq_commute) |
|
| 25062 | 520 |
qed |
521 |
||
| 63325 | 522 |
lemma minus_equation_iff: "- a = b \<longleftrightarrow> - b = a" |
| 25062 | 523 |
proof - |
| 63325 | 524 |
have "- a = - (- b) \<longleftrightarrow> a = -b" |
525 |
by (rule neg_equal_iff_equal) |
|
526 |
then show ?thesis |
|
527 |
by (simp add: eq_commute) |
|
| 14738 | 528 |
qed |
529 |
||
| 63325 | 530 |
lemma eq_neg_iff_add_eq_0: "a = - b \<longleftrightarrow> a + b = 0" |
|
29914
c9ced4f54e82
generalize lemma eq_neg_iff_add_eq_0, and move to OrderedGroup
huffman
parents:
29904
diff
changeset
|
531 |
proof |
| 63325 | 532 |
assume "a = - b" |
533 |
then show "a + b = 0" by simp |
|
|
29914
c9ced4f54e82
generalize lemma eq_neg_iff_add_eq_0, and move to OrderedGroup
huffman
parents:
29904
diff
changeset
|
534 |
next |
|
c9ced4f54e82
generalize lemma eq_neg_iff_add_eq_0, and move to OrderedGroup
huffman
parents:
29904
diff
changeset
|
535 |
assume "a + b = 0" |
|
c9ced4f54e82
generalize lemma eq_neg_iff_add_eq_0, and move to OrderedGroup
huffman
parents:
29904
diff
changeset
|
536 |
moreover have "a + (b + - b) = (a + b) + - b" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
537 |
by (simp only: add.assoc) |
| 63325 | 538 |
ultimately show "a = - b" |
539 |
by simp |
|
|
29914
c9ced4f54e82
generalize lemma eq_neg_iff_add_eq_0, and move to OrderedGroup
huffman
parents:
29904
diff
changeset
|
540 |
qed |
|
c9ced4f54e82
generalize lemma eq_neg_iff_add_eq_0, and move to OrderedGroup
huffman
parents:
29904
diff
changeset
|
541 |
|
| 63325 | 542 |
lemma add_eq_0_iff2: "a + b = 0 \<longleftrightarrow> a = - b" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
543 |
by (fact eq_neg_iff_add_eq_0 [symmetric]) |
|
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
544 |
|
| 63325 | 545 |
lemma neg_eq_iff_add_eq_0: "- a = b \<longleftrightarrow> a + b = 0" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
546 |
by (auto simp add: add_eq_0_iff2) |
| 44348 | 547 |
|
| 63325 | 548 |
lemma add_eq_0_iff: "a + b = 0 \<longleftrightarrow> b = - a" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
549 |
by (auto simp add: neg_eq_iff_add_eq_0 [symmetric]) |
|
45548
3e2722d66169
Groups.thy: generalize several lemmas from class ab_group_add to class group_add
huffman
parents:
45294
diff
changeset
|
550 |
|
| 63325 | 551 |
lemma minus_diff_eq [simp]: "- (a - b) = b - a" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
552 |
by (simp only: neg_eq_iff_add_eq_0 diff_conv_add_uminus add.assoc minus_add_cancel) simp |
|
45548
3e2722d66169
Groups.thy: generalize several lemmas from class ab_group_add to class group_add
huffman
parents:
45294
diff
changeset
|
553 |
|
| 63325 | 554 |
lemma add_diff_eq [algebra_simps, field_simps]: "a + (b - c) = (a + b) - c" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
555 |
by (simp only: diff_conv_add_uminus add.assoc) |
|
45548
3e2722d66169
Groups.thy: generalize several lemmas from class ab_group_add to class group_add
huffman
parents:
45294
diff
changeset
|
556 |
|
| 63325 | 557 |
lemma diff_add_eq_diff_diff_swap: "a - (b + c) = a - c - b" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
558 |
by (simp only: diff_conv_add_uminus add.assoc minus_add) |
|
45548
3e2722d66169
Groups.thy: generalize several lemmas from class ab_group_add to class group_add
huffman
parents:
45294
diff
changeset
|
559 |
|
| 63325 | 560 |
lemma diff_eq_eq [algebra_simps, field_simps]: "a - b = c \<longleftrightarrow> a = c + b" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
561 |
by auto |
|
45548
3e2722d66169
Groups.thy: generalize several lemmas from class ab_group_add to class group_add
huffman
parents:
45294
diff
changeset
|
562 |
|
| 63325 | 563 |
lemma eq_diff_eq [algebra_simps, field_simps]: "a = c - b \<longleftrightarrow> a + b = c" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
564 |
by auto |
|
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
565 |
|
| 63325 | 566 |
lemma diff_diff_eq2 [algebra_simps, field_simps]: "a - (b - c) = (a + c) - b" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
567 |
by (simp only: diff_conv_add_uminus add.assoc) simp |
|
45548
3e2722d66169
Groups.thy: generalize several lemmas from class ab_group_add to class group_add
huffman
parents:
45294
diff
changeset
|
568 |
|
| 63325 | 569 |
lemma diff_eq_diff_eq: "a - b = c - d \<Longrightarrow> a = b \<longleftrightarrow> c = d" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
570 |
by (simp only: eq_iff_diff_eq_0 [of a b] eq_iff_diff_eq_0 [of c d]) |
|
45548
3e2722d66169
Groups.thy: generalize several lemmas from class ab_group_add to class group_add
huffman
parents:
45294
diff
changeset
|
571 |
|
| 25062 | 572 |
end |
573 |
||
| 25762 | 574 |
class ab_group_add = minus + uminus + comm_monoid_add + |
| 25062 | 575 |
assumes ab_left_minus: "- a + a = 0" |
| 59557 | 576 |
assumes ab_diff_conv_add_uminus: "a - b = a + (- b)" |
| 25267 | 577 |
begin |
| 25062 | 578 |
|
| 25267 | 579 |
subclass group_add |
| 63325 | 580 |
by standard (simp_all add: ab_left_minus ab_diff_conv_add_uminus) |
| 25062 | 581 |
|
| 29904 | 582 |
subclass cancel_comm_monoid_add |
| 28823 | 583 |
proof |
| 25062 | 584 |
fix a b c :: 'a |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
585 |
have "b + a - a = b" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
586 |
by simp |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
587 |
then show "a + b - a = b" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
588 |
by (simp add: ac_simps) |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
589 |
show "a - b - c = a - (b + c)" |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
590 |
by (simp add: algebra_simps) |
| 25062 | 591 |
qed |
592 |
||
| 63325 | 593 |
lemma uminus_add_conv_diff [simp]: "- a + b = b - a" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
594 |
by (simp add: add.commute) |
| 25062 | 595 |
|
| 63325 | 596 |
lemma minus_add_distrib [simp]: "- (a + b) = - a + - b" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
597 |
by (simp add: algebra_simps) |
| 25062 | 598 |
|
| 63325 | 599 |
lemma diff_add_eq [algebra_simps, field_simps]: "(a - b) + c = (a + c) - b" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
600 |
by (simp add: algebra_simps) |
| 25077 | 601 |
|
| 25062 | 602 |
end |
| 14738 | 603 |
|
|
37884
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
604 |
|
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
605 |
subsection \<open>(Partially) Ordered Groups\<close> |
| 14738 | 606 |
|
| 60758 | 607 |
text \<open> |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
608 |
The theory of partially ordered groups is taken from the books: |
| 63325 | 609 |
|
610 |
\<^item> \<^emph>\<open>Lattice Theory\<close> by Garret Birkhoff, American Mathematical Society, 1979 |
|
611 |
\<^item> \<^emph>\<open>Partially Ordered Algebraic Systems\<close>, Pergamon Press, 1963 |
|
612 |
||
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
613 |
Most of the used notions can also be looked up in |
| 63325 | 614 |
\<^item> @{url "http://www.mathworld.com"} by Eric Weisstein et. al.
|
615 |
\<^item> \<^emph>\<open>Algebra I\<close> by van der Waerden, Springer |
|
| 60758 | 616 |
\<close> |
|
35301
90e42f9ba4d1
distributed theory Algebras to theories Groups and Lattices
haftmann
parents:
35267
diff
changeset
|
617 |
|
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
618 |
class ordered_ab_semigroup_add = order + ab_semigroup_add + |
| 25062 | 619 |
assumes add_left_mono: "a \<le> b \<Longrightarrow> c + a \<le> c + b" |
620 |
begin |
|
|
24380
c215e256beca
moved ordered_ab_semigroup_add to OrderedGroup.thy
haftmann
parents:
24286
diff
changeset
|
621 |
|
| 63325 | 622 |
lemma add_right_mono: "a \<le> b \<Longrightarrow> a + c \<le> b + c" |
623 |
by (simp add: add.commute [of _ c] add_left_mono) |
|
| 14738 | 624 |
|
| 60758 | 625 |
text \<open>non-strict, in both arguments\<close> |
| 63325 | 626 |
lemma add_mono: "a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c \<le> b + d" |
| 14738 | 627 |
apply (erule add_right_mono [THEN order_trans]) |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
628 |
apply (simp add: add.commute add_left_mono) |
| 14738 | 629 |
done |
630 |
||
| 25062 | 631 |
end |
632 |
||
| 63325 | 633 |
text \<open>Strict monotonicity in both arguments\<close> |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
634 |
class strict_ordered_ab_semigroup_add = ordered_ab_semigroup_add + |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
635 |
assumes add_strict_mono: "a < b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
636 |
|
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
637 |
class ordered_cancel_ab_semigroup_add = |
|
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
638 |
ordered_ab_semigroup_add + cancel_ab_semigroup_add |
| 25062 | 639 |
begin |
640 |
||
| 63325 | 641 |
lemma add_strict_left_mono: "a < b \<Longrightarrow> c + a < c + b" |
642 |
by (auto simp add: less_le add_left_mono) |
|
| 14738 | 643 |
|
| 63325 | 644 |
lemma add_strict_right_mono: "a < b \<Longrightarrow> a + c < b + c" |
645 |
by (simp add: add.commute [of _ c] add_strict_left_mono) |
|
| 14738 | 646 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
647 |
subclass strict_ordered_ab_semigroup_add |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
648 |
apply standard |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
649 |
apply (erule add_strict_right_mono [THEN less_trans]) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
650 |
apply (erule add_strict_left_mono) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
651 |
done |
| 14738 | 652 |
|
| 63325 | 653 |
lemma add_less_le_mono: "a < b \<Longrightarrow> c \<le> d \<Longrightarrow> a + c < b + d" |
654 |
apply (erule add_strict_right_mono [THEN less_le_trans]) |
|
655 |
apply (erule add_left_mono) |
|
656 |
done |
|
| 14738 | 657 |
|
| 63325 | 658 |
lemma add_le_less_mono: "a \<le> b \<Longrightarrow> c < d \<Longrightarrow> a + c < b + d" |
659 |
apply (erule add_right_mono [THEN le_less_trans]) |
|
660 |
apply (erule add_strict_left_mono) |
|
661 |
done |
|
| 14738 | 662 |
|
| 25062 | 663 |
end |
664 |
||
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
665 |
class ordered_ab_semigroup_add_imp_le = ordered_cancel_ab_semigroup_add + |
| 25062 | 666 |
assumes add_le_imp_le_left: "c + a \<le> c + b \<Longrightarrow> a \<le> b" |
667 |
begin |
|
668 |
||
| 14738 | 669 |
lemma add_less_imp_less_left: |
| 63325 | 670 |
assumes less: "c + a < c + b" |
671 |
shows "a < b" |
|
| 14738 | 672 |
proof - |
| 63325 | 673 |
from less have le: "c + a \<le> c + b" |
674 |
by (simp add: order_le_less) |
|
675 |
have "a \<le> b" |
|
| 14738 | 676 |
apply (insert le) |
677 |
apply (drule add_le_imp_le_left) |
|
| 63325 | 678 |
apply (insert le) |
679 |
apply (drule add_le_imp_le_left) |
|
680 |
apply assumption |
|
681 |
done |
|
| 14738 | 682 |
moreover have "a \<noteq> b" |
683 |
proof (rule ccontr) |
|
| 63325 | 684 |
assume "\<not> ?thesis" |
| 14738 | 685 |
then have "a = b" by simp |
686 |
then have "c + a = c + b" by simp |
|
| 63325 | 687 |
with less show "False" by simp |
| 14738 | 688 |
qed |
| 63325 | 689 |
ultimately show "a < b" |
690 |
by (simp add: order_le_less) |
|
| 14738 | 691 |
qed |
692 |
||
| 63325 | 693 |
lemma add_less_imp_less_right: "a + c < b + c \<Longrightarrow> a < b" |
694 |
by (rule add_less_imp_less_left [of c]) (simp add: add.commute) |
|
| 14738 | 695 |
|
| 63325 | 696 |
lemma add_less_cancel_left [simp]: "c + a < c + b \<longleftrightarrow> a < b" |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
697 |
by (blast intro: add_less_imp_less_left add_strict_left_mono) |
| 14738 | 698 |
|
| 63325 | 699 |
lemma add_less_cancel_right [simp]: "a + c < b + c \<longleftrightarrow> a < b" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
700 |
by (blast intro: add_less_imp_less_right add_strict_right_mono) |
| 14738 | 701 |
|
| 63325 | 702 |
lemma add_le_cancel_left [simp]: "c + a \<le> c + b \<longleftrightarrow> a \<le> b" |
703 |
apply auto |
|
704 |
apply (drule add_le_imp_le_left) |
|
705 |
apply (simp_all add: add_left_mono) |
|
706 |
done |
|
| 14738 | 707 |
|
| 63325 | 708 |
lemma add_le_cancel_right [simp]: "a + c \<le> b + c \<longleftrightarrow> a \<le> b" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56950
diff
changeset
|
709 |
by (simp add: add.commute [of a c] add.commute [of b c]) |
| 14738 | 710 |
|
| 63325 | 711 |
lemma add_le_imp_le_right: "a + c \<le> b + c \<Longrightarrow> a \<le> b" |
712 |
by simp |
|
| 25062 | 713 |
|
| 63325 | 714 |
lemma max_add_distrib_left: "max x y + z = max (x + z) (y + z)" |
| 25077 | 715 |
unfolding max_def by auto |
716 |
||
| 63325 | 717 |
lemma min_add_distrib_left: "min x y + z = min (x + z) (y + z)" |
| 25077 | 718 |
unfolding min_def by auto |
719 |
||
| 63325 | 720 |
lemma max_add_distrib_right: "x + max y z = max (x + y) (x + z)" |
|
44848
f4d0b060c7ca
remove lemmas nat_add_min_{left,right} in favor of generic lemmas min_add_distrib_{left,right}
huffman
parents:
44433
diff
changeset
|
721 |
unfolding max_def by auto |
|
f4d0b060c7ca
remove lemmas nat_add_min_{left,right} in favor of generic lemmas min_add_distrib_{left,right}
huffman
parents:
44433
diff
changeset
|
722 |
|
| 63325 | 723 |
lemma min_add_distrib_right: "x + min y z = min (x + y) (x + z)" |
|
44848
f4d0b060c7ca
remove lemmas nat_add_min_{left,right} in favor of generic lemmas min_add_distrib_{left,right}
huffman
parents:
44433
diff
changeset
|
724 |
unfolding min_def by auto |
|
f4d0b060c7ca
remove lemmas nat_add_min_{left,right} in favor of generic lemmas min_add_distrib_{left,right}
huffman
parents:
44433
diff
changeset
|
725 |
|
| 25062 | 726 |
end |
727 |
||
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
728 |
subsection \<open>Support for reasoning about signs\<close> |
|
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
729 |
|
|
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
730 |
class ordered_comm_monoid_add = comm_monoid_add + ordered_ab_semigroup_add |
|
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
731 |
begin |
|
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
732 |
|
| 63325 | 733 |
lemma add_nonneg_nonneg [simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
734 |
using add_mono[of 0 a 0 b] by simp |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
735 |
|
| 63325 | 736 |
lemma add_nonpos_nonpos: "a \<le> 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> a + b \<le> 0" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
737 |
using add_mono[of a 0 b 0] by simp |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
738 |
|
| 63325 | 739 |
lemma add_nonneg_eq_0_iff: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
740 |
using add_left_mono[of 0 y x] add_right_mono[of 0 x y] by auto |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
741 |
|
| 63325 | 742 |
lemma add_nonpos_eq_0_iff: "x \<le> 0 \<Longrightarrow> y \<le> 0 \<Longrightarrow> x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
743 |
using add_left_mono[of y 0 x] add_right_mono[of x 0 y] by auto |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
744 |
|
| 63325 | 745 |
lemma add_increasing: "0 \<le> a \<Longrightarrow> b \<le> c \<Longrightarrow> b \<le> a + c" |
746 |
using add_mono [of 0 a b c] by simp |
|
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
747 |
|
| 63325 | 748 |
lemma add_increasing2: "0 \<le> c \<Longrightarrow> b \<le> a \<Longrightarrow> b \<le> a + c" |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
749 |
by (simp add: add_increasing add.commute [of a]) |
|
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
750 |
|
| 63325 | 751 |
lemma add_decreasing: "a \<le> 0 \<Longrightarrow> c \<le> b \<Longrightarrow> a + c \<le> b" |
752 |
using add_mono [of a 0 c b] by simp |
|
| 52289 | 753 |
|
| 63325 | 754 |
lemma add_decreasing2: "c \<le> 0 \<Longrightarrow> a \<le> b \<Longrightarrow> a + c \<le> b" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
755 |
using add_mono[of a b c 0] by simp |
| 52289 | 756 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
757 |
lemma add_pos_nonneg: "0 < a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 < a + b" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
758 |
using less_le_trans[of 0 a "a + b"] by (simp add: add_increasing2) |
| 52289 | 759 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
760 |
lemma add_pos_pos: "0 < a \<Longrightarrow> 0 < b \<Longrightarrow> 0 < a + b" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
761 |
by (intro add_pos_nonneg less_imp_le) |
| 52289 | 762 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
763 |
lemma add_nonneg_pos: "0 \<le> a \<Longrightarrow> 0 < b \<Longrightarrow> 0 < a + b" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
764 |
using add_pos_nonneg[of b a] by (simp add: add_commute) |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
765 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
766 |
lemma add_neg_nonpos: "a < 0 \<Longrightarrow> b \<le> 0 \<Longrightarrow> a + b < 0" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
767 |
using le_less_trans[of "a + b" a 0] by (simp add: add_decreasing2) |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
768 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
769 |
lemma add_neg_neg: "a < 0 \<Longrightarrow> b < 0 \<Longrightarrow> a + b < 0" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
770 |
by (intro add_neg_nonpos less_imp_le) |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
771 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
772 |
lemma add_nonpos_neg: "a \<le> 0 \<Longrightarrow> b < 0 \<Longrightarrow> a + b < 0" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
773 |
using add_neg_nonpos[of b a] by (simp add: add_commute) |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
774 |
|
| 30691 | 775 |
lemmas add_sign_intros = |
776 |
add_pos_nonneg add_pos_pos add_nonneg_pos add_nonneg_nonneg |
|
777 |
add_neg_nonpos add_neg_neg add_nonpos_neg add_nonpos_nonpos |
|
778 |
||
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
779 |
end |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
780 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
781 |
class strict_ordered_comm_monoid_add = comm_monoid_add + strict_ordered_ab_semigroup_add |
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
782 |
begin |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
783 |
|
| 63325 | 784 |
lemma pos_add_strict: "0 < a \<Longrightarrow> b < c \<Longrightarrow> b < a + c" |
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
785 |
using add_strict_mono [of 0 a b c] by simp |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
786 |
|
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
787 |
end |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
788 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
789 |
class ordered_cancel_comm_monoid_add = ordered_comm_monoid_add + cancel_ab_semigroup_add |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
790 |
begin |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
791 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
792 |
subclass ordered_cancel_ab_semigroup_add .. |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
793 |
subclass strict_ordered_comm_monoid_add .. |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
794 |
|
| 63325 | 795 |
lemma add_strict_increasing: "0 < a \<Longrightarrow> b \<le> c \<Longrightarrow> b < a + c" |
796 |
using add_less_le_mono [of 0 a b c] by simp |
|
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
797 |
|
| 63325 | 798 |
lemma add_strict_increasing2: "0 \<le> a \<Longrightarrow> b < c \<Longrightarrow> b < a + c" |
799 |
using add_le_less_mono [of 0 a b c] by simp |
|
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
800 |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
801 |
end |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
802 |
|
|
63456
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
803 |
class ordered_ab_semigroup_monoid_add_imp_le = monoid_add + ordered_ab_semigroup_add_imp_le |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
804 |
begin |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
805 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
806 |
lemma add_less_same_cancel1 [simp]: |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
807 |
"b + a < b \<longleftrightarrow> a < 0" |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
808 |
using add_less_cancel_left [of _ _ 0] by simp |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
809 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
810 |
lemma add_less_same_cancel2 [simp]: |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
811 |
"a + b < b \<longleftrightarrow> a < 0" |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
812 |
using add_less_cancel_right [of _ _ 0] by simp |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
813 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
814 |
lemma less_add_same_cancel1 [simp]: |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
815 |
"a < a + b \<longleftrightarrow> 0 < b" |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
816 |
using add_less_cancel_left [of _ 0] by simp |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
817 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
818 |
lemma less_add_same_cancel2 [simp]: |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
819 |
"a < b + a \<longleftrightarrow> 0 < b" |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
820 |
using add_less_cancel_right [of 0] by simp |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
821 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
822 |
lemma add_le_same_cancel1 [simp]: |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
823 |
"b + a \<le> b \<longleftrightarrow> a \<le> 0" |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
824 |
using add_le_cancel_left [of _ _ 0] by simp |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
825 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
826 |
lemma add_le_same_cancel2 [simp]: |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
827 |
"a + b \<le> b \<longleftrightarrow> a \<le> 0" |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
828 |
using add_le_cancel_right [of _ _ 0] by simp |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
829 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
830 |
lemma le_add_same_cancel1 [simp]: |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
831 |
"a \<le> a + b \<longleftrightarrow> 0 \<le> b" |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
832 |
using add_le_cancel_left [of _ 0] by simp |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
833 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
834 |
lemma le_add_same_cancel2 [simp]: |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
835 |
"a \<le> b + a \<longleftrightarrow> 0 \<le> b" |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
836 |
using add_le_cancel_right [of 0] by simp |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
837 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
838 |
subclass cancel_comm_monoid_add |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
839 |
by standard auto |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
840 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
841 |
subclass ordered_cancel_comm_monoid_add |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
842 |
by standard |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
843 |
|
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
844 |
end |
|
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
845 |
|
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
846 |
class ordered_ab_group_add = ab_group_add + ordered_ab_semigroup_add |
| 25062 | 847 |
begin |
848 |
||
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
849 |
subclass ordered_cancel_ab_semigroup_add .. |
| 25062 | 850 |
|
|
63456
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63364
diff
changeset
|
851 |
subclass ordered_ab_semigroup_monoid_add_imp_le |
| 28823 | 852 |
proof |
| 25062 | 853 |
fix a b c :: 'a |
854 |
assume "c + a \<le> c + b" |
|
| 63325 | 855 |
then have "(-c) + (c + a) \<le> (-c) + (c + b)" |
856 |
by (rule add_left_mono) |
|
857 |
then have "((-c) + c) + a \<le> ((-c) + c) + b" |
|
858 |
by (simp only: add.assoc) |
|
859 |
then show "a \<le> b" by simp |
|
| 25062 | 860 |
qed |
861 |
||
| 63325 | 862 |
lemma max_diff_distrib_left: "max x y - z = max (x - z) (y - z)" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
863 |
using max_add_distrib_left [of x y "- z"] by simp |
| 25077 | 864 |
|
| 63325 | 865 |
lemma min_diff_distrib_left: "min x y - z = min (x - z) (y - z)" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
866 |
using min_add_distrib_left [of x y "- z"] by simp |
| 25077 | 867 |
|
868 |
lemma le_imp_neg_le: |
|
| 63325 | 869 |
assumes "a \<le> b" |
870 |
shows "- b \<le> - a" |
|
| 25077 | 871 |
proof - |
| 63325 | 872 |
from assms have "- a + a \<le> - a + b" |
873 |
by (rule add_left_mono) |
|
874 |
then have "0 \<le> - a + b" |
|
875 |
by simp |
|
876 |
then have "0 + (- b) \<le> (- a + b) + (- b)" |
|
877 |
by (rule add_right_mono) |
|
878 |
then show ?thesis |
|
879 |
by (simp add: algebra_simps) |
|
| 25077 | 880 |
qed |
881 |
||
882 |
lemma neg_le_iff_le [simp]: "- b \<le> - a \<longleftrightarrow> a \<le> b" |
|
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
883 |
proof |
| 25077 | 884 |
assume "- b \<le> - a" |
| 63325 | 885 |
then have "- (- a) \<le> - (- b)" |
886 |
by (rule le_imp_neg_le) |
|
887 |
then show "a \<le> b" |
|
888 |
by simp |
|
| 25077 | 889 |
next |
| 63325 | 890 |
assume "a \<le> b" |
891 |
then show "- b \<le> - a" |
|
892 |
by (rule le_imp_neg_le) |
|
| 25077 | 893 |
qed |
894 |
||
895 |
lemma neg_le_0_iff_le [simp]: "- a \<le> 0 \<longleftrightarrow> 0 \<le> a" |
|
| 63325 | 896 |
by (subst neg_le_iff_le [symmetric]) simp |
| 25077 | 897 |
|
898 |
lemma neg_0_le_iff_le [simp]: "0 \<le> - a \<longleftrightarrow> a \<le> 0" |
|
| 63325 | 899 |
by (subst neg_le_iff_le [symmetric]) simp |
| 25077 | 900 |
|
901 |
lemma neg_less_iff_less [simp]: "- b < - a \<longleftrightarrow> a < b" |
|
| 63325 | 902 |
by (auto simp add: less_le) |
| 25077 | 903 |
|
904 |
lemma neg_less_0_iff_less [simp]: "- a < 0 \<longleftrightarrow> 0 < a" |
|
| 63325 | 905 |
by (subst neg_less_iff_less [symmetric]) simp |
| 25077 | 906 |
|
907 |
lemma neg_0_less_iff_less [simp]: "0 < - a \<longleftrightarrow> a < 0" |
|
| 63325 | 908 |
by (subst neg_less_iff_less [symmetric]) simp |
| 25077 | 909 |
|
| 63325 | 910 |
text \<open>The next several equations can make the simplifier loop!\<close> |
| 25077 | 911 |
|
912 |
lemma less_minus_iff: "a < - b \<longleftrightarrow> b < - a" |
|
913 |
proof - |
|
| 63325 | 914 |
have "- (-a) < - b \<longleftrightarrow> b < - a" |
915 |
by (rule neg_less_iff_less) |
|
916 |
then show ?thesis by simp |
|
| 25077 | 917 |
qed |
918 |
||
919 |
lemma minus_less_iff: "- a < b \<longleftrightarrow> - b < a" |
|
920 |
proof - |
|
| 63325 | 921 |
have "- a < - (- b) \<longleftrightarrow> - b < a" |
922 |
by (rule neg_less_iff_less) |
|
923 |
then show ?thesis by simp |
|
| 25077 | 924 |
qed |
925 |
||
926 |
lemma le_minus_iff: "a \<le> - b \<longleftrightarrow> b \<le> - a" |
|
927 |
proof - |
|
| 63325 | 928 |
have mm: "- (- a) < -b \<Longrightarrow> - (- b) < -a" for a b :: 'a |
929 |
by (simp only: minus_less_iff) |
|
930 |
have "- (- a) \<le> -b \<longleftrightarrow> b \<le> - a" |
|
| 25077 | 931 |
apply (auto simp only: le_less) |
932 |
apply (drule mm) |
|
933 |
apply (simp_all) |
|
934 |
apply (drule mm[simplified], assumption) |
|
935 |
done |
|
936 |
then show ?thesis by simp |
|
937 |
qed |
|
938 |
||
939 |
lemma minus_le_iff: "- a \<le> b \<longleftrightarrow> - b \<le> a" |
|
| 63325 | 940 |
by (auto simp add: le_less minus_less_iff) |
| 25077 | 941 |
|
| 63325 | 942 |
lemma diff_less_0_iff_less [simp]: "a - b < 0 \<longleftrightarrow> a < b" |
| 25077 | 943 |
proof - |
| 63325 | 944 |
have "a - b < 0 \<longleftrightarrow> a + (- b) < b + (- b)" |
945 |
by simp |
|
946 |
also have "\<dots> \<longleftrightarrow> a < b" |
|
947 |
by (simp only: add_less_cancel_right) |
|
| 25077 | 948 |
finally show ?thesis . |
949 |
qed |
|
950 |
||
|
37884
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
951 |
lemmas less_iff_diff_less_0 = diff_less_0_iff_less [symmetric] |
|
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
952 |
|
| 63325 | 953 |
lemma diff_less_eq [algebra_simps, field_simps]: "a - b < c \<longleftrightarrow> a < c + b" |
954 |
apply (subst less_iff_diff_less_0 [of a]) |
|
955 |
apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst]) |
|
956 |
apply (simp add: algebra_simps) |
|
957 |
done |
|
| 25077 | 958 |
|
| 63325 | 959 |
lemma less_diff_eq[algebra_simps, field_simps]: "a < c - b \<longleftrightarrow> a + b < c" |
960 |
apply (subst less_iff_diff_less_0 [of "a + b"]) |
|
961 |
apply (subst less_iff_diff_less_0 [of a]) |
|
962 |
apply (simp add: algebra_simps) |
|
963 |
done |
|
| 25077 | 964 |
|
| 63325 | 965 |
lemma diff_gt_0_iff_gt [simp]: "a - b > 0 \<longleftrightarrow> a > b" |
| 62348 | 966 |
by (simp add: less_diff_eq) |
|
61762
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents:
61605
diff
changeset
|
967 |
|
| 63325 | 968 |
lemma diff_le_eq [algebra_simps, field_simps]: "a - b \<le> c \<longleftrightarrow> a \<le> c + b" |
| 62348 | 969 |
by (auto simp add: le_less diff_less_eq ) |
| 25077 | 970 |
|
| 63325 | 971 |
lemma le_diff_eq [algebra_simps, field_simps]: "a \<le> c - b \<longleftrightarrow> a + b \<le> c" |
| 62348 | 972 |
by (auto simp add: le_less less_diff_eq) |
| 25077 | 973 |
|
| 63325 | 974 |
lemma diff_le_0_iff_le [simp]: "a - b \<le> 0 \<longleftrightarrow> a \<le> b" |
|
37884
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
975 |
by (simp add: algebra_simps) |
|
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
976 |
|
|
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
977 |
lemmas le_iff_diff_le_0 = diff_le_0_iff_le [symmetric] |
|
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
978 |
|
| 63325 | 979 |
lemma diff_ge_0_iff_ge [simp]: "a - b \<ge> 0 \<longleftrightarrow> a \<ge> b" |
| 62348 | 980 |
by (simp add: le_diff_eq) |
981 |
||
| 63325 | 982 |
lemma diff_eq_diff_less: "a - b = c - d \<Longrightarrow> a < b \<longleftrightarrow> c < d" |
|
37884
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
983 |
by (auto simp only: less_iff_diff_less_0 [of a b] less_iff_diff_less_0 [of c d]) |
|
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
984 |
|
| 63325 | 985 |
lemma diff_eq_diff_less_eq: "a - b = c - d \<Longrightarrow> a \<le> b \<longleftrightarrow> c \<le> d" |
|
37889
0d8058e0c270
keep explicit diff_def as legacy theorem; modernized abel_cancel simproc setup
haftmann
parents:
37884
diff
changeset
|
986 |
by (auto simp only: le_iff_diff_le_0 [of a b] le_iff_diff_le_0 [of c d]) |
| 25077 | 987 |
|
| 56950 | 988 |
lemma diff_mono: "a \<le> b \<Longrightarrow> d \<le> c \<Longrightarrow> a - c \<le> b - d" |
989 |
by (simp add: field_simps add_mono) |
|
990 |
||
991 |
lemma diff_left_mono: "b \<le> a \<Longrightarrow> c - a \<le> c - b" |
|
992 |
by (simp add: field_simps) |
|
993 |
||
994 |
lemma diff_right_mono: "a \<le> b \<Longrightarrow> a - c \<le> b - c" |
|
995 |
by (simp add: field_simps) |
|
996 |
||
997 |
lemma diff_strict_mono: "a < b \<Longrightarrow> d < c \<Longrightarrow> a - c < b - d" |
|
998 |
by (simp add: field_simps add_strict_mono) |
|
999 |
||
1000 |
lemma diff_strict_left_mono: "b < a \<Longrightarrow> c - a < c - b" |
|
1001 |
by (simp add: field_simps) |
|
1002 |
||
1003 |
lemma diff_strict_right_mono: "a < b \<Longrightarrow> a - c < b - c" |
|
1004 |
by (simp add: field_simps) |
|
1005 |
||
| 25077 | 1006 |
end |
1007 |
||
| 48891 | 1008 |
ML_file "Tools/group_cancel.ML" |
|
48556
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
huffman
parents:
45548
diff
changeset
|
1009 |
|
|
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
huffman
parents:
45548
diff
changeset
|
1010 |
simproc_setup group_cancel_add ("a + b::'a::ab_group_add") =
|
| 60758 | 1011 |
\<open>fn phi => fn ss => try Group_Cancel.cancel_add_conv\<close> |
|
48556
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
huffman
parents:
45548
diff
changeset
|
1012 |
|
|
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
huffman
parents:
45548
diff
changeset
|
1013 |
simproc_setup group_cancel_diff ("a - b::'a::ab_group_add") =
|
| 60758 | 1014 |
\<open>fn phi => fn ss => try Group_Cancel.cancel_diff_conv\<close> |
|
37884
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
1015 |
|
|
48556
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
huffman
parents:
45548
diff
changeset
|
1016 |
simproc_setup group_cancel_eq ("a = (b::'a::ab_group_add)") =
|
| 60758 | 1017 |
\<open>fn phi => fn ss => try Group_Cancel.cancel_eq_conv\<close> |
|
37889
0d8058e0c270
keep explicit diff_def as legacy theorem; modernized abel_cancel simproc setup
haftmann
parents:
37884
diff
changeset
|
1018 |
|
|
48556
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
huffman
parents:
45548
diff
changeset
|
1019 |
simproc_setup group_cancel_le ("a \<le> (b::'a::ordered_ab_group_add)") =
|
| 60758 | 1020 |
\<open>fn phi => fn ss => try Group_Cancel.cancel_le_conv\<close> |
|
48556
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
huffman
parents:
45548
diff
changeset
|
1021 |
|
|
62a3fbf9d35b
replace abel_cancel simprocs with functionally equivalent, but simpler and faster ones
huffman
parents:
45548
diff
changeset
|
1022 |
simproc_setup group_cancel_less ("a < (b::'a::ordered_ab_group_add)") =
|
| 60758 | 1023 |
\<open>fn phi => fn ss => try Group_Cancel.cancel_less_conv\<close> |
|
37884
314a88278715
discontinued pretending that abel_cancel is logic-independent; cleaned up junk
haftmann
parents:
36977
diff
changeset
|
1024 |
|
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1025 |
class linordered_ab_semigroup_add = |
|
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1026 |
linorder + ordered_ab_semigroup_add |
| 25062 | 1027 |
|
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1028 |
class linordered_cancel_ab_semigroup_add = |
|
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1029 |
linorder + ordered_cancel_ab_semigroup_add |
| 25267 | 1030 |
begin |
| 25062 | 1031 |
|
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1032 |
subclass linordered_ab_semigroup_add .. |
| 25062 | 1033 |
|
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1034 |
subclass ordered_ab_semigroup_add_imp_le |
| 28823 | 1035 |
proof |
| 25062 | 1036 |
fix a b c :: 'a |
| 63325 | 1037 |
assume le1: "c + a \<le> c + b" |
1038 |
show "a \<le> b" |
|
| 25062 | 1039 |
proof (rule ccontr) |
| 63325 | 1040 |
assume *: "\<not> ?thesis" |
1041 |
then have "b \<le> a" by (simp add: linorder_not_le) |
|
1042 |
then have le2: "c + b \<le> c + a" by (rule add_left_mono) |
|
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
1043 |
have "a = b" |
| 63325 | 1044 |
apply (insert le1 le2) |
1045 |
apply (drule antisym) |
|
1046 |
apply simp_all |
|
| 25062 | 1047 |
done |
| 63325 | 1048 |
with * show False |
| 25062 | 1049 |
by (simp add: linorder_not_le [symmetric]) |
1050 |
qed |
|
1051 |
qed |
|
1052 |
||
| 25267 | 1053 |
end |
1054 |
||
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1055 |
class linordered_ab_group_add = linorder + ordered_ab_group_add |
| 25267 | 1056 |
begin |
| 25230 | 1057 |
|
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1058 |
subclass linordered_cancel_ab_semigroup_add .. |
| 25230 | 1059 |
|
| 63325 | 1060 |
lemma equal_neg_zero [simp]: "a = - a \<longleftrightarrow> a = 0" |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1061 |
proof |
| 63325 | 1062 |
assume "a = 0" |
1063 |
then show "a = - a" by simp |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1064 |
next |
| 63325 | 1065 |
assume A: "a = - a" |
1066 |
show "a = 0" |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1067 |
proof (cases "0 \<le> a") |
| 63325 | 1068 |
case True |
1069 |
with A have "0 \<le> - a" by auto |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1070 |
with le_minus_iff have "a \<le> 0" by simp |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1071 |
with True show ?thesis by (auto intro: order_trans) |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1072 |
next |
| 63325 | 1073 |
case False |
1074 |
then have B: "a \<le> 0" by auto |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1075 |
with A have "- a \<le> 0" by auto |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1076 |
with B show ?thesis by (auto intro: order_trans) |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1077 |
qed |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1078 |
qed |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1079 |
|
| 63325 | 1080 |
lemma neg_equal_zero [simp]: "- a = a \<longleftrightarrow> a = 0" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1081 |
by (auto dest: sym) |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1082 |
|
| 63325 | 1083 |
lemma neg_less_eq_nonneg [simp]: "- a \<le> a \<longleftrightarrow> 0 \<le> a" |
| 54250 | 1084 |
proof |
| 63325 | 1085 |
assume *: "- a \<le> a" |
1086 |
show "0 \<le> a" |
|
| 54250 | 1087 |
proof (rule classical) |
| 63325 | 1088 |
assume "\<not> ?thesis" |
| 54250 | 1089 |
then have "a < 0" by auto |
| 63325 | 1090 |
with * have "- a < 0" by (rule le_less_trans) |
| 54250 | 1091 |
then show ?thesis by auto |
1092 |
qed |
|
1093 |
next |
|
| 63325 | 1094 |
assume *: "0 \<le> a" |
1095 |
then have "- a \<le> 0" by (simp add: minus_le_iff) |
|
1096 |
from this * show "- a \<le> a" by (rule order_trans) |
|
| 54250 | 1097 |
qed |
1098 |
||
| 63325 | 1099 |
lemma neg_less_pos [simp]: "- a < a \<longleftrightarrow> 0 < a" |
| 54250 | 1100 |
by (auto simp add: less_le) |
1101 |
||
| 63325 | 1102 |
lemma less_eq_neg_nonpos [simp]: "a \<le> - a \<longleftrightarrow> a \<le> 0" |
| 54250 | 1103 |
using neg_less_eq_nonneg [of "- a"] by simp |
1104 |
||
| 63325 | 1105 |
lemma less_neg_neg [simp]: "a < - a \<longleftrightarrow> a < 0" |
| 54250 | 1106 |
using neg_less_pos [of "- a"] by simp |
1107 |
||
| 63325 | 1108 |
lemma double_zero [simp]: "a + a = 0 \<longleftrightarrow> a = 0" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1109 |
proof |
| 63325 | 1110 |
assume "a + a = 0" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1111 |
then have a: "- a = a" by (rule minus_unique) |
| 35216 | 1112 |
then show "a = 0" by (simp only: neg_equal_zero) |
| 63325 | 1113 |
next |
1114 |
assume "a = 0" |
|
1115 |
then show "a + a = 0" by simp |
|
1116 |
qed |
|
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1117 |
|
| 63325 | 1118 |
lemma double_zero_sym [simp]: "0 = a + a \<longleftrightarrow> a = 0" |
1119 |
apply (rule iffI) |
|
1120 |
apply (drule sym) |
|
1121 |
apply simp_all |
|
1122 |
done |
|
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1123 |
|
| 63325 | 1124 |
lemma zero_less_double_add_iff_zero_less_single_add [simp]: "0 < a + a \<longleftrightarrow> 0 < a" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1125 |
proof |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1126 |
assume "0 < a + a" |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1127 |
then have "0 - a < a" by (simp only: diff_less_eq) |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1128 |
then have "- a < a" by simp |
| 54250 | 1129 |
then show "0 < a" by simp |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1130 |
next |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1131 |
assume "0 < a" |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1132 |
with this have "0 + 0 < a + a" |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1133 |
by (rule add_strict_mono) |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1134 |
then show "0 < a + a" by simp |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1135 |
qed |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1136 |
|
| 63325 | 1137 |
lemma zero_le_double_add_iff_zero_le_single_add [simp]: "0 \<le> a + a \<longleftrightarrow> 0 \<le> a" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1138 |
by (auto simp add: le_less) |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1139 |
|
| 63325 | 1140 |
lemma double_add_less_zero_iff_single_add_less_zero [simp]: "a + a < 0 \<longleftrightarrow> a < 0" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1141 |
proof - |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1142 |
have "\<not> a + a < 0 \<longleftrightarrow> \<not> a < 0" |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1143 |
by (simp add: not_less) |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1144 |
then show ?thesis by simp |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1145 |
qed |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1146 |
|
| 63325 | 1147 |
lemma double_add_le_zero_iff_single_add_le_zero [simp]: "a + a \<le> 0 \<longleftrightarrow> a \<le> 0" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1148 |
proof - |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1149 |
have "\<not> a + a \<le> 0 \<longleftrightarrow> \<not> a \<le> 0" |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1150 |
by (simp add: not_le) |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1151 |
then show ?thesis by simp |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1152 |
qed |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1153 |
|
| 63325 | 1154 |
lemma minus_max_eq_min: "- max x y = min (- x) (- y)" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1155 |
by (auto simp add: max_def min_def) |
|
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1156 |
|
| 63325 | 1157 |
lemma minus_min_eq_max: "- min x y = max (- x) (- y)" |
|
35036
b8c8d01cc20d
separate library theory for type classes combining lattices with various algebraic structures; more simp rules
haftmann
parents:
35028
diff
changeset
|
1158 |
by (auto simp add: max_def min_def) |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1159 |
|
| 25267 | 1160 |
end |
1161 |
||
|
35092
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1162 |
class abs = |
| 61944 | 1163 |
fixes abs :: "'a \<Rightarrow> 'a" ("\<bar>_\<bar>")
|
|
35092
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1164 |
|
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1165 |
class sgn = |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1166 |
fixes sgn :: "'a \<Rightarrow> 'a" |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1167 |
|
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1168 |
class abs_if = minus + uminus + ord + zero + abs + |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1169 |
assumes abs_if: "\<bar>a\<bar> = (if a < 0 then - a else a)" |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1170 |
|
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1171 |
class sgn_if = minus + uminus + zero + one + ord + sgn + |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1172 |
assumes sgn_if: "sgn x = (if x = 0 then 0 else if 0 < x then 1 else - 1)" |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1173 |
begin |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1174 |
|
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1175 |
lemma sgn0 [simp]: "sgn 0 = 0" |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1176 |
by (simp add:sgn_if) |
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1177 |
|
|
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
35050
diff
changeset
|
1178 |
end |
| 14738 | 1179 |
|
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
34973
diff
changeset
|
1180 |
class ordered_ab_group_add_abs = ordered_ab_group_add + abs + |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1181 |
assumes abs_ge_zero [simp]: "\<bar>a\<bar> \<ge> 0" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1182 |
and abs_ge_self: "a \<le> \<bar>a\<bar>" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1183 |
and abs_leI: "a \<le> b \<Longrightarrow> - a \<le> b \<Longrightarrow> \<bar>a\<bar> \<le> b" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1184 |
and abs_minus_cancel [simp]: "\<bar>-a\<bar> = \<bar>a\<bar>" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1185 |
and abs_triangle_ineq: "\<bar>a + b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1186 |
begin |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1187 |
|
| 25307 | 1188 |
lemma abs_minus_le_zero: "- \<bar>a\<bar> \<le> 0" |
1189 |
unfolding neg_le_0_iff_le by simp |
|
1190 |
||
1191 |
lemma abs_of_nonneg [simp]: |
|
| 63325 | 1192 |
assumes nonneg: "0 \<le> a" |
1193 |
shows "\<bar>a\<bar> = a" |
|
| 25307 | 1194 |
proof (rule antisym) |
| 63325 | 1195 |
show "a \<le> \<bar>a\<bar>" by (rule abs_ge_self) |
| 25307 | 1196 |
from nonneg le_imp_neg_le have "- a \<le> 0" by simp |
1197 |
from this nonneg have "- a \<le> a" by (rule order_trans) |
|
1198 |
then show "\<bar>a\<bar> \<le> a" by (auto intro: abs_leI) |
|
| 63325 | 1199 |
qed |
| 25307 | 1200 |
|
1201 |
lemma abs_idempotent [simp]: "\<bar>\<bar>a\<bar>\<bar> = \<bar>a\<bar>" |
|
| 63325 | 1202 |
by (rule antisym) (auto intro!: abs_ge_self abs_leI order_trans [of "- \<bar>a\<bar>" 0 "\<bar>a\<bar>"]) |
| 25307 | 1203 |
|
1204 |
lemma abs_eq_0 [simp]: "\<bar>a\<bar> = 0 \<longleftrightarrow> a = 0" |
|
1205 |
proof - |
|
1206 |
have "\<bar>a\<bar> = 0 \<Longrightarrow> a = 0" |
|
1207 |
proof (rule antisym) |
|
1208 |
assume zero: "\<bar>a\<bar> = 0" |
|
1209 |
with abs_ge_self show "a \<le> 0" by auto |
|
1210 |
from zero have "\<bar>-a\<bar> = 0" by simp |
|
| 36302 | 1211 |
with abs_ge_self [of "- a"] have "- a \<le> 0" by auto |
| 25307 | 1212 |
with neg_le_0_iff_le show "0 \<le> a" by auto |
1213 |
qed |
|
1214 |
then show ?thesis by auto |
|
1215 |
qed |
|
1216 |
||
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1217 |
lemma abs_zero [simp]: "\<bar>0\<bar> = 0" |
| 63325 | 1218 |
by simp |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1219 |
|
| 54148 | 1220 |
lemma abs_0_eq [simp]: "0 = \<bar>a\<bar> \<longleftrightarrow> a = 0" |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1221 |
proof - |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1222 |
have "0 = \<bar>a\<bar> \<longleftrightarrow> \<bar>a\<bar> = 0" by (simp only: eq_ac) |
| 63325 | 1223 |
then show ?thesis by simp |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1224 |
qed |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1225 |
|
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
1226 |
lemma abs_le_zero_iff [simp]: "\<bar>a\<bar> \<le> 0 \<longleftrightarrow> a = 0" |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1227 |
proof |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1228 |
assume "\<bar>a\<bar> \<le> 0" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1229 |
then have "\<bar>a\<bar> = 0" by (rule antisym) simp |
| 63325 | 1230 |
then show "a = 0" by simp |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1231 |
next |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1232 |
assume "a = 0" |
| 63325 | 1233 |
then show "\<bar>a\<bar> \<le> 0" by simp |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1234 |
qed |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1235 |
|
|
62379
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1236 |
lemma abs_le_self_iff [simp]: "\<bar>a\<bar> \<le> a \<longleftrightarrow> 0 \<le> a" |
|
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1237 |
proof - |
| 63325 | 1238 |
have "0 \<le> \<bar>a\<bar>" |
|
62379
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1239 |
using abs_ge_zero by blast |
|
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1240 |
then have "\<bar>a\<bar> \<le> a \<Longrightarrow> 0 \<le> a" |
|
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1241 |
using order.trans by blast |
|
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1242 |
then show ?thesis |
|
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1243 |
using abs_of_nonneg eq_refl by blast |
|
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1244 |
qed |
|
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
paulson <lp15@cam.ac.uk>
parents:
62378
diff
changeset
|
1245 |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1246 |
lemma zero_less_abs_iff [simp]: "0 < \<bar>a\<bar> \<longleftrightarrow> a \<noteq> 0" |
| 63325 | 1247 |
by (simp add: less_le) |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1248 |
|
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1249 |
lemma abs_not_less_zero [simp]: "\<not> \<bar>a\<bar> < 0" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1250 |
proof - |
| 63325 | 1251 |
have "x \<le> y \<Longrightarrow> \<not> y < x" for x y by auto |
1252 |
then show ?thesis by simp |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1253 |
qed |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1254 |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1255 |
lemma abs_ge_minus_self: "- a \<le> \<bar>a\<bar>" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1256 |
proof - |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1257 |
have "- a \<le> \<bar>-a\<bar>" by (rule abs_ge_self) |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1258 |
then show ?thesis by simp |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1259 |
qed |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1260 |
|
| 63325 | 1261 |
lemma abs_minus_commute: "\<bar>a - b\<bar> = \<bar>b - a\<bar>" |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1262 |
proof - |
| 63325 | 1263 |
have "\<bar>a - b\<bar> = \<bar>- (a - b)\<bar>" |
1264 |
by (simp only: abs_minus_cancel) |
|
1265 |
also have "\<dots> = \<bar>b - a\<bar>" by simp |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1266 |
finally show ?thesis . |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1267 |
qed |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1268 |
|
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1269 |
lemma abs_of_pos: "0 < a \<Longrightarrow> \<bar>a\<bar> = a" |
| 63325 | 1270 |
by (rule abs_of_nonneg) (rule less_imp_le) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1271 |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1272 |
lemma abs_of_nonpos [simp]: |
| 63325 | 1273 |
assumes "a \<le> 0" |
1274 |
shows "\<bar>a\<bar> = - a" |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1275 |
proof - |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1276 |
let ?b = "- a" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1277 |
have "- ?b \<le> 0 \<Longrightarrow> \<bar>- ?b\<bar> = - (- ?b)" |
| 63325 | 1278 |
unfolding abs_minus_cancel [of ?b] |
1279 |
unfolding neg_le_0_iff_le [of ?b] |
|
1280 |
unfolding minus_minus by (erule abs_of_nonneg) |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1281 |
then show ?thesis using assms by auto |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1282 |
qed |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
62348
diff
changeset
|
1283 |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1284 |
lemma abs_of_neg: "a < 0 \<Longrightarrow> \<bar>a\<bar> = - a" |
| 63325 | 1285 |
by (rule abs_of_nonpos) (rule less_imp_le) |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1286 |
|
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1287 |
lemma abs_le_D1: "\<bar>a\<bar> \<le> b \<Longrightarrow> a \<le> b" |
| 63325 | 1288 |
using abs_ge_self by (blast intro: order_trans) |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1289 |
|
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1290 |
lemma abs_le_D2: "\<bar>a\<bar> \<le> b \<Longrightarrow> - a \<le> b" |
| 63325 | 1291 |
using abs_le_D1 [of "- a"] by simp |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1292 |
|
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1293 |
lemma abs_le_iff: "\<bar>a\<bar> \<le> b \<longleftrightarrow> a \<le> b \<and> - a \<le> b" |
| 63325 | 1294 |
by (blast intro: abs_leI dest: abs_le_D1 abs_le_D2) |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1295 |
|
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1296 |
lemma abs_triangle_ineq2: "\<bar>a\<bar> - \<bar>b\<bar> \<le> \<bar>a - b\<bar>" |
| 36302 | 1297 |
proof - |
1298 |
have "\<bar>a\<bar> = \<bar>b + (a - b)\<bar>" |
|
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
54148
diff
changeset
|
1299 |
by (simp add: algebra_simps) |
| 36302 | 1300 |
then have "\<bar>a\<bar> \<le> \<bar>b\<bar> + \<bar>a - b\<bar>" |
1301 |
by (simp add: abs_triangle_ineq) |
|
1302 |
then show ?thesis |
|
1303 |
by (simp add: algebra_simps) |
|
1304 |
qed |
|
1305 |
||
1306 |
lemma abs_triangle_ineq2_sym: "\<bar>a\<bar> - \<bar>b\<bar> \<le> \<bar>b - a\<bar>" |
|
1307 |
by (simp only: abs_minus_commute [of b] abs_triangle_ineq2) |
|
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1308 |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1309 |
lemma abs_triangle_ineq3: "\<bar>\<bar>a\<bar> - \<bar>b\<bar>\<bar> \<le> \<bar>a - b\<bar>" |
| 36302 | 1310 |
by (simp add: abs_le_iff abs_triangle_ineq2 abs_triangle_ineq2_sym) |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1311 |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1312 |
lemma abs_triangle_ineq4: "\<bar>a - b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1313 |
proof - |
| 63325 | 1314 |
have "\<bar>a - b\<bar> = \<bar>a + - b\<bar>" |
1315 |
by (simp add: algebra_simps) |
|
1316 |
also have "\<dots> \<le> \<bar>a\<bar> + \<bar>- b\<bar>" |
|
1317 |
by (rule abs_triangle_ineq) |
|
| 29667 | 1318 |
finally show ?thesis by simp |
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1319 |
qed |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1320 |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1321 |
lemma abs_diff_triangle_ineq: "\<bar>a + b - (c + d)\<bar> \<le> \<bar>a - c\<bar> + \<bar>b - d\<bar>" |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1322 |
proof - |
| 63325 | 1323 |
have "\<bar>a + b - (c + d)\<bar> = \<bar>(a - c) + (b - d)\<bar>" |
1324 |
by (simp add: algebra_simps) |
|
1325 |
also have "\<dots> \<le> \<bar>a - c\<bar> + \<bar>b - d\<bar>" |
|
1326 |
by (rule abs_triangle_ineq) |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1327 |
finally show ?thesis . |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1328 |
qed |
|
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
16417
diff
changeset
|
1329 |
|
| 63325 | 1330 |
lemma abs_add_abs [simp]: "\<bar>\<bar>a\<bar> + \<bar>b\<bar>\<bar> = \<bar>a\<bar> + \<bar>b\<bar>" |
1331 |
(is "?L = ?R") |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1332 |
proof (rule antisym) |
| 63325 | 1333 |
show "?L \<ge> ?R" by (rule abs_ge_self) |
1334 |
have "?L \<le> \<bar>\<bar>a\<bar>\<bar> + \<bar>\<bar>b\<bar>\<bar>" by (rule abs_triangle_ineq) |
|
|
25303
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1335 |
also have "\<dots> = ?R" by simp |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1336 |
finally show "?L \<le> ?R" . |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1337 |
qed |
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1338 |
|
|
0699e20feabd
renamed lordered_*_* to lordered_*_add_*; further localization
haftmann
parents:
25267
diff
changeset
|
1339 |
end |
| 14738 | 1340 |
|
| 60762 | 1341 |
lemma dense_eq0_I: |
1342 |
fixes x::"'a::{dense_linorder,ordered_ab_group_add_abs}"
|
|
| 63325 | 1343 |
shows "(\<And>e. 0 < e \<Longrightarrow> \<bar>x\<bar> \<le> e) \<Longrightarrow> x = 0" |
1344 |
apply (cases "\<bar>x\<bar> = 0") |
|
1345 |
apply simp |
|
| 60762 | 1346 |
apply (simp only: zero_less_abs_iff [symmetric]) |
1347 |
apply (drule dense) |
|
1348 |
apply (auto simp add: not_less [symmetric]) |
|
1349 |
done |
|
1350 |
||
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
1351 |
hide_fact (open) ab_diff_conv_add_uminus add_0 mult_1 ab_left_minus |
|
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
1352 |
|
| 63325 | 1353 |
lemmas add_0 = add_0_left (* FIXME duplicate *) |
1354 |
lemmas mult_1 = mult_1_left (* FIXME duplicate *) |
|
1355 |
lemmas ab_left_minus = left_minus (* FIXME duplicate *) |
|
1356 |
lemmas diff_diff_eq = diff_diff_add (* FIXME duplicate *) |
|
1357 |
||
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59559
diff
changeset
|
1358 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1359 |
subsection \<open>Canonically ordered monoids\<close> |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1360 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1361 |
text \<open>Canonically ordered monoids are never groups.\<close> |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1362 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1363 |
class canonically_ordered_monoid_add = comm_monoid_add + order + |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1364 |
assumes le_iff_add: "a \<le> b \<longleftrightarrow> (\<exists>c. b = a + c)" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1365 |
begin |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1366 |
|
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1367 |
lemma zero_le[simp]: "0 \<le> x" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1368 |
by (auto simp: le_iff_add) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1369 |
|
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1370 |
lemma le_zero_eq[simp]: "n \<le> 0 \<longleftrightarrow> n = 0" |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1371 |
by (auto intro: antisym) |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1372 |
|
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1373 |
lemma not_less_zero[simp]: "\<not> n < 0" |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1374 |
by (auto simp: less_le) |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1375 |
|
| 63325 | 1376 |
lemma zero_less_iff_neq_zero: "0 < n \<longleftrightarrow> n \<noteq> 0" |
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1377 |
by (auto simp: less_le) |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1378 |
|
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1379 |
text \<open>This theorem is useful with \<open>blast\<close>\<close> |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1380 |
lemma gr_zeroI: "(n = 0 \<Longrightarrow> False) \<Longrightarrow> 0 < n" |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1381 |
by (rule zero_less_iff_neq_zero[THEN iffD2]) iprover |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1382 |
|
| 63325 | 1383 |
lemma not_gr_zero[simp]: "\<not> 0 < n \<longleftrightarrow> n = 0" |
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1384 |
by (simp add: zero_less_iff_neq_zero) |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1385 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1386 |
subclass ordered_comm_monoid_add |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1387 |
proof qed (auto simp: le_iff_add add_ac) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1388 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1389 |
lemma add_eq_0_iff_both_eq_0: "x + y = 0 \<longleftrightarrow> x = 0 \<and> y = 0" |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1390 |
by (intro add_nonneg_eq_0_iff zero_le) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1391 |
|
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1392 |
lemma gr_implies_not_zero: "m < n \<Longrightarrow> n \<noteq> 0" |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1393 |
using add_eq_0_iff_both_eq_0[of m] by (auto simp: le_iff_add less_le) |
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1394 |
|
|
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1395 |
lemmas zero_order = zero_le le_zero_eq not_less_zero zero_less_iff_neq_zero not_gr_zero |
| 63145 | 1396 |
\<comment> \<open>This should be attributed with \<open>[iff]\<close>, but then \<open>blast\<close> fails in \<open>Set\<close>.\<close> |
|
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62377
diff
changeset
|
1397 |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1398 |
end |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1399 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1400 |
class ordered_cancel_comm_monoid_diff = |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1401 |
canonically_ordered_monoid_add + comm_monoid_diff + ordered_ab_semigroup_add_imp_le |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1402 |
begin |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1403 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1404 |
context |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1405 |
fixes a b |
| 63325 | 1406 |
assumes le: "a \<le> b" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1407 |
begin |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1408 |
|
| 63325 | 1409 |
lemma add_diff_inverse: "a + (b - a) = b" |
1410 |
using le by (auto simp add: le_iff_add) |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1411 |
|
| 63325 | 1412 |
lemma add_diff_assoc: "c + (b - a) = c + b - a" |
1413 |
using le by (auto simp add: le_iff_add add.left_commute [of c]) |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1414 |
|
| 63325 | 1415 |
lemma add_diff_assoc2: "b - a + c = b + c - a" |
1416 |
using le by (auto simp add: le_iff_add add.assoc) |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1417 |
|
| 63325 | 1418 |
lemma diff_add_assoc: "c + b - a = c + (b - a)" |
1419 |
using le by (simp add: add.commute add_diff_assoc) |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1420 |
|
| 63325 | 1421 |
lemma diff_add_assoc2: "b + c - a = b - a + c" |
1422 |
using le by (simp add: add.commute add_diff_assoc) |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1423 |
|
| 63325 | 1424 |
lemma diff_diff_right: "c - (b - a) = c + a - b" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1425 |
by (simp add: add_diff_inverse add_diff_cancel_left [of a c "b - a", symmetric] add.commute) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1426 |
|
| 63325 | 1427 |
lemma diff_add: "b - a + a = b" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1428 |
by (simp add: add.commute add_diff_inverse) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1429 |
|
| 63325 | 1430 |
lemma le_add_diff: "c \<le> b + c - a" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1431 |
by (auto simp add: add.commute diff_add_assoc2 le_iff_add) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1432 |
|
| 63325 | 1433 |
lemma le_imp_diff_is_add: "a \<le> b \<Longrightarrow> b - a = c \<longleftrightarrow> b = c + a" |
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1434 |
by (auto simp add: add.commute add_diff_inverse) |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1435 |
|
| 63325 | 1436 |
lemma le_diff_conv2: "c \<le> b - a \<longleftrightarrow> c + a \<le> b" |
1437 |
(is "?P \<longleftrightarrow> ?Q") |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1438 |
proof |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1439 |
assume ?P |
| 63325 | 1440 |
then have "c + a \<le> b - a + a" |
1441 |
by (rule add_right_mono) |
|
1442 |
then show ?Q |
|
1443 |
by (simp add: add_diff_inverse add.commute) |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1444 |
next |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1445 |
assume ?Q |
| 63325 | 1446 |
then have "a + c \<le> a + (b - a)" |
1447 |
by (simp add: add_diff_inverse add.commute) |
|
|
62377
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1448 |
then show ?P by simp |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1449 |
qed |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1450 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1451 |
end |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1452 |
|
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1453 |
end |
|
ace69956d018
moved more proofs to ordered_comm_monoid_add; introduced strict_ordered_ab_semigroup/comm_monoid_add
hoelzl
parents:
62376
diff
changeset
|
1454 |
|
| 63325 | 1455 |
|
| 60758 | 1456 |
subsection \<open>Tools setup\<close> |
| 25090 | 1457 |
|
|
54147
97a8ff4e4ac9
killed most "no_atp", to make Sledgehammer more complete
blanchet
parents:
52435
diff
changeset
|
1458 |
lemma add_mono_thms_linordered_semiring: |
| 61076 | 1459 |
fixes i j k :: "'a::ordered_ab_semigroup_add" |
| 25077 | 1460 |
shows "i \<le> j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l" |
1461 |
and "i = j \<and> k \<le> l \<Longrightarrow> i + k \<le> j + l" |
|
1462 |
and "i \<le> j \<and> k = l \<Longrightarrow> i + k \<le> j + l" |
|
1463 |
and "i = j \<and> k = l \<Longrightarrow> i + k = j + l" |
|
| 63325 | 1464 |
by (rule add_mono, clarify+)+ |
| 25077 | 1465 |
|
|
54147
97a8ff4e4ac9
killed most "no_atp", to make Sledgehammer more complete
blanchet
parents:
52435
diff
changeset
|
1466 |
lemma add_mono_thms_linordered_field: |
| 61076 | 1467 |
fixes i j k :: "'a::ordered_cancel_ab_semigroup_add" |
| 25077 | 1468 |
shows "i < j \<and> k = l \<Longrightarrow> i + k < j + l" |
1469 |
and "i = j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
1470 |
and "i < j \<and> k \<le> l \<Longrightarrow> i + k < j + l" |
|
1471 |
and "i \<le> j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
1472 |
and "i < j \<and> k < l \<Longrightarrow> i + k < j + l" |
|
| 63325 | 1473 |
by (auto intro: add_strict_right_mono add_strict_left_mono |
1474 |
add_less_le_mono add_le_less_mono add_strict_mono) |
|
| 25077 | 1475 |
|
|
52435
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
52289
diff
changeset
|
1476 |
code_identifier |
|
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
52289
diff
changeset
|
1477 |
code_module Groups \<rightharpoonup> (SML) Arith and (OCaml) Arith and (Haskell) Arith |
| 33364 | 1478 |
|
| 14738 | 1479 |
end |